WPF Definition for FontSize

I know in WPF that FontSize = 1/96 of an inch (same as 1 pixel, I think). Is the FontSize size the height, width, or diagonal character size? I assume this is the font height, but the Microsoft documentation does not really indicate what it is.

Also, is there an easy way to get the height and width of the font size?

Answer: Thus, it looks like FontSize - this is the height, and the width can be determined (without knowing the actual character) only in monospaced fonts, since proportional fonts have different widths.

+3
source share
1 answer

, Typefaces Typography.

: Wikipedia: Typeface

, 2 - , Desktop Publishing 1/72 (0,0139 /0,35 ). (, ), em-, , , , . [3 ] , Helvetica 12 , em, Helvetica, 12 1/6 (0,17 /4,3 ). 12- Helvetica 12 .

... 72, , WinForms. WPF 96.

, MSDN Link:

FormattedText formattedText = new FormattedText(
            textBox1.Text.Substring(0, 1),  
            CultureInfo.GetCultureInfo("en-us"),
            FlowDirection.LeftToRight,
            new Typeface(textBox1.FontFamily.ToString()),
             textBox1.FontSize,
            Brushes.Black 
            );

... formattedText.WidthIncludingTrailingWhitespace;

... formattedText.Height;

+3

Source: https://habr.com/ru/post/1734932/


All Articles