Alexandre Julliard : gdi32: Implement GetCharWidthW as a standard driver entry point.

Alexandre Julliard julliard at winehq.org
Thu Oct 20 14:25:11 CDT 2011


Module: wine
Branch: master
Commit: 5c1c7a65765d08ab0016722a21157a666e2260d9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5c1c7a65765d08ab0016722a21157a666e2260d9

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Oct 19 13:38:10 2011 +0200

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 72d9f83..d08ba4b 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 af4da1e..3f16a6f 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 47b2968..ad7b049 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,




More information about the wine-cvs mailing list