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

Alexandre Julliard julliard at winehq.org
Wed Oct 26 12:35:46 CDT 2011


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Oct 20 16:39:53 2011 +0200

gdi32: Implement GetKerningPairs as a standard driver entry point.

---

 dlls/gdi32/font.c        |    8 ++++----
 dlls/gdi32/freetype.c    |   33 +++++++++++++++++++--------------
 dlls/gdi32/gdi_private.h |    1 -
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 26eba55..9859f3c 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -2664,7 +2664,8 @@ DWORD WINAPI GetKerningPairsW( HDC hDC, DWORD cPairs,
                                  LPKERNINGPAIR lpKerningPairs )
 {
     DC *dc;
-    DWORD ret = 0;
+    DWORD ret;
+    PHYSDEV dev;
 
     TRACE("(%p,%d,%p)\n", hDC, cPairs, lpKerningPairs);
 
@@ -2677,9 +2678,8 @@ DWORD WINAPI GetKerningPairsW( HDC hDC, DWORD cPairs,
     dc = get_dc_ptr(hDC);
     if (!dc) return 0;
 
-    if (dc->gdiFont)
-        ret = WineEngGetKerningPairs(dc->gdiFont, cPairs, lpKerningPairs);
-
+    dev = GET_DC_PHYSDEV( dc, pGetKerningPairs );
+    ret = dev->funcs->pGetKerningPairs( dev, cPairs, lpKerningPairs );
     release_dc_ptr( dc );
     return ret;
 }
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index a98cf36..6d21cc9 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -6896,7 +6896,10 @@ static DWORD parse_format0_kern_subtable(GdiFont *font,
     return nPairs;
 }
 
-DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair)
+/*************************************************************
+ * freetype_GetKerningPairs
+ */
+static DWORD freetype_GetKerningPairs( PHYSDEV dev, DWORD cPairs, KERNINGPAIR *kern_pair )
 {
     DWORD length;
     void *buf;
@@ -6904,6 +6907,14 @@ DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair
     const struct TT_kern_subtable *tt_kern_subtable;
     USHORT i, nTables;
     USHORT *glyph_to_char;
+    GdiFont *font;
+    struct freetype_physdev *physdev = get_freetype_dev( dev );
+
+    if (!(font = physdev->font))
+    {
+        dev = GET_NEXT_PHYSDEV( dev, pGetKerningPairs );
+        return dev->funcs->pGetKerningPairs( dev, cPairs, kern_pair );
+    }
 
     GDI_CheckNotLock();
     EnterCriticalSection( &freetype_cs );
@@ -6913,11 +6924,11 @@ DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair
         {
             cPairs = min(cPairs, font->total_kern_pairs);
             memcpy(kern_pair, font->kern_pairs, cPairs * sizeof(*kern_pair));
-            LeaveCriticalSection( &freetype_cs );
-            return cPairs;
         }
+        else cPairs = font->total_kern_pairs;
+
         LeaveCriticalSection( &freetype_cs );
-        return font->total_kern_pairs;
+        return cPairs;
     }
 
     font->total_kern_pairs = 0;
@@ -7038,11 +7049,11 @@ DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair
     {
         cPairs = min(cPairs, font->total_kern_pairs);
         memcpy(kern_pair, font->kern_pairs, cPairs * sizeof(*kern_pair));
-        LeaveCriticalSection( &freetype_cs );
-        return cPairs;
     }
+    else cPairs = font->total_kern_pairs;
+
     LeaveCriticalSection( &freetype_cs );
-    return font->total_kern_pairs;
+    return cPairs;
 }
 
 static const struct gdi_dc_funcs freetype_funcs =
@@ -7097,7 +7108,7 @@ static const struct gdi_dc_funcs freetype_funcs =
     freetype_GetGlyphOutline,           /* pGetGlyphOutline */
     NULL,                               /* pGetICMProfile */
     NULL,                               /* pGetImage */
-    NULL,                               /* pGetKerningPairs */
+    freetype_GetKerningPairs,           /* pGetKerningPairs */
     NULL,                               /* pGetNearestColor */
     NULL,                               /* pGetOutlineTextMetrics */
     NULL,                               /* pGetPixel */
@@ -7267,12 +7278,6 @@ BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
     return TRUE;
 }
 
-DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair)
-{
-    ERR("called but we don't have FreeType\n");
-    return 0;
-}
-
 BOOL WineEngRealizationInfo(GdiFont *font, realization_info_t *info)
 {
     ERR("called but we don't have FreeType\n");
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index d0727a2..5e685d3 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -293,7 +293,6 @@ 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 WineEngGetFontData(GdiFont*, DWORD, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN;
-extern DWORD WineEngGetKerningPairs(GdiFont*, DWORD, KERNINGPAIR *) DECLSPEC_HIDDEN;
 extern BOOL WineEngGetLinkedHFont(DC *dc, WCHAR c, HFONT *new_hfont, UINT *glyph) DECLSPEC_HIDDEN;
 extern UINT WineEngGetOutlineTextMetrics(GdiFont*, UINT, LPOUTLINETEXTMETRICW) DECLSPEC_HIDDEN;
 extern UINT WineEngGetTextCharsetInfo(GdiFont *font, LPFONTSIGNATURE fs, DWORD flags) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list