I've noticed in WPF, the default font size of 12 points is roughly equivalent to 9 points in "normal" applications (e.g. WordPad), 10 pt in WPF is roughly 7 pt standard, and when I try to match the default font size of 10 pt in WordPad in WPF, I've found 13 is the closest.
First of all, why does WPF use such bizarre non-standard font sizes, and secondly, is there a reliable way to convert between the two?
My reason for asking is I want to build a font size menu with "standard" font sizes of 9, 10, 12, 14, 16, 18, 24, 36, 48, but I'm pretty sure if I use those actual values they will be wildly off.
In WPF, the default font family for text displayed on controls (like Label and Button) is Segoe UI, with a default size of 12.0 device-independent units. Because a device-independent unit is 1/96 inch, a FontSize value of 12 represents characters whose capitals are 1/8″ high.
If the font-size you want is 12px , then you should specify 0.75em (because 12/16 = 0.75).
Note: The default value for the font-size property is medium (16px) in all modern browsers like Firefox, Chrome, IE, Safari, Opera etc.
WPF uses pixels as its default unit for font size. The mapping between points (probably what you mean when you say "standard" font size) and pixels is: 1 pt = (96/72) px
This gives us a simple conversion function:
public static double PointsToPixels(double points) { return points*(96.0/72.0); }
See this question for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With