EDN Admin
Well-known member
<div style="color:black; background-color:white
<pre><span style="color:blue int iLogPixelsY;
iLogPixelsY = GetDeviceCaps(hdc, LOGPIXELSY);
LOGFONT lf;
<span style="color:blue int iPts;
iPts = 22;
memset(&lf, 0, <span style="color:blue sizeof(LOGFONT));
lf.lfHeight = -iPts * iLogPixelsY / 72;
lf.lfWeight = FW_NORMAL;
lf.lfItalic = 0;
lf.lfCharSet = 0;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
wcscpy(lf.lfFaceName, L<span style="color:#a31515 "Cambria Math");
HFONT hFont;
hFont = CreateFontIndirect(&lf);
hFont = (HFONT)SelectObject(hdc, hFont);
TCHAR tx;
tx = a;
TEXTMETRIC tm;
GetTextMetrics(hdc, &tm);
GLYPHMETRICS gm;
GetGlyphOutline(hdc, tx, GGO_METRICS, &gm, 0, NULL, &gmat);
[/code]
If I run the code with "Cambria Math" as above, I get the following values for
tm and gm :
tm.tmHeight = 161
tm.tmAscent = 90
tm.tmDescent = 71
These are clearly incorrect values !
<br/>
gm.gmBlackBoxY = 14, which seems to be correct.
Now, if I just change the face name to "Arial" in the LOGFONT structure lf, I get the following values for
tm and gm .
tm.tmHeight = 33
tm.tmAscent = 27
tm.tmDescent = 6
and
gm.gmBlackBoxY = 15
which seem to be correct !
Maybe Im missing something int the definition of the LOGFONT structure for the "Cambria Math" font.
<br/>
<br/>
<br/>
View the full article
<pre><span style="color:blue int iLogPixelsY;
iLogPixelsY = GetDeviceCaps(hdc, LOGPIXELSY);
LOGFONT lf;
<span style="color:blue int iPts;
iPts = 22;
memset(&lf, 0, <span style="color:blue sizeof(LOGFONT));
lf.lfHeight = -iPts * iLogPixelsY / 72;
lf.lfWeight = FW_NORMAL;
lf.lfItalic = 0;
lf.lfCharSet = 0;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
wcscpy(lf.lfFaceName, L<span style="color:#a31515 "Cambria Math");
HFONT hFont;
hFont = CreateFontIndirect(&lf);
hFont = (HFONT)SelectObject(hdc, hFont);
TCHAR tx;
tx = a;
TEXTMETRIC tm;
GetTextMetrics(hdc, &tm);
GLYPHMETRICS gm;
GetGlyphOutline(hdc, tx, GGO_METRICS, &gm, 0, NULL, &gmat);
[/code]
If I run the code with "Cambria Math" as above, I get the following values for
tm and gm :
tm.tmHeight = 161
tm.tmAscent = 90
tm.tmDescent = 71
These are clearly incorrect values !
<br/>
gm.gmBlackBoxY = 14, which seems to be correct.
Now, if I just change the face name to "Arial" in the LOGFONT structure lf, I get the following values for
tm and gm .
tm.tmHeight = 33
tm.tmAscent = 27
tm.tmDescent = 6
and
gm.gmBlackBoxY = 15
which seem to be correct !
Maybe Im missing something int the definition of the LOGFONT structure for the "Cambria Math" font.
<br/>
<br/>
<br/>
View the full article