[PATCH 1/2] gdi32: Move EnumFontFamiliesEx16() to gdi16.c and reimplement it based on EnumFontFamiliesExW().

Michael Stefaniuc mstefani at redhat.de
Tue Feb 19 17:13:32 CST 2008


---
 dlls/gdi32/font.c  |  140 ----------------------------------------------------
 dlls/gdi32/gdi16.c |  109 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+), 140 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index e2aca59..80407e3 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -234,21 +234,6 @@ static void FONT_LogFontWToA( const LOGFONTW *fontW, LPLOGFONTA fontA )
     fontA->lfFaceName[LF_FACESIZE-1] = 0;
 }
 
-static void FONT_EnumLogFontExWTo16( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEX16 font16 )
-{
-    FONT_LogFontWTo16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
-
-    WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
-			 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
-    font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
-    WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
-			 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
-    font16->elfStyle[LF_FACESIZE-1] = '\0';
-    WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
-			 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
-    font16->elfScript[LF_FACESIZE-1] = '\0';
-}
-
 static void FONT_EnumLogFontExWToA( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEXA fontA )
 {
     FONT_LogFontWToA( (const LOGFONTW *)fontW, (LPLOGFONTA)fontA);
@@ -299,35 +284,6 @@ static void FONT_TextMetricWToA(const TEXTMETRICW *ptmW, LPTEXTMETRICA ptmA )
 }
 
 
-static void FONT_NewTextMetricExWTo16(const NEWTEXTMETRICEXW *ptmW, LPNEWTEXTMETRICEX16 ptm16 )
-{
-    ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
-    ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
-    ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
-    ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
-    ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
-    ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
-    ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
-    ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
-    ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
-    ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
-    ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
-    ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
-    ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
-    ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
-    ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
-    ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
-    ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
-    ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
-    ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
-    ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
-    ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
-    ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
-    ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
-    ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
-    memcpy(&ptm16->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
-}
-
 static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRICEXA *ptmA )
 {
     FONT_TextMetricWToA((const TEXTMETRICW *)ptmW, (LPTEXTMETRICA)ptmA);
@@ -656,45 +612,6 @@ static BOOL FONT_DeleteObject( HGDIOBJ handle, void *obj )
 
 
 /***********************************************************************
- *              FONT_EnumInstance16
- *
- * Called by the device driver layer to pass font info
- * down to the application.
- *
- * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
- *       We have to use other types because of the FONTENUMPROCW definition.
- */
-static INT CALLBACK FONT_EnumInstance16( const LOGFONTW *plf, const TEXTMETRICW *ptm,
-                                         DWORD fType, LPARAM lp )
-{
-    fontEnum16 *pfe = (fontEnum16*)lp;
-    INT ret = 1;
-
-    if (!pfe->lpLogFontParam ||
-        pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
-        pfe->lpLogFontParam->lfCharSet == plf->lfCharSet )
-    {
-        WORD args[7];
-        DWORD result;
-
-        FONT_EnumLogFontExWTo16((const ENUMLOGFONTEXW *)plf, pfe->lpLogFont);
-        FONT_NewTextMetricExWTo16((const NEWTEXTMETRICEXW *)ptm, pfe->lpTextMetric);
-        pfe->dwFlags |= ENUM_CALLED;
-
-        args[6] = SELECTOROF(pfe->segLogFont);
-        args[5] = OFFSETOF(pfe->segLogFont);
-        args[4] = SELECTOROF(pfe->segTextMetric);
-        args[3] = OFFSETOF(pfe->segTextMetric);
-        args[2] = fType;
-        args[1] = HIWORD(pfe->lpData);
-        args[0] = LOWORD(pfe->lpData);
-        WOWCallback16Ex( (DWORD)pfe->lpEnumFunc, WCB16_PASCAL, sizeof(args), args, &result );
-        ret = LOWORD(result);
-    }
-    return ret;
-}
-
-/***********************************************************************
  *              FONT_EnumInstance
  *
  * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
@@ -731,63 +648,6 @@ static INT CALLBACK FONT_EnumInstance( const LOGFONTW *plf, const TEXTMETRICW *p
 }
 
 /***********************************************************************
- *              EnumFontFamiliesEx	(GDI.613)
- */
-INT16 WINAPI EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf,
-                                   FONTENUMPROC16 efproc, LPARAM lParam,
-                                   DWORD dwFlags)
-{
-    fontEnum16 fe16;
-    INT16	ret = 1, ret2;
-    DC* 	dc = get_dc_ptr( HDC_32(hDC) );
-    NEWTEXTMETRICEX16 tm16;
-    ENUMLOGFONTEX16 lf16;
-    LOGFONTW lfW, *plfW;
-    BOOL enum_gdi_fonts;
-
-    if (!dc) return 0;
-
-    if (plf)
-    {
-        FONT_LogFont16ToW(plf, &lfW);
-        plfW = &lfW;
-    }
-    else plfW = NULL;
-
-    fe16.hdc = HDC_32(hDC);
-    fe16.lpLogFontParam = plf;
-    fe16.lpEnumFunc = efproc;
-    fe16.lpData = lParam;
-    fe16.lpTextMetric = &tm16;
-    fe16.lpLogFont = &lf16;
-    fe16.segTextMetric = MapLS( &tm16 );
-    fe16.segLogFont = MapLS( &lf16 );
-    fe16.dwFlags = 0;
-
-    enum_gdi_fonts = GetDeviceCaps(fe16.hdc, TEXTCAPS) & TC_VA_ABLE;
-
-    if (!dc->funcs->pEnumDeviceFonts && !enum_gdi_fonts)
-    {
-        ret = 0;
-        goto done;
-    }
-
-    if (enum_gdi_fonts)
-        ret = WineEngEnumFonts( plfW, FONT_EnumInstance16, (LPARAM)&fe16 );
-    fe16.dwFlags &= ~ENUM_CALLED;
-    if (ret && dc->funcs->pEnumDeviceFonts) {
-	ret2 = dc->funcs->pEnumDeviceFonts( dc->physDev, plfW, FONT_EnumInstance16, (LPARAM)&fe16 );
-	if(fe16.dwFlags & ENUM_CALLED) /* update ret iff a font gets enumed */
-	    ret = ret2;
-    }
-done:
-    UnMapLS( fe16.segTextMetric );
-    UnMapLS( fe16.segLogFont );
-    release_dc_ptr( dc );
-    return ret;
-}
-
-/***********************************************************************
  *		FONT_EnumFontFamiliesEx
  */
 static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf,
