views:

277

answers:

1

I know that in WPF, FontSize = 1/96 of an inch (same as 1 pixel I think). Is the FontSize dimension the height, the width, or diagonal size of a character? I would guess it's the font height, but the Microsoft documentation doesn't really indicate what it is.

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

Answer: So it looks like the FontSize is the height, and the width can only be determined (without knowing the actual character) on monospaced fonts since proportional fonts have varying widths.

+2  A: 

They are referring to Font Size as used in Typefaces for Typography.

You can read about it here: Wikipedia: Typeface

The size of typefaces and fonts is traditionally measured in points;2 point has been defined differently at different times, but now the most popular is the Desktop Publishing point of 1⁄72 in (0.0139 in/0.35 mm). When specified in typographic sizes (points, kyus), the height of an em-square, an invisible box which is typically a bit larger than the distance from the tallest ascender to the lowest descender, is scaled to equal the specified size.[3] For example, when setting Helvetica at 12 point, the em square defined in the Helvetica font is scaled to 12 points or 1⁄6 in (0.17 in/4.3 mm). Yet no particular element of 12-point Helvetica need measure exactly 12 points.

A note...72 as stated in this Wikipedia article is what WinForms used. WPF switched to 96.

As for the second part of your question, I found this resource from an 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;

NebuSoft
So it sounds like the FontSize is indeed the height and the width can only be determined (without knowing the actual character) on monospaced fonts. Thanks!
smoore