Article ID: 74298 - Last Review: November 21, 2006 - Revision: 3.2 INFO: Calculating Text Extents of Bold and Italic Text
This article was previously published under Q74298 SUMMARYGetTextExtent() can be used to calculate the extent of a string. The value returned may need to be adjusted, depending upon the style of the font. When an italic or bold font is requested and none are available, the
Graphics Device Interface (GDI) may simulate those styles using an existing
raster or vector font.
MORE INFORMATION
GDI-simulated bold and italic fonts both include overhangs. The
overhang is specified in a TEXTMETRIC structure obtained by calling
the GetTextMetrics function. The proper method for calculating the
extent of a line of italic or bold text is shown below:
GetTextExtent yields
this as the extent:
||
/ / \/
/ / / / / / / /| |
/---/ / / / / / / | |
/ / /---/ /---/ /---/ |---|
/ / / / / / / / | |
----- / / / / / / | |
^ /\ /\
Overhang || ||
Because the next Start the nonitalic H
character is italic, here because it does not
start the next slant and would partially
character within the overwrite the previous
overhang of the italic character.
current character
|| ||
|| ||
||===||
|| ||
|| ||
---<= This line represents the "extra" overhang of 1.
/\
||
GetTextExtent yields
this as the extent of the
bold H.
APPLIES TO
| Other Resources Other Support Sites
CommunityArticle Translations |






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top