The information in this article applies to:
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.
MORE INFORMATIONTo calculate the logical height, use the following formula:
LOGPIXELSY is the number of pixels contained in a logical inch on the
device. This value is obtained by calling the GetDeviceCaps() function with the LOGPIXELSY index. The value 72 is significant because one inch contains 72 points.
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:
This formula may also be written as follows:
When an application calls the CreateFont() or CreateFontIndirect() functions and specifies a negative value for the height parameter, the font mapper provides the closest match for the character height rather than the cell height. The difference between the cell height and the character height is the internal leading, as demonstrated by the following diagram:
The following formula computes the point size of a font:
The Height and Internal Leading values are obtained from the
TEXTMETRIC data structure. The LOGPIXELSY value is obtained from the
GetDeviceCaps function as outlined above.
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. Additional query words: 3.00 3.10 3.50 4.00 win16sdk TrueType
Keywords : kbNTOS350 kbNTOS351 kbNTOS400 kbWinOS95 kbSDKWin16 |
Last Reviewed: June 24, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |