Example #1
0
            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);
            }
Example #2
0
        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));
        }
Example #3
0
 public KnownFont(IFont font, string selector)
 {
     _font    = font;
     Selector = selector;
     _glyph   = _font.GetGlyph(selector);
 }