views:

121

answers:

1

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.

+3  A: 

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.

Joseph Sturtevant
Thanks! That does appear to be the missing key. I also see I can specify font sizes with a "qualified double" and specify points as the unit, however I wonder how to do that from code.
chaiguy