Пример #1
0
        public void Measure(char[] textBuffer, int startAt, int len, out float width, out float height)
        {
            glyphLayout.Typeface = this.CurrentTypeFace;
            var scale = CurrentTypeFace.CalculateToPixelScaleFromPointSize(this.FontSizeInPoints);
            MeasuredStringBox strBox;

            glyphLayout.MeasureString(textBuffer, startAt, len, out strBox, scale);
            width  = strBox.width;
            height = strBox.CalculateLineHeight();
        }
Пример #2
0
        public MeasuredStringBox Measure(char[] textBuffer, int startAt, int len)
        {
            glyphLayout.Typeface = this.CurrentTypeFace;
            float pxscale = CurrentTypeFace.CalculateScaleToPixelFromPointSize(this.FontSizeInPoints);

            glyphLayout.Layout(textBuffer, startAt, len);

            _reusableGlyphPlanList.Clear();
            IGlyphPositions glyphPositions = glyphLayout.ResultUnscaledGlyphPositions;

            GlyphLayoutExtensions.GenerateGlyphPlan(glyphLayout.ResultUnscaledGlyphPositions,
                                                    pxscale,
                                                    false, _reusableGlyphPlanList);
            return(new MeasuredStringBox(
                       _reusableGlyphPlanList.AccumAdvanceX * pxscale,
                       CurrentTypeFace.Ascender * pxscale,
                       CurrentTypeFace.Descender * pxscale,
                       CurrentTypeFace.LineGap * pxscale,
                       Typography.OpenFont.Extensions.TypefaceExtensions.CalculateRecommendLineSpacing(CurrentTypeFace) * pxscale));
        }