public IEnumerable <RectangleF> GetBoundingRectsForGlyphs(TFont font, IEnumerable <TGlyph> glyphs, int nVariants) { using var glyphArray = new Structures.RentedArray <TGlyph>(glyphs, nVariants); var rects = new CGRect[nVariants]; font.CtFont.GetBoundingRects(CTFontOrientation.Horizontal, glyphArray.Result.Array, rects, nVariants); return(rects.Select(rect => (RectangleF)rect)); }
public (IEnumerable <float> Advances, float Total) GetAdvancesForGlyphs (TFont font, IEnumerable <TGlyph> glyphs, int nGlyphs) { using var glyphArray = new Structures.RentedArray <TGlyph>(glyphs, nGlyphs); var advanceSizes = new CGSize[nGlyphs]; var combinedAdvance = font.CtFont.GetAdvancesForGlyphs (CTFontOrientation.Default, glyphArray.Result.Array, advanceSizes, nGlyphs); return(advanceSizes.Select(advance => (float)advance.Width), (float)combinedAdvance); }
public void Draw(IGraphicsContext <TFont, TGlyph> context) { this.DrawBackground(context); context.SaveState(); using var glyphs = new Structures.RentedArray <TGlyph>(Glyph); using var positions = new Structures.RentedArray <PointF>(new PointF()); context.Translate(new PointF(Position.X, Position.Y - ShiftDown)); context.SetTextPosition(new PointF()); context.DrawGlyphsAtPoints(glyphs.Result, Font, positions.Result, TextColor); context.RestoreState(); }