示例#1
0
 internal AtlasChar(AtlasFont font, char chr, int adv, AtlasImage img)
 {
     Font    = font;
     Char    = chr;
     Advance = adv;
     Image   = img;
 }
示例#2
0
        public void DrawText(AtlasFont font, ref string text, Vector2 position, Color4 color)
        {
            var pos = position;

            AtlasChar prev = null;
            AtlasChar chr;

            for (int i = 0; i < text.Length; ++i)
            {
                chr = font.GetChar(text[i]);

                if (prev != null)
                {
                    pos.X += prev.GetKerning(chr.Char);
                }

                if (chr.Image != null)
                {
                    DrawImage(chr.Image, pos, color);
                }

                pos.X += chr.Advance;
                prev   = chr;
            }
        }
示例#3
0
        public AtlasFont AddFont(string name, int ascent, int descent, int lineGap)
        {
            if (fonts.ContainsKey(name))
            {
                throw new Exception($"Atlas already has font with name: \"{name}\"");
            }

            var font = new AtlasFont(this, ref name, ascent, descent, lineGap);

            fonts.Add(name, font);
            return(font);
        }
示例#4
0
 public bool TryGetFont(string name, out AtlasFont result)
 {
     return(fonts.TryGetValue(name, out result));
 }
示例#5
0
 public void DrawText(AtlasFont font, string text, Vector2 position, Color4 color)
 {
     DrawText(font, ref text, position, color);
 }