[FONTVIEW]

Improve font type detection. Patch by Katayama Hirofumi. Slightly modified by me.
CORE-6801 #resolve

svn path=/trunk/; revision=58315
This commit is contained in:
Timo Kreuzer 2013-02-16 11:39:15 +00:00
parent d77cbc7506
commit 413592e946

View file

@ -136,6 +136,28 @@ Display_DrawText(HDC hDC, DISPLAYDATA* pData, int nYPos)
return y;
}
static int
CALLBACK
EnumFontFamProcW(
const LOGFONTW *lpelfe,
const TEXTMETRICW *lptm,
DWORD FontType,
LPARAM lParam)
{
PNEWTEXTMETRICW pntmw = (PNEWTEXTMETRICW)lptm;
PBOOL pfOpenType = (PBOOL)lParam;
if (FontType & TRUETYPE_FONTTYPE)
{
if (pntmw->ntmFlags & (NTM_TT_OPENTYPE | NTM_PS_OPENTYPE))
{
*pfOpenType = TRUE;
return FALSE;
}
}
return TRUE;
}
static LRESULT
Display_SetTypeFace(HWND hwnd, PEXTLOGFONTW pExtLogFont)
{
@ -160,12 +182,27 @@ Display_SetTypeFace(HWND hwnd, PEXTLOGFONTW pExtLogFont)
pData->hCharSetFont = CreateFontIndirectW(&logfont);
/* Get font format */
// FIXME: Get the real font format (OpenType?)
SelectObject(hDC, pData->hCharSetFont);
GetTextMetrics(hDC, &tm);
if ((tm.tmPitchAndFamily & TMPF_TRUETYPE) == TMPF_TRUETYPE)
if (tm.tmPitchAndFamily & TMPF_TRUETYPE)
{
swprintf(pData->szFormat, L" (TrueType)");
BOOL fOpenType = FALSE;
EnumFontFamiliesExW(hDC, &logfont,
EnumFontFamProcW, (LPARAM)&fOpenType, 0);
if (fOpenType)
swprintf(pData->szFormat, L" (OpenType)");
else
swprintf(pData->szFormat, L" (TrueType)");
}
else if (tm.tmPitchAndFamily & TMPF_VECTOR)
{
swprintf(pData->szFormat, L" (Vector)");
}
else
{
swprintf(pData->szFormat, L" (Raster)");
}
for (i = 0; i < MAX_SIZES; i++)