From 441d6cfcd4649af7df4f81f1f2217c0348b559ab Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 20 Oct 2011 17:14:53 +0200 Subject: [PATCH] gdi32: Implement GetTextFace as a standard driver entry point. --- dlls/gdi32/driver.c | 15 ++++++++++++++- dlls/gdi32/font.c | 19 ++++--------------- dlls/gdi32/freetype.c | 35 +++++++++++++++++++---------------- dlls/gdi32/gdi_private.h | 1 - 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index d2883a7bc3c..ea15eab884e 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -434,7 +434,20 @@ static BOOL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name ) { - return 0; + INT ret = 0; + LOGFONTW font; + HFONT hfont = GetCurrentObject( dev->hdc, OBJ_FONT ); + + if (GetObjectW( hfont, sizeof(font), &font )) + { + ret = strlenW( font.lfFaceName ) + 1; + if (name) + { + lstrcpynW( name, font.lfFaceName, size ); + ret = min( size, ret ); + } + } + return ret; } static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics ) diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 98529db97d3..ae00b899ea4 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -852,25 +852,14 @@ INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name ) */ INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name ) { - FONTOBJ *font; - INT ret = 0; + PHYSDEV dev; + INT ret; DC * dc = get_dc_ptr( hdc ); if (!dc) return 0; - if(dc->gdiFont) - ret = WineEngGetTextFace(dc->gdiFont, count, name); - else if ((font = GDI_GetObjPtr( dc->hFont, OBJ_FONT ))) - { - INT n = strlenW(font->logfont.lfFaceName) + 1; - if (name) - { - lstrcpynW( name, font->logfont.lfFaceName, count ); - ret = min(count, n); - } - else ret = n; - GDI_ReleaseObj( dc->hFont ); - } + dev = GET_DC_PHYSDEV( dc, pGetTextFace ); + ret = dev->funcs->pGetTextFace( dev, count, name ); release_dc_ptr( dc ); return ret; } diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 7ca72629fd3..3ac3677cc5a 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -6595,17 +6595,26 @@ DWORD WineEngGetFontData(GdiFont *font, DWORD table, DWORD offset, LPVOID buf, } /************************************************************* - * WineEngGetTextFace - * + * freetype_GetTextFace */ -INT WineEngGetTextFace(GdiFont *font, INT count, LPWSTR str) +static INT freetype_GetTextFace( PHYSDEV dev, INT count, LPWSTR str ) { - INT n = strlenW(font->name) + 1; - if(str) { - lstrcpynW(str, font->name, count); - return min(count, n); - } else - return n; + INT n; + struct freetype_physdev *physdev = get_freetype_dev( dev ); + + if (!physdev->font) + { + dev = GET_NEXT_PHYSDEV( dev, pGetTextFace ); + return dev->funcs->pGetTextFace( dev, count, str ); + } + + n = strlenW(physdev->font->name) + 1; + if (str) + { + lstrcpynW(str, physdev->font->name, count); + n = min(count, n); + } + return n; } /************************************************************* @@ -7138,7 +7147,7 @@ static const struct gdi_dc_funcs freetype_funcs = freetype_GetTextCharsetInfo, /* pGetTextCharsetInfo */ freetype_GetTextExtentExPoint, /* pGetTextExtentExPoint */ freetype_GetTextExtentExPointI, /* pGetTextExtentExPointI */ - NULL, /* pGetTextFace */ + freetype_GetTextFace, /* pGetTextFace */ freetype_GetTextMetrics, /* pGetTextMetrics */ NULL, /* pIntersectClipRect */ NULL, /* pInvertRgn */ @@ -7234,12 +7243,6 @@ DWORD WineEngGetFontData(GdiFont *font, DWORD table, DWORD offset, LPVOID buf, return GDI_ERROR; } -INT WineEngGetTextFace(GdiFont *font, INT count, LPWSTR str) -{ - ERR("called but we don't have FreeType\n"); - return 0; -} - INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv) { FIXME("(%s, %x, %p): stub\n", debugstr_w(file), flags, pdv); diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index ee7aacfd003..2e1a650b642 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -294,7 +294,6 @@ extern HANDLE WineEngAddFontMemResourceEx(PVOID, DWORD, PVOID, LPDWORD) DECLSPEC extern BOOL WineEngDestroyFontInstance(HFONT handle) DECLSPEC_HIDDEN; extern DWORD WineEngGetFontData(GdiFont*, DWORD, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN; extern BOOL WineEngGetLinkedHFont(DC *dc, WCHAR c, HFONT *new_hfont, UINT *glyph) DECLSPEC_HIDDEN; -extern INT WineEngGetTextFace(GdiFont*, INT, LPWSTR) DECLSPEC_HIDDEN; extern BOOL WineEngFontIsLinked(GdiFont*) DECLSPEC_HIDDEN; extern BOOL WineEngInit(void) DECLSPEC_HIDDEN; extern BOOL WineEngRealizationInfo(GdiFont*, realization_info_t*) DECLSPEC_HIDDEN; -- 2.11.4.GIT