Commit 5476c0e2 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdi32: ntmCellHeight and ntmAvgWidth should be in font units.

parent 57fbf143
......@@ -342,6 +342,7 @@ struct tagGdiFont {
SHORT yMax;
SHORT yMin;
DWORD ntmFlags;
UINT ntmCellHeight, ntmAvgWidth;
FONTSIGNATURE fs;
GdiFont *base_font;
VOID *GSUB_Table;
......@@ -5070,6 +5071,8 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
memcpy(&pntm->ntmTm, &font->potm->otmTextMetrics, sizeof(TEXTMETRICW));
pntm->ntmTm.ntmSizeEM = font->potm->otmEMSquare;
pntm->ntmTm.ntmCellHeight = font->ntmCellHeight;
pntm->ntmTm.ntmAvgWidth = font->ntmAvgWidth;
lstrcpynW(pelf->elfLogFont.lfFaceName,
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFamilyName),
......@@ -5086,6 +5089,8 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
get_text_metrics(font, (TEXTMETRICW *)&pntm->ntmTm);
pntm->ntmTm.ntmSizeEM = pntm->ntmTm.tmHeight - pntm->ntmTm.tmInternalLeading;
pntm->ntmTm.ntmCellHeight = pntm->ntmTm.tmHeight;
pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
lstrcpynW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
if (face->FullName)
......@@ -5096,8 +5101,6 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
}
pntm->ntmTm.ntmFlags = face->ntmFlags;
pntm->ntmTm.ntmCellHeight = pntm->ntmTm.tmHeight;
pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
pntm->ntmFontSig = face->fs;
pelf->elfScript[0] = '\0'; /* This will get set in WineEngEnumFonts */
......@@ -6611,9 +6614,10 @@ static BOOL get_outline_text_metrics(GdiFont *font)
pPost = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_post); /* we can live with this failing */
TRACE("OS/2 winA = %d winD = %d typoA = %d typoD = %d typoLG = %d FT_Face a = %d, d = %d, h = %d: HORZ a = %d, d = %d lg = %d maxY = %ld minY = %ld\n",
TRACE("OS/2 winA = %d winD = %d typoA = %d typoD = %d typoLG = %d avgW %d FT_Face a = %d, d = %d, h = %d: HORZ a = %d, d = %d lg = %d maxY = %ld minY = %ld\n",
pOS2->usWinAscent, pOS2->usWinDescent,
pOS2->sTypoAscender, pOS2->sTypoDescender, pOS2->sTypoLineGap,
pOS2->xAvgCharWidth,
ft_face->ascender, ft_face->descender, ft_face->height,
pHori->Ascender, pHori->Descender, pHori->Line_Gap,
ft_face->bbox.yMax, ft_face->bbox.yMin);
......@@ -6631,6 +6635,9 @@ static BOOL get_outline_text_metrics(GdiFont *font)
descent = pOS2->usWinDescent;
}
font->ntmCellHeight = ascent + descent;
font->ntmAvgWidth = pOS2->xAvgCharWidth;
if(font->yMax) {
TM.tmAscent = font->yMax;
TM.tmDescent = -font->yMin;
......
......@@ -2056,11 +2056,15 @@ struct enum_font_dataW
static INT CALLBACK arial_enum_proc(const LOGFONT *lf, const TEXTMETRIC *tm, DWORD type, LPARAM lParam)
{
struct enum_font_data *efd = (struct enum_font_data *)lParam;
const NEWTEXTMETRIC *ntm = (const NEWTEXTMETRIC *)tm;
ok(lf->lfHeight == tm->tmHeight, "lfHeight %d != tmHeight %d\n", lf->lfHeight, tm->tmHeight);
ok(lf->lfHeight > 0 && lf->lfHeight < 200, "enumerated font height %d\n", lf->lfHeight);
if (type != TRUETYPE_FONTTYPE) return 1;
ok(ntm->ntmCellHeight + ntm->ntmCellHeight/5 >= ntm->ntmSizeEM, "ntmCellHeight %d should be close to ntmSizeEM %d\n", ntm->ntmCellHeight, ntm->ntmSizeEM);
if (0) /* Disabled to limit console spam */
trace("enumed font \"%s\", charset %d, height %d, weight %d, italic %d\n",
lf->lfFaceName, lf->lfCharSet, lf->lfHeight, lf->lfWeight, lf->lfItalic);
......@@ -2075,11 +2079,15 @@ static INT CALLBACK arial_enum_proc(const LOGFONT *lf, const TEXTMETRIC *tm, DWO
static INT CALLBACK arial_enum_procw(const LOGFONTW *lf, const TEXTMETRICW *tm, DWORD type, LPARAM lParam)
{
struct enum_font_dataW *efd = (struct enum_font_dataW *)lParam;
const NEWTEXTMETRICW *ntm = (const NEWTEXTMETRICW *)tm;
ok(lf->lfHeight == tm->tmHeight, "lfHeight %d != tmHeight %d\n", lf->lfHeight, tm->tmHeight);
ok(lf->lfHeight > 0 && lf->lfHeight < 200, "enumerated font height %d\n", lf->lfHeight);
if (type != TRUETYPE_FONTTYPE) return 1;
ok(ntm->ntmCellHeight + ntm->ntmCellHeight/5 >= ntm->ntmSizeEM, "ntmCellHeight %d should be close to ntmSizeEM %d\n", ntm->ntmCellHeight, ntm->ntmSizeEM);
if (0) /* Disabled to limit console spam */
trace("enumed font %s, charset %d, height %d, weight %d, italic %d\n",
wine_dbgstr_w(lf->lfFaceName), lf->lfCharSet, lf->lfHeight, lf->lfWeight, lf->lfItalic);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment