void Initialize(IFont font, string text, IDrawStyle drawStyle = null, int? destX = null, int? destY = null) { if (drawStyle != null) ChangeDrawStyle(drawStyle, false); else if (this.drawStyle == null) ChangeDrawStyle(new DrawStyle(), false); if (destX != null) DrawX = destX.Value; if (destY != null) DrawY = destY.Value; if (font != null) { this.font = font; this.drawStyle.LineHeight = font.Info.LineHeight.Ceiling(); } originalGlyphs = new IGlyph[(text + "").Length]; for (int i = 0; i < originalGlyphs.Count; i++) originalGlyphs[i] = font.GetGlyph(text[i]); Changed = true; ID = Factory.NewID(Name); }
public static GlyphsData MeasureText(this IFont font, string text, float destX, float destY, IDrawStyle drawStyle = null) { if (font == null || string.IsNullOrEmpty(text)) { return(GlyphsData.Empty); } var Glyphs = new IGlyph[(text + "").Length]; for (int i = 0; i < Glyphs.Length; i++) { Glyphs[i] = font.GetGlyph(text[i]); } return(MeasureGlyphs(font, Glyphs, destX, destY, drawStyle)); }
public KnownFont(IFont font, string selector) { _font = font; Selector = selector; _glyph = _font.GetGlyph(selector); }