Converting between WPF font size and "standard" font size

devios1 picture devios1 · Aug 9, 2010 · Viewed 18.4k times · Source

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.

Answer

Joseph Sturtevant picture Joseph Sturtevant · Aug 10, 2010

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.