Commit cbd81d39 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Implement EnumDeviceFonts as a standard driver entry point.

parent 873bf81d
......@@ -276,7 +276,7 @@ static INT nulldrv_EndPage( PHYSDEV dev )
static BOOL nulldrv_EnumDeviceFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
{
return FALSE;
return TRUE;
}
static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
......
......@@ -100,23 +100,20 @@ static const struct gdi_obj_funcs font_funcs =
FONT_DeleteObject /* pDeleteObject */
};
#define ENUM_UNICODE 0x00000001
#define ENUM_CALLED 0x00000002
typedef struct
{
GDIOBJHDR header;
LOGFONTW logfont;
} FONTOBJ;
typedef struct
struct font_enum
{
LPLOGFONTW lpLogFontParam;
FONTENUMPROCW lpEnumFunc;
LPARAM lpData;
DWORD dwFlags;
BOOL unicode;
HDC hdc;
} fontEnum32;
};
/*
* For TranslateCharsetInfo
......@@ -613,7 +610,7 @@ static BOOL FONT_DeleteObject( HGDIOBJ handle )
static INT CALLBACK FONT_EnumInstance( const LOGFONTW *plf, const TEXTMETRICW *ptm,
DWORD fType, LPARAM lp )
{
fontEnum32 *pfe = (fontEnum32*)lp;
struct font_enum *pfe = (struct font_enum *)lp;
INT ret = 1;
/* lfCharSet is at the same offset in both LOGFONTA and LOGFONTW */
......@@ -626,15 +623,13 @@ static INT CALLBACK FONT_EnumInstance( const LOGFONTW *plf, const TEXTMETRICW *p
ENUMLOGFONTEXA logfont;
NEWTEXTMETRICEXA tmA;
pfe->dwFlags |= ENUM_CALLED;
if (!(pfe->dwFlags & ENUM_UNICODE))
if (!pfe->unicode)
{
FONT_EnumLogFontExWToA( (const ENUMLOGFONTEXW *)plf, &logfont);
FONT_NewTextMetricExWToA( (const NEWTEXTMETRICEXW *)ptm, &tmA );
plf = (LOGFONTW *)&logfont.elfLogFont;
ptm = (TEXTMETRICW *)&tmA;
}
ret = pfe->lpEnumFunc( plf, ptm, fType, pfe->lpData );
}
return ret;
......@@ -643,37 +638,24 @@ static INT CALLBACK FONT_EnumInstance( const LOGFONTW *plf, const TEXTMETRICW *p
/***********************************************************************
* FONT_EnumFontFamiliesEx
*/
static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf,
FONTENUMPROCW efproc,
LPARAM lParam, DWORD dwUnicode)
static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf, FONTENUMPROCW efproc,
LPARAM lParam, BOOL unicode )
{
INT ret = 1, ret2;
INT ret = 0;
DC *dc = get_dc_ptr( hDC );
fontEnum32 fe32;
BOOL enum_gdi_fonts;
if (!dc) return 0;
struct font_enum fe;
if (plf)
TRACE("lfFaceName = %s lfCharset = %d\n", debugstr_w(plf->lfFaceName),
plf->lfCharSet);
fe32.lpLogFontParam = plf;
fe32.lpEnumFunc = efproc;
fe32.lpData = lParam;
fe32.dwFlags = dwUnicode;
fe32.hdc = hDC;
enum_gdi_fonts = GetDeviceCaps(hDC, TEXTCAPS) & TC_VA_ABLE;
if (enum_gdi_fonts)
ret = WineEngEnumFonts( plf, FONT_EnumInstance, (LPARAM)&fe32 );
fe32.dwFlags &= ~ENUM_CALLED;
if (ret)
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEnumDeviceFonts );
ret2 = physdev->funcs->pEnumDeviceFonts( physdev, plf, FONT_EnumInstance, (LPARAM)&fe32 );
if(fe32.dwFlags & ENUM_CALLED) /* update ret iff a font gets enumed */
ret = ret2;
if (plf) TRACE("lfFaceName = %s lfCharset = %d\n", debugstr_w(plf->lfFaceName), plf->lfCharSet);
fe.lpLogFontParam = plf;
fe.lpEnumFunc = efproc;
fe.lpData = lParam;
fe.unicode = unicode;
fe.hdc = hDC;
ret = physdev->funcs->pEnumDeviceFonts( physdev, plf, FONT_EnumInstance, (LPARAM)&fe );
}
release_dc_ptr( dc );
return ret;
......@@ -686,7 +668,7 @@ INT WINAPI EnumFontFamiliesExW( HDC hDC, LPLOGFONTW plf,
FONTENUMPROCW efproc,
LPARAM lParam, DWORD dwFlags )
{
return FONT_EnumFontFamiliesEx( hDC, plf, efproc, lParam, ENUM_UNICODE );
return FONT_EnumFontFamiliesEx( hDC, plf, efproc, lParam, TRUE );
}
/***********************************************************************
......@@ -705,7 +687,7 @@ INT WINAPI EnumFontFamiliesExA( HDC hDC, LPLOGFONTA plf,
}
else plfW = NULL;
return FONT_EnumFontFamiliesEx( hDC, plfW, (FONTENUMPROCW)efproc, lParam, 0);
return FONT_EnumFontFamiliesEx( hDC, plfW, (FONTENUMPROCW)efproc, lParam, FALSE );
}
/***********************************************************************
......
......@@ -4584,10 +4584,9 @@ static BOOL enum_face_charsets(Face *face, struct enum_charset_list *list,
}
/*************************************************************
* WineEngEnumFonts
*
* freetype_EnumDeviceFonts
*/
DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
static BOOL freetype_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam )
{
Family *family;
Face *face;
......@@ -4627,7 +4626,7 @@ DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
face = LIST_ENTRY(face_elem_ptr, Face, entry);
if (!face_matches(face, plf)) continue;
if (!enum_face_charsets(face, &enum_charsets, proc, lparam)) return 0;
if (!enum_face_charsets(face, &enum_charsets, proc, lparam)) return FALSE;
}
}
}
......@@ -4636,11 +4635,11 @@ DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
family = LIST_ENTRY(family_elem_ptr, Family, entry);
face_elem_ptr = list_head(&family->faces);
face = LIST_ENTRY(face_elem_ptr, Face, entry);
if (!enum_face_charsets(face, &enum_charsets, proc, lparam)) return 0;
if (!enum_face_charsets(face, &enum_charsets, proc, lparam)) return FALSE;
}
}
LeaveCriticalSection( &freetype_cs );
return 1;
return TRUE;
}
static void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
......@@ -7074,7 +7073,7 @@ static const struct gdi_dc_funcs freetype_funcs =
NULL, /* pEndDoc */
NULL, /* pEndPage */
NULL, /* pEndPath */
NULL, /* pEnumDeviceFonts */
freetype_EnumDeviceFonts, /* pEnumDeviceFonts */
NULL, /* pEnumICMProfiles */
NULL, /* pExcludeClipRect */
NULL, /* pExtDeviceMode */
......@@ -7185,11 +7184,6 @@ BOOL WineEngDestroyFontInstance(HFONT hfont)
return FALSE;
}
DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
{
return 1;
}
DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
LPWORD pgi, DWORD flags)
{
......
......@@ -292,7 +292,6 @@ typedef struct
extern INT WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
extern HANDLE WineEngAddFontMemResourceEx(PVOID, DWORD, PVOID, LPDWORD) DECLSPEC_HIDDEN;
extern BOOL WineEngDestroyFontInstance(HFONT handle) DECLSPEC_HIDDEN;
extern DWORD WineEngEnumFonts(LPLOGFONTW, FONTENUMPROCW, LPARAM) DECLSPEC_HIDDEN;
extern BOOL WineEngGetCharABCWidths(GdiFont *font, UINT firstChar,
UINT lastChar, LPABC buffer) DECLSPEC_HIDDEN;
extern BOOL WineEngGetCharABCWidthsFloat(GdiFont *font, UINT firstChar,
......
......@@ -428,13 +428,17 @@ static UINT PSDRV_GetFontMetric(HDC hdc, const AFM *afm,
BOOL PSDRV_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lp )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pEnumDeviceFonts );
ENUMLOGFONTEXW lf;
NEWTEXTMETRICEXW tm;
BOOL b, bRet = 0;
BOOL ret;
AFMLISTENTRY *afmle;
FONTFAMILY *family;
char FaceName[LF_FACESIZE];
ret = next->funcs->pEnumDeviceFonts( next, plf, proc, lp );
if (!ret) return FALSE;
if( plf && plf->lfFaceName[0] ) {
WideCharToMultiByte(CP_ACP, 0, plf->lfFaceName, -1,
FaceName, sizeof(FaceName), NULL, NULL);
......@@ -450,9 +454,8 @@ BOOL PSDRV_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPA
TRACE("Got '%s'\n", afmle->afm->FontName);
fm = PSDRV_GetFontMetric( dev->hdc, afmle->afm, &tm, &lf );
if( (b = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp )) )
bRet = b;
else break;
if (!(ret = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp )))
break;
}
}
} else {
......@@ -464,10 +467,9 @@ BOOL PSDRV_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPA
afmle = family->afmlist;
TRACE("Got '%s'\n", afmle->afm->FontName);
fm = PSDRV_GetFontMetric( dev->hdc, afmle->afm, &tm, &lf );
if( (b = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp )) )
bRet = b;
else break;
if (!(ret = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp )))
break;
}
}
return bRet;
return ret;
}
......@@ -3326,14 +3326,18 @@ HFONT X11DRV_SelectFont( PHYSDEV dev, HFONT hfont )
BOOL X11DRV_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lp )
{
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pEnumDeviceFonts );
ENUMLOGFONTEXW lf;
NEWTEXTMETRICEXW tm;
fontResource* pfr = fontList;
BOOL b, bRet = 0;
BOOL ret;
LOGFONTW lfW;
ret = next->funcs->pEnumDeviceFonts( next, plf, proc, lp );
if (!ret) return FALSE;
/* don't enumerate x11 fonts if we're using client side fonts */
if (physDev->has_gdi_font) return FALSE;
if (physDev->has_gdi_font) return ret;
if (!plf)
{
......@@ -3362,9 +3366,8 @@ BOOL X11DRV_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP
plf->lfCharSet == pfi->df.dfCharSet) {
UINT xfm = XFONT_GetFontMetric( pfi, &lf, &tm );
if( (b = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, xfm, lp )) )
bRet = b;
else break;
if (!(ret = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, xfm, lp )))
break;
}
}
}
......@@ -3376,12 +3379,11 @@ BOOL X11DRV_EnumDeviceFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LP
{
UINT xfm = XFONT_GetFontMetric( pfr->fi, &lf, &tm );
if( (b = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, xfm, lp )) )
bRet = b;
else break;
if (!(ret = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, xfm, lp )))
break;
}
}
return bRet;
return ret;
}
......
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