Thursday, March 31, 2011

Why is a font in .NET of size 8 displayed as 8.25?

When you select, for example, a Size of 8 in a Font Dialog for Microsoft Sans Serif, it returns a font that .NET displays as having a size 8.25?

Why is this exactly?

From stackoverflow
  • This is most likely due to the way the Windows Font Mapper calculates font sizes. There is a slight difference between pixel heights of font cells and normal "points" @ 1/72 of an inch.

    More info here: http://msdn.microsoft.com/en-us/library/ms969909.aspx

  • A point is 1/72 of an inch, so the font should be 8/72 (0.111111) inches high. Windows assumes a standard display is 96 DPI, unless you take pains to configure it otherwise. That means it tries to create a font that's 10.66667 pixels high; it rounds to 11 pixels. When you convert that back to points ((11 / 96) * 72), it becomes 8.25.

0 comments:

Post a Comment