Select the product you need help with
INFO: Calculating The Logical Height and Point Size of a FontArticle ID: 74299 - View products that this article applies to. This article was previously published under Q74299 SUMMARY
To create a font in the Microsoft Windows graphical environment given only
the required point size, an application must calculate the logical height
of the font because the CreateFont() and CreateFontIndirect() functions use logical units to specify height.
To describe a font to the user, an application can calculate a font's point size, given its height. This article provides the formulas required to perform these calculations for the MM_TEXT mapping mode. You will have to derive a new equation to calculate the font size in another mapping mode. MORE INFORMATION
To calculate the logical height, use the following formula:
Point Size * LOGPIXELSY
height = Internal Leading + -------------------------
72
The problem with this calculation is that there is no method to determine the internal leading for the font because it has not yet been created. To work around this difficulty, use the following variation of the formula:
-(Point Size * LOGPIXELSY)
height = --------------------------
72
---------- <------------------------------ | | |- Internal Leading | | | | | <--------- | | | | | | |- Cell Height | |---| | |- Character Height | | | | | | | | | | | | | ---------- <------------------------------
(Height - Internal Leading) * 72
Point Size = --------------------------------
LOGPIXELSY
Round the calculated point size to the nearest integer. The Windows MulDiv() function rounds its result and is an excellent choice to perform the previous calculation. PropertiesArticle ID: 74299 - Last Review: November 21, 2006 - Revision: 3.2 APPLIES TO
| Article Translations
|


Back to the top








