From 5c1c7a65765d08ab0016722a21157a666e2260d9 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 19 Oct 2011 13:38:10 +0200 Subject: [PATCH] gdi32: Implement GetCharWidthW as a standard driver entry point. --- dlls/gdi32/font.c | 12 ++++-------- dlls/gdi32/freetype.c | 26 ++++++++++++-------------- dlls/gdi32/gdi_private.h | 1 - 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 72d9f83c58c..d08ba4bd31b 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -1612,23 +1612,19 @@ BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar, { UINT i; BOOL ret; + PHYSDEV dev; DC * dc = get_dc_ptr( hdc ); + if (!dc) return FALSE; - if (dc->gdiFont) - ret = WineEngGetCharWidth( dc->gdiFont, firstChar, lastChar, buffer ); - else - { - PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetCharWidth ); - ret = physdev->funcs->pGetCharWidth( physdev, firstChar, lastChar, buffer); - } + dev = GET_DC_PHYSDEV( dc, pGetCharWidth ); + ret = dev->funcs->pGetCharWidth( dev, firstChar, lastChar, buffer ); if (ret) { /* convert device units to logical */ for( i = firstChar; i <= lastChar; i++, buffer++ ) *buffer = INTERNAL_XDSTOWS(dc, *buffer); - ret = TRUE; } release_dc_ptr( dc ); return ret; diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index af4da1e5c07..3f16a6f16f9 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -6309,24 +6309,29 @@ static BOOL get_glyph_index_linked(GdiFont *font, UINT c, GdiFont **linked_font, } /************************************************************* - * WineEngGetCharWidth - * + * freetype_GetCharWidth */ -BOOL WineEngGetCharWidth(GdiFont *font, UINT firstChar, UINT lastChar, - LPINT buffer) +static BOOL freetype_GetCharWidth( PHYSDEV dev, UINT firstChar, UINT lastChar, LPINT buffer ) { static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} }; UINT c; GLYPHMETRICS gm; FT_UInt glyph_index; GdiFont *linked_font; + struct freetype_physdev *physdev = get_freetype_dev( dev ); - TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer); + if (!physdev->font) + { + dev = GET_NEXT_PHYSDEV( dev, pGetCharWidth ); + return dev->funcs->pGetCharWidth( dev, firstChar, lastChar, buffer ); + } + + TRACE("%p, %d, %d, %p\n", physdev->font, firstChar, lastChar, buffer); GDI_CheckNotLock(); EnterCriticalSection( &freetype_cs ); for(c = firstChar; c <= lastChar; c++) { - get_glyph_index_linked(font, c, &linked_font, &glyph_index); + get_glyph_index_linked(physdev->font, c, &linked_font, &glyph_index); WineEngGetGlyphOutline(linked_font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL, &identity); buffer[c - firstChar] = FONT_GM(linked_font,glyph_index)->adv; @@ -7076,7 +7081,7 @@ static const struct gdi_dc_funcs freetype_funcs = NULL, /* pFlattenPath */ NULL, /* pFrameRgn */ NULL, /* pGdiComment */ - NULL, /* pGetCharWidth */ + freetype_GetCharWidth, /* pGetCharWidth */ NULL, /* pGetDeviceCaps */ NULL, /* pGetDeviceGammaRamp */ NULL, /* pGetICMProfile */ @@ -7206,13 +7211,6 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize, return 0; } -BOOL WineEngGetCharWidth(GdiFont *font, UINT firstChar, UINT lastChar, - LPINT buffer) -{ - ERR("called but we don't have FreeType\n"); - return FALSE; -} - BOOL WineEngGetCharABCWidths(GdiFont *font, UINT firstChar, UINT lastChar, LPABC buffer) { diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 47b29681abb..ad7b049afa8 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -299,7 +299,6 @@ extern BOOL WineEngGetCharABCWidthsFloat(GdiFont *font, UINT firstChar, UINT lastChar, LPABCFLOAT buffer) DECLSPEC_HIDDEN; extern BOOL WineEngGetCharABCWidthsI(GdiFont *font, UINT firstChar, UINT count, LPWORD pgi, LPABC buffer) DECLSPEC_HIDDEN; -extern BOOL WineEngGetCharWidth(GdiFont*, UINT, UINT, LPINT) DECLSPEC_HIDDEN; extern DWORD WineEngGetFontData(GdiFont*, DWORD, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN; extern DWORD WineEngGetFontUnicodeRanges(GdiFont *, LPGLYPHSET) DECLSPEC_HIDDEN; extern DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,