[PATCH 3/5] gdi32: Extract freetype code to winefreetype DLL.

Rémi Bernon rbernon at codeweavers.com
Mon Jul 6 14:37:23 CDT 2020


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---

This could also be done by using a PE freetype dependency, but in
addition to the build time requirements, it may not be what we actually
want.

For instance, native freetype using native fontconfig benefit from the
system fonts configuration, whereas Win32 freetype and fontconfig will
be more isolated from the system.

I couldn't build the macOS part of the code, so I'm not sure if it works
but it's probably just a matter of adding a few more things to the gdi32
internal interface.

 configure.ac                            |   1 +
 dlls/gdi32/Makefile.in                  |   8 +-
 dlls/gdi32/driver.c                     |  20 ++++
 dlls/gdi32/gdi32.spec                   |  12 ++-
 dlls/gdi32/gdi_private.h                | 115 ++------------------
 dlls/gdi32/resource.h                   |   1 +
 dlls/winefreetype/Makefile.in           |  12 +++
 dlls/{gdi32 => winefreetype}/freetype.c |  82 +++++++-------
 dlls/{gdi32 => winefreetype}/vertical.c |   0
 dlls/winefreetype/winefreetype.spec     |   8 ++
 include/wine/gdi_font.h                 | 135 ++++++++++++++++++++++++
 11 files changed, 239 insertions(+), 155 deletions(-)
 create mode 100644 dlls/winefreetype/Makefile.in
 rename dlls/{gdi32 => winefreetype}/freetype.c (99%)
 rename dlls/{gdi32 => winefreetype}/vertical.c (100%)
 create mode 100644 dlls/winefreetype/winefreetype.spec
 create mode 100644 include/wine/gdi_font.h

diff --git a/configure.ac b/configure.ac
index d5964223204..d53b770aa51 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3822,6 +3822,7 @@ WINE_CONFIG_MAKEFILE(dlls/winecoreaudio.drv)
 WINE_CONFIG_MAKEFILE(dlls/winecrt0)
 WINE_CONFIG_MAKEFILE(dlls/wined3d)
 WINE_CONFIG_MAKEFILE(dlls/winegstreamer)
+WINE_CONFIG_MAKEFILE(dlls/winefreetype)
 WINE_CONFIG_MAKEFILE(dlls/winehid.sys)
 WINE_CONFIG_MAKEFILE(dlls/winejoystick.drv)
 WINE_CONFIG_MAKEFILE(dlls/winemac.drv)
diff --git a/dlls/gdi32/Makefile.in b/dlls/gdi32/Makefile.in
index 32b2e6959c1..54506255657 100644
--- a/dlls/gdi32/Makefile.in
+++ b/dlls/gdi32/Makefile.in
@@ -1,9 +1,7 @@
 EXTRADEFS = -D_GDI32_
 MODULE    = gdi32.dll
 IMPORTLIB = gdi32
-IMPORTS   = advapi32
-EXTRAINCL = $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS)
-EXTRALIBS = $(CARBON_LIBS) $(APPKIT_LIBS)
+IMPORTS   = advapi32 winefreetype
 DELAYIMPORTS = usp10 setupapi
 
 C_SRCS = \
@@ -29,7 +27,6 @@ C_SRCS = \
 	enhmfdrv/init.c \
 	enhmfdrv/objects.c \
 	font.c \
-	freetype.c \
 	gdiobj.c \
 	icm.c \
 	mapping.c \
@@ -47,9 +44,6 @@ C_SRCS = \
 	pen.c \
 	printdrv.c \
 	region.c \
-	vertical.c \
 	vulkan.c
 
 RC_SRCS = gdi32.rc
-
-freetype_EXTRADEFS = -DWINE_FONT_DIR=\"`$(MAKEDEP) -R ${datadir}/wine ${fontdir}`\"
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index 39812b5ca0a..4b53b23e790 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -1586,3 +1586,23 @@ NTSTATUS WINAPI D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLU
 
     return get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership( desc );
 }
+
+WINAPI void __wine_gdi_check_not_lock(void)
+{
+    GDI_CheckNotLock();
+}
+
+WINAPI DC *__wine_gdi_get_physdev_dc( PHYSDEV dev )
+{
+    return get_physdev_dc( dev );
+}
+
+WINAPI DWORD __wine_gdi_get_dpi(void)
+{
+    return get_dpi();
+}
+
+WINAPI void __wine_gdi_set_font_driver(const struct gdi_dc_funcs *ptr)
+{
+    font_driver = ptr;
+}
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 725afebb8eb..610a9a714c0 100644
--- a/dlls/gdi32/gdi32.spec
+++ b/dlls/gdi32/gdi32.spec
@@ -289,8 +289,8 @@
 @ stdcall GetEnhMetaFileW(wstr)
 # @ stub GetFontAssocStatus
 @ stdcall GetFontData(long long long ptr long)
-@ stdcall GetFontFileData(long long int64 ptr long)
-@ stdcall GetFontFileInfo(long long ptr long ptr)
+@ stdcall GetFontFileData(long long int64 ptr long) winefreetype.GetFontFileData
+@ stdcall GetFontFileInfo(long long ptr long ptr) winefreetype.GetFontFileInfo
 @ stdcall GetFontLanguageInfo(long)
 @ stdcall GetFontRealizationInfo(long ptr)
 @ stub GetFontResourceInfo
@@ -332,7 +332,7 @@
 @ stdcall GetPolyFillMode(long)
 @ stdcall GetROP2(long)
 @ stdcall GetRandomRgn(long long long)
-@ stdcall GetRasterizerCaps(ptr long)
+@ stdcall GetRasterizerCaps(ptr long) winefreetype.GetRasterizerCaps
 @ stdcall GetRegionData(long long ptr)
 @ stdcall GetRelAbs(long long)
 @ stdcall GetRgnBox(long ptr)
@@ -536,3 +536,9 @@
 
 # Vulkan
 @ cdecl __wine_get_vulkan_driver(long long)
+
+# freetype.drv
+@ stdcall __wine_gdi_check_not_lock()
+@ stdcall __wine_gdi_get_physdev_dc(ptr)
+@ stdcall __wine_gdi_get_dpi()
+@ stdcall __wine_gdi_set_font_driver(ptr)
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 4bb46619666..8601423eaf1 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -29,6 +29,7 @@
 #include "winbase.h"
 #include "wingdi.h"
 #include "wine/gdi_driver.h"
+#include "wine/gdi_font.h"
 
 /* Metafile defines */
 #define META_EOF 0x0000
