Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        public Size MeasureString(char[] str, int startAt, int len, RequestFont font)
        {
            //resolve type face
            Typeface typeface = typefaceStore.GetTypeface(font.Name, InstalledFontStyle.Normal);

            glyphLayout.Typeface = typeface;
            MeasuredStringBox result;
            float             scale = typeface.CalculateToPixelScaleFromPointSize(font.SizeInPoints);

            //measure string at specific px scale
            glyphLayout.MeasureString(str, startAt, len, out result, scale);

            return(new Size((int)result.width, (int)result.CalculateLineHeight()));
        }