コード例 #1
0
        public IEnumerable <RectangleF> GetBoundingRectsForGlyphs(TFont font, ForEach <TGlyph> glyphs, int nVariants)
        {
            var glyphArray = new TGlyph[nVariants];

            glyphs.CopyTo(glyphArray);
            var rects = new CGRect[nVariants];

            font.CtFont.GetBoundingRects(CTFontOrientation.Horizontal, glyphArray, rects, nVariants);
            return(rects.Select(rect => (RectangleF)rect));
        }
コード例 #2
0
        public (IEnumerable <float> Advances, float Total) GetAdvancesForGlyphs(TFont font, ForEach <TGlyph> glyphs, int nGlyphs)
        {
            var glyphArray = new TGlyph[nGlyphs];

            glyphs.CopyTo(glyphArray);
            var advanceSizes    = new CGSize[nGlyphs];
            var combinedAdvance = font.CtFont.GetAdvancesForGlyphs(CTFontOrientation.Default, glyphArray, advanceSizes, nGlyphs);

            return(advanceSizes.Select(advance => (float)advance.Width), (float)combinedAdvance);
        }
コード例 #3
0
        public void DrawGlyphsAtPoints(ForEach <TGlyph> glyphs, TFont font, ForEach <PointF> points, Color?color)
        {
            DebugWriteLine(glyphs, points);
            var cgPoints = points.Select(p => (CGPoint)p);
            var cgArray  = new RentedArray <CGPoint>(cgPoints.Count);

            cgPoints.CopyTo(cgArray.Array);
            var glyphArray = new RentedArray <TGlyph>(cgPoints.Count);

            glyphs.CopyTo(glyphArray.Array);
            var ctFont = font.CtFont;

            if (color.HasValue)
            {
                CgContext.SetFillColor(color.Value.ToCgColor());
            }
            ctFont.DrawGlyphs(CgContext, glyphArray.Array, cgArray.Array);
            cgArray.Return();
            glyphArray.Return();
        }