@@ -48,6 +49,8 @@ typedef struct {
 /* extra stock object: default 1x1 bitmap for memory DCs */
 #define DEFAULT_BITMAP (STOCK_LAST+1)
 
+struct font_fileinfo;
+
 struct gdi_obj_funcs
 {
     HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
@@ -57,92 +60,10 @@ struct gdi_obj_funcs
     BOOL    (*pDeleteObject)( HGDIOBJ handle );
 };
 
-typedef struct tagDC
-{
-    HDC          hSelf;            /* Handle to this DC */
-    struct gdi_physdev nulldrv;    /* physdev for the null driver */
-    PHYSDEV      physDev;          /* current top of the physdev stack */
-    DWORD        thread;           /* thread owning the DC */
-    LONG         refcount;         /* thread refcount */
-    LONG         dirty;            /* dirty flag */
-    LONG         disabled;         /* get_dc_ptr() will return NULL.  Controlled by DCHF_(DISABLE|ENABLE)DC */
-    INT          saveLevel;
-    struct tagDC *saved_dc;
-    DWORD_PTR    dwHookData;
-    DCHOOKPROC   hookProc;         /* DC hook */
-    BOOL         bounds_enabled:1; /* bounds tracking is enabled */
-    BOOL         path_open:1;      /* path is currently open (only for saved DCs) */
-
-    POINT        wnd_org;          /* Window origin */
-    SIZE         wnd_ext;          /* Window extent */
-    POINT        vport_org;        /* Viewport origin */
-    SIZE         vport_ext;        /* Viewport extent */
-    SIZE         virtual_res;      /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
-    SIZE         virtual_size;     /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
-    RECT         vis_rect;         /* visible rectangle in screen coords */
-    RECT         device_rect;      /* rectangle for the whole device */
-    int          pixel_format;     /* pixel format (for memory DCs) */
-    UINT         aa_flags;         /* anti-aliasing flags to pass to GetGlyphOutline for current font */
-    FLOAT        miterLimit;
-
-    int           flags;
-    DWORD         layout;
-    HRGN          hClipRgn;      /* Clip region */
-    HRGN          hMetaRgn;      /* Meta region */
-    HRGN          hVisRgn;       /* Visible region */
-    HRGN          region;        /* Total DC region (intersection of clip and visible) */
-    HPEN          hPen;
-    HBRUSH        hBrush;
-    HFONT         hFont;
-    HBITMAP       hBitmap;
-    HPALETTE      hPalette;
-
-    struct gdi_path *path;
-
-    struct font_gamma_ramp *font_gamma_ramp;
-
-    UINT          font_code_page;
-    WORD          ROPmode;
-    WORD          polyFillMode;
-    WORD          stretchBltMode;
-    WORD          relAbsMode;
-    WORD          backgroundMode;
-    COLORREF      backgroundColor;
-    COLORREF      textColor;
-    COLORREF      dcBrushColor;
-    COLORREF      dcPenColor;
-    POINT         brush_org;
-
-    DWORD         mapperFlags;       /* Font mapper flags */
-    WORD          textAlign;         /* Text alignment from SetTextAlign() */
-    INT           charExtra;         /* Spacing from SetTextCharacterExtra() */
-    INT           breakExtra;        /* breakTotalExtra / breakCount */
-    INT           breakRem;          /* breakTotalExtra % breakCount */
-    INT           MapMode;
-    INT           GraphicsMode;      /* Graphics mode */
-    ABORTPROC     pAbortProc;        /* AbortProc for Printing */
-    POINT         cur_pos;           /* Current position */
-    INT           ArcDirection;
-    XFORM         xformWorld2Wnd;    /* World-to-window transformation */
-    XFORM         xformWorld2Vport;  /* World-to-viewport transformation */
-    XFORM         xformVport2World;  /* Inverse of the above transformation */
-    BOOL          vport2WorldValid;  /* Is xformVport2World valid? */
-    RECT          bounds;            /* Current bounding rect */
-} DC;
-
 /* Certain functions will do no further processing if the driver returns this.
    Used by mfdrv for example. */
 #define GDI_NO_MORE_WORK 2
 
-/* Rounds a floating point number to integer. The world-to-viewport
- * transformation process is done in floating point internally. This function
- * is then used to round these coordinates to integer values.
- */
-static inline INT GDI_ROUND(double val)
-{
-   return (int)floor(val + 0.5);
-}
-
 #define GET_DC_PHYSDEV(dc,func) \
     get_physdev_entry_point( (dc)->physDev, FIELD_OFFSET(struct gdi_dc_funcs,func))
 
@@ -282,31 +203,11 @@ struct font_gamma_ramp
 
 /* freetype.c */
 
-/* Undocumented structure filled in by GetFontRealizationInfo */
-struct font_realization_info
-{
-    DWORD size;        /* could be 16 or 24 */
-    DWORD flags;       /* 1 for bitmap fonts, 3 for scalable fonts */
-    DWORD cache_num;   /* keeps incrementing - num of fonts that have been created allowing for caching?? */
-    DWORD instance_id; /* identifies a realized font instance */
-    DWORD unk;         /* unknown */
-    WORD  face_index;  /* face index in case of font collections */
-    WORD  simulations; /* 0 bit - bold simulation, 1 bit - oblique simulation */
-};
-
-/* Undocumented structure filled in by GetCharWidthInfo */
-struct char_width_info
-{
-    INT lsb;   /* minimum left side bearing */
-    INT rsb;   /* minimum right side bearing */
-    INT unk;   /* unknown */
-};
-
-extern INT WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
-extern HANDLE WineEngAddFontMemResourceEx(PVOID, DWORD, PVOID, LPDWORD) DECLSPEC_HIDDEN;
-extern BOOL WineEngCreateScalableFontResource(DWORD, LPCWSTR, LPCWSTR, LPCWSTR) DECLSPEC_HIDDEN;
-extern BOOL WineEngInit(void) DECLSPEC_HIDDEN;
-extern BOOL WineEngRemoveFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
+extern BOOL WINAPI WineEngInit(void) DECLSPEC_HIDDEN;
+extern INT WINAPI WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
+extern HANDLE WINAPI WineEngAddFontMemResourceEx(PVOID, DWORD, PVOID, LPDWORD) DECLSPEC_HIDDEN;
+extern BOOL WINAPI WineEngCreateScalableFontResource(DWORD, LPCWSTR, LPCWSTR, LPCWSTR) DECLSPEC_HIDDEN;
+extern BOOL WINAPI WineEngRemoveFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
 
 /* gdiobj.c */
 extern HGDIOBJ alloc_gdi_handle( void *obj, WORD type, const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/resource.h b/dlls/gdi32/resource.h
index b9a0eb66735..2fd878a2568 100644
--- a/dlls/gdi32/resource.h
+++ b/dlls/gdi32/resource.h
@@ -19,6 +19,7 @@
 #include <windef.h>
 
 /* these are in the order of the fsCsb[0] bits */
+/* a few are also duplicated in freetype.c */
 #define IDS_FIRST_SCRIPT     16
 #define IDS_WESTERN          (IDS_FIRST_SCRIPT + 0)
 #define IDS_CENTRAL_EUROPEAN (IDS_FIRST_SCRIPT + 1)
diff --git a/dlls/winefreetype/Makefile.in b/dlls/winefreetype/Makefile.in
new file mode 100644
index 00000000000..4b8a24ffb5d
--- /dev/null
+++ b/dlls/winefreetype/Makefile.in
@@ -0,0 +1,12 @@
+MODULE    = winefreetype.dll
+IMPORTLIB = winefreetype
+IMPORTS   = gdi32 advapi32
+EXTRADEFS = -D_GDI32_
+EXTRAINCL = $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS)
+EXTRALIBS = $(CARBON_LIBS) $(APPKIT_LIBS)
+
+C_SRCS = \
+	freetype.c \
+	vertical.c
+
+freetype_EXTRADEFS = -DWINE_FONT_DIR=\"`$(MAKEDEP) -R ${datadir}/wine ${fontdir}`\"
diff --git a/dlls/gdi32/freetype.c b/dlls/winefreetype/freetype.c
similarity index 99%
rename from dlls/gdi32/freetype.c
rename to dlls/winefreetype/freetype.c
index f82a8c1641f..b4956219c35 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/winefreetype/freetype.c
@@ -99,12 +99,15 @@
 #include "winerror.h"
 #include "winreg.h"
 #include "wingdi.h"
-#include "gdi_private.h"
+#include "wine/gdi_font.h"
 #include "wine/unicode.h"
 #include "wine/debug.h"
 #include "wine/list.h"
 
-#include "resource.h"
+/* from gdi32 resource.h */
+#define IDS_FIRST_SCRIPT     16
+#define IDS_OEM_DOS          (IDS_FIRST_SCRIPT + 32)
+#define IDS_OTHER            (IDS_FIRST_SCRIPT + 33)
 
 WINE_DEFAULT_DEBUG_CHANNEL(font);
 
@@ -3316,12 +3319,12 @@ static void delete_external_font_keys(void)
  *    WineEngAddFontResourceEx
  *
  */
-INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
+INT WINAPI WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
 {
     WCHAR path[MAX_PATH];
     INT ret = 0;
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
 
     if (ft_handle)  /* do it only if we have freetype up and running */
     {
@@ -3353,9 +3356,9 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
  *    WineEngAddFontMemResourceEx
  *
  */
-HANDLE WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
+HANDLE WINAPI WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
 {
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
 
     if (ft_handle)  /* do it only if we have freetype up and running */
     {
@@ -3389,12 +3392,12 @@ HANDLE WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD
  *    WineEngRemoveFontResourceEx
  *
  */
-BOOL WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
+BOOL WINAPI WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
 {
     WCHAR path[MAX_PATH];
     INT ret = 0;
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
 
     if (ft_handle)  /* do it only if we have freetype up and running */
     {
@@ -3704,8 +3707,8 @@ static BOOL create_fot( const WCHAR *resource, const WCHAR *font_file, const str
  *    WineEngCreateScalableFontResource
  *
  */
-BOOL WineEngCreateScalableFontResource( DWORD hidden, LPCWSTR resource,
-                                        LPCWSTR font_file, LPCWSTR font_path )
+BOOL WINAPI WineEngCreateScalableFontResource( DWORD hidden, LPCWSTR resource,
+                                               LPCWSTR font_file, LPCWSTR font_path )
 {
     char *unix_name = get_ttf_file_name( font_file, font_path );
     struct fontdir fontdir;
@@ -4048,7 +4051,7 @@ static void update_font_info(void)
     DWORD screen_dpi, font_dpi = 0;
     BOOL done = FALSE;
 
-    screen_dpi = get_dpi();
+    screen_dpi = __wine_gdi_get_dpi();
     if (!screen_dpi) screen_dpi = 96;
 
     if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL) != ERROR_SUCCESS)
@@ -4225,7 +4228,7 @@ static BOOL init_freetype(void)
         pFT_Property_Set( library, "truetype", "interpreter-version", &interpreter_version );
     }
 
-    font_driver = &freetype_funcs;
+    __wine_gdi_set_font_driver(&freetype_funcs);
     return TRUE;
 
 sym_not_found:
@@ -4401,7 +4404,7 @@ static void reorder_font_list(void)
  *
  * Initialize FreeType library and create a list of available faces
  */
-BOOL WineEngInit(void)
+BOOL WINAPI WineEngInit(void)
 {
     HKEY hkey;
     DWORD disposition;
@@ -5548,7 +5551,7 @@ static HFONT CDECL freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags
     CHARSETINFO csi;
     FMAT2 dcmat;
     FontSubst *psub = NULL;
-    DC *dc = get_physdev_dc( dev );
+    DC *dc = __wine_gdi_get_physdev_dc( dev );
     const SYSTEM_LINKS *font_link;
 
     if (!hfont)  /* notification that the font has been changed by another driver */
@@ -5598,7 +5601,7 @@ static HFONT CDECL freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags
     TRACE("DC transform %f %f %f %f\n", dcmat.eM11, dcmat.eM12,
                                         dcmat.eM21, dcmat.eM22);
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     /* check the cache first */
@@ -6018,13 +6021,15 @@ static INT load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] )
     HRSRC rsrc;
     HGLOBAL hMem;
     WCHAR *p;
-    int i;
+    int i = 0;
+    HMODULE gdi32_module = GetModuleHandleA("gdi32.dll");
 
+    if (!gdi32_module) goto done;
     id += IDS_FIRST_SCRIPT;
     rsrc = FindResourceW( gdi32_module, (LPCWSTR)(ULONG_PTR)((id >> 4) + 1), (LPCWSTR)6 /*RT_STRING*/ );
-    if (!rsrc) return 0;
+    if (!rsrc) goto done;
     hMem = LoadResource( gdi32_module, rsrc );
-    if (!hMem) return 0;
+    if (!hMem) goto done;
 
     p = LockResource( hMem );
     id &= 0x000f;
@@ -6033,6 +6038,9 @@ static INT load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] )
     i = min(LF_FACESIZE - 1, *p);
     memcpy(buffer, p + 1, i * sizeof(WCHAR));
     buffer[i] = 0;
+
+done:
+    if (gdi32_module) CloseHandle(gdi32_module);
     return i;
 }
 
@@ -6313,7 +6321,7 @@ static BOOL CDECL freetype_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW
 
     create_enum_charset_list(plf->lfCharSet, &enum_charsets);
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
     if(plf->lfFaceName[0]) {
         WCHAR *face_name = plf->lfFaceName;
@@ -6630,7 +6638,7 @@ static DWORD CDECL freetype_GetGlyphIndices( PHYSDEV dev, LPCWSTR lpstr, INT cou
         got_default = TRUE;
     }
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     for(i = 0; i < count; i++)
@@ -8279,7 +8287,7 @@ static DWORD CDECL freetype_GetGlyphOutline( PHYSDEV dev, UINT glyph, UINT forma
         return dev->funcs->pGetGlyphOutline( dev, glyph, format, lpgm, buflen, buf, lpmat );
     }
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
     ret = get_glyph_outline( physdev->font, glyph, format, lpgm, &abc, buflen, buf, lpmat );
     LeaveCriticalSection( &freetype_cs );
@@ -8300,7 +8308,7 @@ static BOOL CDECL freetype_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
         return dev->funcs->pGetTextMetrics( dev, metrics );
     }
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
     ret = get_text_metrics( physdev->font, metrics );
     LeaveCriticalSection( &freetype_cs );
@@ -8325,7 +8333,7 @@ static UINT CDECL freetype_GetOutlineTextMetrics( PHYSDEV dev, UINT cbSize, OUTL
 
     if (!FT_IS_SCALABLE( physdev->font->ft_face )) return 0;
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     if (physdev->font->potm || get_outline_text_metrics( physdev->font ))
@@ -8450,7 +8458,7 @@ static BOOL CDECL freetype_GetCharWidth( PHYSDEV dev, UINT firstChar, UINT lastC
 
     TRACE("%p, %d, %d, %p\n", physdev->font, firstChar, lastChar, buffer);
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
     for(c = firstChar; c <= lastChar; c++) {
         if (get_glyph_outline( physdev->font, c, GGO_METRICS, &gm, &abc, 0, NULL, &identity ) == GDI_ERROR)
@@ -8514,7 +8522,7 @@ static BOOL CDECL freetype_GetCharABCWidths( PHYSDEV dev, UINT firstChar, UINT l
 
     TRACE("%p, %d, %d, %p\n", physdev->font, firstChar, lastChar, buffer);
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     for(c = firstChar; c <= lastChar; c++, buffer++)
@@ -8543,7 +8551,7 @@ static BOOL CDECL freetype_GetCharABCWidthsI( PHYSDEV dev, UINT firstChar, UINT
     if(!FT_HAS_HORIZONTAL(physdev->font->ft_face))
         return FALSE;
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     for(c = 0; c < count; c++, buffer++)
@@ -8573,7 +8581,7 @@ static BOOL CDECL freetype_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR wstr, INT
 
     TRACE("%p, %s, %d\n", physdev->font, debugstr_wn(wstr, count), count);
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     for (idx = pos = 0; idx < count; idx++)
@@ -8606,7 +8614,7 @@ static BOOL CDECL freetype_GetTextExtentExPointI( PHYSDEV dev, const WORD *indic
 
     TRACE("%p, %p, %d\n", physdev->font, indices, count);
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
 
     for (idx = pos = 0; idx < count; idx++)
@@ -8782,7 +8790,7 @@ static BOOL CDECL freetype_FontIsLinked( PHYSDEV dev )
         return dev->funcs->pFontIsLinked( dev );
     }
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
     ret = !list_empty(&physdev->font->child_fonts);
     LeaveCriticalSection( &freetype_cs );
@@ -9011,7 +9019,7 @@ static DWORD CDECL freetype_GetKerningPairs( PHYSDEV dev, DWORD cPairs, KERNINGP
         return dev->funcs->pGetKerningPairs( dev, cPairs, kern_pair );
     }
 
-    GDI_CheckNotLock();
+    __wine_gdi_check_not_lock();
     EnterCriticalSection( &freetype_cs );
     if (font->total_kern_pairs != (DWORD)-1)
     {
@@ -9290,35 +9298,33 @@ static const struct gdi_dc_funcs freetype_funcs =
 
 #else /* HAVE_FREETYPE */
 
-struct font_fileinfo;
-
 /*************************************************************************/
 
-BOOL WineEngInit(void)
+BOOL WINAPI WineEngInit(void)
 {
     return FALSE;
 }
 
-INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
+INT WINAPI WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
 {
     FIXME("(%s, %x, %p): stub\n", debugstr_w(file), flags, pdv);
     return 1;
 }
 
-INT WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
+INT WINAPI WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
 {
     FIXME("(%s, %x, %p): stub\n", debugstr_w(file), flags, pdv);
     return TRUE;
 }
 
-HANDLE WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
+HANDLE WINAPI WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
 {
     FIXME("(%p, %u, %p, %p): stub\n", pbFont, cbFont, pdv, pcFonts);
     return NULL;
 }
 
-BOOL WineEngCreateScalableFontResource( DWORD hidden, LPCWSTR resource,
-                                        LPCWSTR font_file, LPCWSTR font_path )
+BOOL WINAPI WineEngCreateScalableFontResource( DWORD hidden, LPCWSTR resource,
+                                               LPCWSTR font_file, LPCWSTR font_path )
 {
     FIXME("stub\n");
     return FALSE;
diff --git a/dlls/gdi32/vertical.c b/dlls/winefreetype/vertical.c
similarity index 100%
rename from dlls/gdi32/vertical.c
rename to dlls/winefreetype/vertical.c
diff --git a/dlls/winefreetype/winefreetype.spec b/dlls/winefreetype/winefreetype.spec
new file mode 100644
index 00000000000..970365b965d
--- /dev/null
+++ b/dlls/winefreetype/winefreetype.spec
@@ -0,0 +1,8 @@
+@ stdcall WineEngInit()
+@ stdcall WineEngAddFontResourceEx(ptr long ptr)
+@ stdcall WineEngRemoveFontResourceEx(ptr long ptr)
+@ stdcall WineEngAddFontMemResourceEx(ptr long ptr ptr)
+@ stdcall WineEngCreateScalableFontResource(long ptr ptr ptr)
+@ stdcall GetRasterizerCaps(ptr long)
+@ stdcall GetFontFileData(long long int64 ptr long)
+@ stdcall GetFontFileInfo(long long ptr long ptr)
diff --git a/include/wine/gdi_font.h b/include/wine/gdi_font.h
new file mode 100644
index 00000000000..035241094f2
--- /dev/null
+++ b/include/wine/gdi_font.h
@@ -0,0 +1,135 @@
+/*
+ * Definitions for Wine GDI freetype interface
+ *
+ * Copyright 2020 Rémi Bernon for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_WINE_GDI_FONT_H
+#define __WINE_WINE_GDI_FONT_H
+
+#include <math.h>
+
+#include "wine/gdi_driver.h"
+
+typedef struct tagDC
+{
+    HDC          hSelf;            /* Handle to this DC */
+    struct gdi_physdev nulldrv;    /* physdev for the null driver */
+    PHYSDEV      physDev;          /* current top of the physdev stack */
+    DWORD        thread;           /* thread owning the DC */
+    LONG         refcount;         /* thread refcount */
+    LONG         dirty;            /* dirty flag */
+    LONG         disabled;         /* get_dc_ptr() will return NULL.  Controlled by DCHF_(DISABLE|ENABLE)DC */
+    INT          saveLevel;
+    struct tagDC *saved_dc;
+    DWORD_PTR    dwHookData;
+    DCHOOKPROC   hookProc;         /* DC hook */
+    BOOL         bounds_enabled:1; /* bounds tracking is enabled */
+    BOOL         path_open:1;      /* path is currently open (only for saved DCs) */
+
+    POINT        wnd_org;          /* Window origin */
+    SIZE         wnd_ext;          /* Window extent */
+    POINT        vport_org;        /* Viewport origin */
+    SIZE         vport_ext;        /* Viewport extent */
+    SIZE         virtual_res;      /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
+    SIZE         virtual_size;     /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
+    RECT         vis_rect;         /* visible rectangle in screen coords */
+    RECT         device_rect;      /* rectangle for the whole device */
+    int          pixel_format;     /* pixel format (for memory DCs) */
+    UINT         aa_flags;         /* anti-aliasing flags to pass to GetGlyphOutline for current font */
+    FLOAT        miterLimit;
+
+    int           flags;
+    DWORD         layout;
+    HRGN          hClipRgn;      /* Clip region */
+    HRGN          hMetaRgn;      /* Meta region */
+    HRGN          hVisRgn;       /* Visible region */
+    HRGN          region;        /* Total DC region (intersection of clip and visible) */
+    HPEN          hPen;
+    HBRUSH        hBrush;
+    HFONT         hFont;
+    HBITMAP       hBitmap;
+    HPALETTE      hPalette;
+
+    struct gdi_path *path;
+
+    struct font_gamma_ramp *font_gamma_ramp;
+
+    UINT          font_code_page;
+    WORD          ROPmode;
+    WORD          polyFillMode;
+    WORD          stretchBltMode;
+    WORD          relAbsMode;
+    WORD          backgroundMode;
+    COLORREF      backgroundColor;
+    COLORREF      textColor;
+    COLORREF      dcBrushColor;
+    COLORREF      dcPenColor;
+    POINT         brush_org;
+
+    DWORD         mapperFlags;       /* Font mapper flags */
+    WORD          textAlign;         /* Text alignment from SetTextAlign() */
+    INT           charExtra;         /* Spacing from SetTextCharacterExtra() */
+    INT           breakExtra;        /* breakTotalExtra / breakCount */
+    INT           breakRem;          /* breakTotalExtra % breakCount */
+    INT           MapMode;
+    INT           GraphicsMode;      /* Graphics mode */
+    ABORTPROC     pAbortProc;        /* AbortProc for Printing */
+    POINT         cur_pos;           /* Current position */
+    INT           ArcDirection;
+    XFORM         xformWorld2Wnd;    /* World-to-window transformation */
+    XFORM         xformWorld2Vport;  /* World-to-viewport transformation */
+    XFORM         xformVport2World;  /* Inverse of the above transformation */
+    BOOL          vport2WorldValid;  /* Is xformVport2World valid? */
+    RECT          bounds;            /* Current bounding rect */
+} DC;
+
+/* Undocumented structure filled in by GetFontRealizationInfo */
+struct font_realization_info
+{
+    DWORD size;        /* could be 16 or 24 */
+    DWORD flags;       /* 1 for bitmap fonts, 3 for scalable fonts */
+    DWORD cache_num;   /* keeps incrementing - num of fonts that have been created allowing for caching?? */
+    DWORD instance_id; /* identifies a realized font instance */
+    DWORD unk;         /* unknown */
+    WORD  face_index;  /* face index in case of font collections */
+    WORD  simulations; /* 0 bit - bold simulation, 1 bit - oblique simulation */
+};
+
+/* Undocumented structure filled in by GetCharWidthInfo */
+struct char_width_info
+{
+    INT lsb;   /* minimum left side bearing */
+    INT rsb;   /* minimum right side bearing */
+    INT unk;   /* unknown */
+};
+
+/* Rounds a floating point number to integer. The world-to-viewport
+ * transformation process is done in floating point internally. This function
+ * is then used to round these coordinates to integer values.
+ */
+static inline INT GDI_ROUND(double val)
+{
+   return (int)floor(val + 0.5);
+}
+
+extern WINAPI void __wine_gdi_check_not_lock(void) DECLSPEC_HIDDEN;
+extern WINAPI DC *__wine_gdi_get_physdev_dc( PHYSDEV dev ) DECLSPEC_HIDDEN;
+extern WINAPI DWORD __wine_gdi_get_dpi(void) DECLSPEC_HIDDEN;
+extern WINAPI void __wine_gdi_set_font_driver(const struct gdi_dc_funcs *) DECLSPEC_HIDDEN;
+
+#endif /* __WINE_WINE_GDI_FONT_H */
-- 
2.27.0




More information about the wine-devel mailing list