How to find the width and height of the text with specified font ?
How to find the width and height of the text with specified font :
LOGFONT logFont... which holds information about the selected font...
HFONT hFont = CreateFontIndirect(&logfont);
SelectObject(graphics->GetHdc(),(HGDIOBJ)hFont);
GetTextExtentPoint32 () ... returns the width and height of the text
we can get width here...
we may get Height From the following :
TextMetrics tm;
GetTextMetrics(&tm);
tm.Height - Height of the text....
The GetTextExtentPoint32 function computes the width and height of the specified string of text. the GetTextExtentPoint32 function initializes the members of a SIZE structure with the length and height of the specified string. The GetTextMetrics function retrieves the overhang for the current font. Because the overhang is zero if the font is a TrueType font, the overhang value does not change the string placement. For raster fonts, however, it is important to use the overhang value.
LOGFONT logFont... which holds information about the selected font...
HFONT hFont = CreateFontIndirect(&logfont);
SelectObject(graphics->GetHdc(),(HGDIOBJ)hFont);
GetTextExtentPoint32 () ... returns the width and height of the text
we can get width here...
we may get Height From the following :
TextMetrics tm;
GetTextMetrics(&tm);
tm.Height - Height of the text....
The GetTextExtentPoint32 function computes the width and height of the specified string of text. the GetTextExtentPoint32 function initializes the members of a SIZE structure with the length and height of the specified string. The GetTextMetrics function retrieves the overhang for the current font. Because the overhang is zero if the font is a TrueType font, the overhang value does not change the string placement. For raster fonts, however, it is important to use the overhang value.
Labels: MFC problems
0 Comments:
Post a Comment
<< Home