Commit a52167e7 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wineps: Move EnumFonts implementation to unixlib.

parent fb8daf33
......@@ -374,83 +374,3 @@ BOOL CDECL PSDRV_GetCharWidth(PHYSDEV dev, UINT first, UINT count, const WCHAR *
return TRUE;
}
/***********************************************************************
* PSDRV_GetFontMetric
*/
static UINT PSDRV_GetFontMetric(HDC hdc, const AFM *afm,
NEWTEXTMETRICEXW *ntmx, ENUMLOGFONTEXW *elfx)
{
/* ntmx->ntmTm is NEWTEXTMETRICW; compatible w/ TEXTMETRICW per Win32 doc */
TEXTMETRICW *tm = (TEXTMETRICW *)&(ntmx->ntmTm);
LOGFONTW *lf = &(elfx->elfLogFont);
PSFONT font;
memset(ntmx, 0, sizeof(*ntmx));
memset(elfx, 0, sizeof(*elfx));
ScaleFont(afm, -(LONG)(afm->WinMetrics.usUnitsPerEm), &font, tm);
lf->lfHeight = tm->tmHeight;
lf->lfWidth = tm->tmAveCharWidth;
lf->lfWeight = tm->tmWeight;
lf->lfItalic = tm->tmItalic;
lf->lfCharSet = tm->tmCharSet;
lf->lfPitchAndFamily = (afm->IsFixedPitch) ? FIXED_PITCH : VARIABLE_PITCH;
lstrcpynW(lf->lfFaceName, afm->FamilyName, LF_FACESIZE);
return DEVICE_FONTTYPE;
}
/***********************************************************************
* PSDRV_EnumFonts
*/
BOOL CDECL PSDRV_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lp )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pEnumFonts );
ENUMLOGFONTEXW lf;
NEWTEXTMETRICEXW tm;
BOOL ret;
AFMLISTENTRY *afmle;
FONTFAMILY *family;
ret = next->funcs->pEnumFonts( next, plf, proc, lp );
if (!ret) return FALSE;
if( plf && plf->lfFaceName[0] ) {
TRACE("lfFaceName = %s\n", debugstr_w(plf->lfFaceName));
for(family = physDev->pi->Fonts; family; family = family->next) {
if(!wcsncmp(plf->lfFaceName, family->FamilyName,
wcslen(family->FamilyName)))
break;
}
if(family) {
for(afmle = family->afmlist; afmle; afmle = afmle->next) {
UINT fm;
TRACE("Got '%s'\n", afmle->afm->FontName);
fm = PSDRV_GetFontMetric( dev->hdc, afmle->afm, &tm, &lf );
if (!(ret = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp )))
break;
}
}
} else {
TRACE("lfFaceName = NULL\n");
for(family = physDev->pi->Fonts; family; family = family->next) {
UINT fm;
afmle = family->afmlist;
TRACE("Got '%s'\n", afmle->afm->FontName);
fm = PSDRV_GetFontMetric( dev->hdc, afmle->afm, &tm, &lf );
if (!(ret = (*proc)( &lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp )))
break;
}
}
return ret;
}
......@@ -693,7 +693,6 @@ static struct gdi_dc_funcs psdrv_funcs =
.pCreateCompatibleDC = PSDRV_CreateCompatibleDC,
.pCreateDC = PSDRV_CreateDC,
.pDeleteDC = PSDRV_DeleteDC,
.pEnumFonts = PSDRV_EnumFonts,
.pGetCharWidth = PSDRV_GetCharWidth,
.pGetTextExtentExPoint = PSDRV_GetTextExtentExPoint,
.pGetTextMetrics = PSDRV_GetTextMetrics,
......
......@@ -155,11 +155,6 @@ static struct pp_data* get_handle_data(HANDLE pp)
return ret;
}
static BOOL CDECL font_EnumFonts(PHYSDEV dev, LOGFONTW *lf, FONTENUMPROCW proc, LPARAM lp)
{
return EnumFontFamiliesExW(dev->hdc, lf, proc, lp, 0);
}
static BOOL CDECL font_GetCharWidth(PHYSDEV dev, UINT first, UINT count, const WCHAR *chars, INT *buffer)
{
XFORM old, xform = { .eM11 = 1.0f };
......@@ -204,7 +199,6 @@ static HFONT CDECL font_SelectFont(PHYSDEV dev, HFONT hfont, UINT *aa_flags)
static const struct gdi_dc_funcs font_funcs =
{
.pEnumFonts = font_EnumFonts,
.pGetCharWidth = font_GetCharWidth,
.pGetTextExtentExPoint = font_GetTextExtentExPoint,
.pGetTextMetrics = font_GetTextMetrics,
......
......@@ -429,7 +429,6 @@ extern BOOL CDECL PSDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bo
extern BOOL CDECL PSDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_EndDoc( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_EndPage( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lp ) DECLSPEC_HIDDEN;
extern INT CDECL PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_data,
INT cbOutput, LPVOID out_data ) DECLSPEC_HIDDEN;
extern BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
......
......@@ -1056,6 +1056,83 @@ static HFONT CDECL select_font(PHYSDEV dev, HFONT hfont, UINT *aa_flags)
return hfont;
}
static UINT get_font_metric(HDC hdc, const AFM *afm,
NEWTEXTMETRICEXW *ntmx, ENUMLOGFONTEXW *elfx)
{
/* ntmx->ntmTm is NEWTEXTMETRICW; compatible w/ TEXTMETRICW per Win32 doc */
TEXTMETRICW *tm = (TEXTMETRICW *)&(ntmx->ntmTm);
LOGFONTW *lf = &(elfx->elfLogFont);
PSFONT font;
memset(ntmx, 0, sizeof(*ntmx));
memset(elfx, 0, sizeof(*elfx));
scale_font(afm, -(LONG)afm->WinMetrics.usUnitsPerEm, &font, tm);
lf->lfHeight = tm->tmHeight;
lf->lfWidth = tm->tmAveCharWidth;
lf->lfWeight = tm->tmWeight;
lf->lfItalic = tm->tmItalic;
lf->lfCharSet = tm->tmCharSet;
lf->lfPitchAndFamily = afm->IsFixedPitch ? FIXED_PITCH : VARIABLE_PITCH;
lstrcpynW(lf->lfFaceName, afm->FamilyName, LF_FACESIZE);
return DEVICE_FONTTYPE;
}
static BOOL CDECL enum_fonts(PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lp)
{
PSDRV_PDEVICE *pdev = get_psdrv_dev(dev);
PHYSDEV next = GET_NEXT_PHYSDEV(dev, pEnumFonts);
ENUMLOGFONTEXW lf;
NEWTEXTMETRICEXW tm;
BOOL ret;
AFMLISTENTRY *afmle;
FONTFAMILY *family;
ret = next->funcs->pEnumFonts(next, plf, proc, lp);
if (!ret) return FALSE;
if (plf && plf->lfFaceName[0])
{
TRACE("lfFaceName = %s\n", debugstr_w(plf->lfFaceName));
for (family = pdev->pi->Fonts; family; family = family->next)
{
if (!wcsncmp(plf->lfFaceName, family->FamilyName,
wcslen(family->FamilyName)))
break;
}
if (family)
{
for (afmle = family->afmlist; afmle; afmle = afmle->next)
{
UINT fm;
TRACE("Got '%s'\n", afmle->afm->FontName);
fm = get_font_metric(dev->hdc, afmle->afm, &tm, &lf);
if (!(ret = (*proc)(&lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp)))
break;
}
}
}
else
{
TRACE("lfFaceName = NULL\n");
for (family = pdev->pi->Fonts; family; family = family->next)
{
UINT fm;
afmle = family->afmlist;
TRACE("Got '%s'\n", afmle->afm->FontName);
fm = get_font_metric(dev->hdc, afmle->afm, &tm, &lf);
if (!(ret = (*proc)(&lf.elfLogFont, (TEXTMETRICW *)&tm, fm, lp)))
break;
}
}
return ret;
}
static NTSTATUS init_dc(void *arg)
{
struct init_dc_params *params = arg;
......@@ -1064,6 +1141,7 @@ static NTSTATUS init_dc(void *arg)
params->funcs->pResetDC = reset_dc;
params->funcs->pExtEscape = ext_escape;
params->funcs->pSelectFont = select_font;
params->funcs->pEnumFonts = enum_fonts;
return TRUE;
}
......
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