TEXTMETRIC结构和“Cambria Math”字体的问题

如果我运行下面的代码,使用“cambria Math”字体获得tm和gm结构的以下值:

tm.tmHeight = 161 tm.tmAscent = 90 tm.tmDescent = 71 

 gm.gmBlackBoxY = 14 

tm中的值显然是错误的gmBlackBoxY似乎是正确的。

现在,如果我运行的代码

 lfFaceName = "Arial" 

我得到tmgm以下的值,这是正确的:

 tm.tmHeight = 33 tm.tmAscent = 27 tm.tmDescent = 6 

 gm.gmBlackBoxY = 15 

码:

 int iLogPixelsY; iLogPixelsY = GetDeviceCaps(hdc,LOGPIXELSY); LOGFONT lf; int iPts; iPts = 22; memset(&lf, 0, 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"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); 

任何人都可以解释为“Cambria Math”字体获得TEXTMETRIC结构的明显不正确吗?

代码中的错误不适用于获取TEXTMETRIC结构(不包括在同一代码中使用TCHAR,CHAR和WCHAR函数和变量)。

 tm.tmHeight == 161; tm.tmAscent == 90; tm.tmDescent == 71; tm.tmInternalLeading == 132; 

上面的行没有任何错误!

 tm.tmHeight == tm.tmAscent + tm.tmDescent; tm.tmHeight == tm.tmInternalLeading + MulDiv(22,GetDeviceCaps(hdc,LOGPIXELSY),72); 

“坎布里亚数学”是用这些参数设计的!

转到链接http://www.ascenderfonts.com/font/cambria-regular.aspx更改字体大小为22pt(或其他),并查看字体“Cambria”的顶部和底部边距之间的差异和字体“坎布里亚数学”。