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