Exemplo n.º 1
0
 internal AtlasChar(AtlasFont font, char chr, int adv, AtlasImage img)
 {
     Font    = font;
     Char    = chr;
     Advance = adv;
     Image   = img;
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 public bool TryGetFont(string name, out AtlasFont result)
 {
     return(fonts.TryGetValue(name, out result));
 }
Exemplo n.º 5
0
 public void DrawText(AtlasFont font, string text, Vector2 position, Color4 color)
 {
     DrawText(font, ref text, position, color);
 }