diff --git a/dlls/gdi32/gdi16.c b/dlls/gdi32/gdi16.c
index 813c57e..a638581 100644
--- a/dlls/gdi32/gdi16.c
+++ b/dlls/gdi32/gdi16.c
@@ -139,6 +139,90 @@ static void logfont_W_to_16( const LOGFONTW* font32, LPLOGFONT16 font16 )
     font16->lfFaceName[LF_FACESIZE-1] = 0;
 }
 
+/* convert a ENUMLOGFONTEXW to a ENUMLOGFONTEX16 */
+static void enumlogfontex_W_to_16( const ENUMLOGFONTEXW *fontW,
+                                   LPENUMLOGFONTEX16 font16 )
+{
+    logfont_W_to_16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
+
+    WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
+                         (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
+    font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
+    WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
+                         (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
+    font16->elfStyle[LF_FACESIZE-1] = '\0';
+    WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
+                         (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
+    font16->elfScript[LF_FACESIZE-1] = '\0';
+}
+
+/* convert a NEWTEXTMETRICEXW to a NEWTEXTMETRICEX16 */
+static void newtextmetricex_W_to_16( const NEWTEXTMETRICEXW *ptmW,
+                                     LPNEWTEXTMETRICEX16 ptm16 )
+{
+    ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
+    ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
+    ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
+    ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
+    ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
+    ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
+    ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
+    ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
+    ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
+    ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
+    ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
+    ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
+    ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
+    ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
+    ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
+    ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
+    ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
+    ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
+    ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
+    ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
+    ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
+    ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
+    ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
+    ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
+    memcpy(&ptm16->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
+}
+
+/*
+ * callback for EnumFontFamiliesEx16
+ * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
+ *       We have to use other types because of the FONTENUMPROCW definition.
+ */
+static INT CALLBACK enum_font_callback( const LOGFONTW *plf,
+                                        const TEXTMETRICW *ptm, DWORD fType,
+                                        LPARAM param )
+{
+    const struct callback16_info *info = (struct callback16_info *)param;
+    ENUMLOGFONTEX16 elfe16;
+    NEWTEXTMETRICEX16 ntm16;
+    SEGPTR segelfe16;
+    SEGPTR segntm16;
+    WORD args[7];
+    DWORD ret;
+
+    enumlogfontex_W_to_16((const ENUMLOGFONTEXW *)plf, &elfe16);
+    newtextmetricex_W_to_16((const NEWTEXTMETRICEXW *)ptm, &ntm16);
+    segelfe16 = MapLS( &elfe16 );
+    segntm16 = MapLS( &ntm16 );
+    args[6] = SELECTOROF(segelfe16);
+    args[5] = OFFSETOF(segelfe16);
+    args[4] = SELECTOROF(segntm16);
+    args[3] = OFFSETOF(segntm16);
+    args[2] = fType;
+    args[1] = HIWORD(info->param);
+    args[0] = LOWORD(info->param);
+
+    WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
+    UnMapLS( segelfe16 );
+    UnMapLS( segntm16 );
+    return LOWORD(ret);
+}
+
+
 /***********************************************************************
  *           SetBkColor    (GDI.1)
  */
@@ -3138,6 +3222,31 @@ UINT16 WINAPI GetTextCharset16( HDC16 hdc )
 }
 
 
+/***********************************************************************
+ *           EnumFontFamiliesEx (GDI.613)
+ */
+INT16 WINAPI EnumFontFamiliesEx16( HDC16 hdc, LPLOGFONT16 plf,
+                                   FONTENUMPROC16 proc, LPARAM lParam,
+                                   DWORD dwFlags)
+{
+    struct callback16_info info;
+    LOGFONTW lfW, *plfW;
+
+    info.proc  = (FARPROC16)proc;
+    info.param = lParam;
+
+    if (plf)
+    {
+        logfont_16_to_W(plf, &lfW);
+        plfW = &lfW;
+    }
+    else plfW = NULL;
+
+    return EnumFontFamiliesExW( HDC_32(hdc), plfW, enum_font_callback,
+                                (LPARAM)&info, dwFlags );
+}
+
+
 /*************************************************************************
  *             GetFontLanguageInfo   (GDI.616)
  */
-- 
1.5.4.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20080220/457286cf/attachment.pgp 


More information about the wine-patches mailing list