Alexandre Julliard : gdi32: Move FreeType support to a new Unix library.
Alexandre Julliard
julliard at winehq.org
Thu Nov 5 15:37:15 CST 2020
Module: wine
Branch: master
Commit: 3cfafab38b26e0fd731c511d9ef984c1594e9ebc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3cfafab38b26e0fd731c511d9ef984c1594e9ebc
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Nov 5 10:32:04 2020 +0100
gdi32: Move FreeType support to a new Unix library.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/font.c | 14 ++++++-----
dlls/gdi32/freetype.c | 61 +++++++++++++++++++++---------------------------
dlls/gdi32/gdi_private.h | 17 +++++++-------
3 files changed, 42 insertions(+), 50 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 6a76e28d06d..e3c7d8ad06a 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -940,11 +940,11 @@ static struct gdi_font_face *create_face( struct gdi_font_family *family, const
return NULL;
}
-int add_gdi_face( const WCHAR *family_name, const WCHAR *second_name,
- const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
- void *data_ptr, SIZE_T data_size, UINT index, FONTSIGNATURE fs,
- DWORD ntmflags, DWORD version, DWORD flags,
- const struct bitmap_font_size *size )
+static int CDECL add_gdi_face( const WCHAR *family_name, const WCHAR *second_name,
+ const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
+ void *data_ptr, SIZE_T data_size, UINT index, FONTSIGNATURE fs,
+ DWORD ntmflags, DWORD version, DWORD flags,
+ const struct bitmap_font_size *size )
{
struct gdi_font_face *face;
struct gdi_font_family *family;
@@ -8040,6 +8040,8 @@ static void load_registry_fonts(void)
RegCloseKey( hkey );
}
+static const struct font_callback_funcs callback_funcs = { add_gdi_face };
+
/***********************************************************************
* font_init
*/
@@ -8055,7 +8057,7 @@ void font_init(void)
init_font_options();
update_codepage();
- if (!WineEngInit( &font_funcs )) return;
+ if (__wine_init_unix_lib( gdi32_module, DLL_PROCESS_ATTACH, &callback_funcs, &font_funcs )) return;
if (!(mutex = CreateMutexW( NULL, FALSE, mutex_nameW ))) return;
WaitForSingleObject( mutex, INFINITE );
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index f112a04b4c1..9c875c1fa2f 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -21,6 +21,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#if 0
+#pragma makedep unix
+#endif
+
#include "config.h"
#include "wine/port.h"
@@ -102,16 +106,15 @@
#include "winreg.h"
#include "wingdi.h"
#include "gdi_private.h"
-#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "resource.h"
-WINE_DEFAULT_DEBUG_CHANNEL(font);
-
#ifdef HAVE_FREETYPE
+WINE_DEFAULT_DEBUG_CHANNEL(font);
+
#ifndef HAVE_FT_TRUETYPEENGINETYPE
typedef enum
{
@@ -247,7 +250,7 @@ static inline FT_Face get_ft_face( struct gdi_font *font )
return ((struct font_private_data *)font->private)->ft_face;
}
-static const struct font_backend_funcs font_funcs;
+static const struct font_callback_funcs *callback_funcs;
struct font_mapping
{
@@ -1028,9 +1031,10 @@ static int AddFaceToList(FT_Face ft_face, const WCHAR *file, void *data_ptr, SIZ
if (!FT_IS_SCALABLE( ft_face )) get_bitmap_size( ft_face, &size );
if (!HIWORD( flags )) flags |= ADDFONT_AA_FLAGS( default_aa_flags );
- ret = add_gdi_face( family_name, second_name, style_name, full_name, file, data_ptr, data_size,
- face_index, fs, get_ntm_flags( ft_face ), get_font_version( ft_face ),
- flags, FT_IS_SCALABLE(ft_face) ? NULL : &size );
+ ret = callback_funcs->add_gdi_face( family_name, second_name, style_name, full_name, file,
+ data_ptr, data_size, face_index, fs, get_ntm_flags( ft_face ),
+ get_font_version( ft_face ), flags,
+ FT_IS_SCALABLE(ft_face) ? NULL : &size );
TRACE("fsCsb = %08x %08x/%08x %08x %08x %08x\n",
fs.fsCsb[0], fs.fsCsb[1], fs.fsUsb[0], fs.fsUsb[1], fs.fsUsb[2], fs.fsUsb[3]);
@@ -1662,24 +1666,6 @@ static void CDECL freetype_load_fonts(void)
#endif
}
-/*************************************************************
- * WineEngInit
- *
- * Initialize FreeType library and create a list of available faces
- */
-BOOL WineEngInit( const struct font_backend_funcs **funcs )
-{
- if(!init_freetype()) return FALSE;
-
-#ifdef SONAME_LIBFONTCONFIG
- init_fontconfig();
-#endif
-
- *funcs = &font_funcs;
- NtQueryDefaultLocale( FALSE, &system_lcid );
- return TRUE;
-}
-
/* Some fonts have large usWinDescent values, as a result of storing signed short
in unsigned field. That's probably caused by sTypoDescent vs usWinDescent confusion in
some font generation tools. */
@@ -3471,10 +3457,10 @@ static BOOL CDECL freetype_set_outline_text_metrics( struct gdi_font *font )
FIXME("failed to read full_nameW for font %s!\n", wine_dbgstr_w((WCHAR *)font->otm.otmpFamilyName));
font->otm.otmpFullName = (char *)strdupW(fake_nameW);
}
- needed = sizeof(font->otm) + (strlenW( (WCHAR *)font->otm.otmpFamilyName ) + 1 +
- strlenW( (WCHAR *)font->otm.otmpStyleName ) + 1 +
- strlenW( (WCHAR *)font->otm.otmpFaceName ) + 1 +
- strlenW( (WCHAR *)font->otm.otmpFullName ) + 1) * sizeof(WCHAR);
+ needed = sizeof(font->otm) + (lstrlenW( (WCHAR *)font->otm.otmpFamilyName ) + 1 +
+ lstrlenW( (WCHAR *)font->otm.otmpStyleName ) + 1 +
+ lstrlenW( (WCHAR *)font->otm.otmpFaceName ) + 1 +
+ lstrlenW( (WCHAR *)font->otm.otmpFullName ) + 1) * sizeof(WCHAR);
em_scale = (FT_Fixed)pFT_MulDiv(font->ppem, 1 << 16, ft_face->units_per_EM);
@@ -4044,13 +4030,18 @@ static const struct font_backend_funcs font_funcs =
freetype_destroy_font
};
-#else /* HAVE_FREETYPE */
-
-/*************************************************************************/
-
-BOOL WineEngInit( const struct font_backend_funcs **funcs )
+NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
{
- return FALSE;
+ if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
+
+ callback_funcs = ptr_in;
+ if (!init_freetype()) return STATUS_DLL_NOT_FOUND;
+#ifdef SONAME_LIBFONTCONFIG
+ init_fontconfig();
+#endif
+ NtQueryDefaultLocale( FALSE, &system_lcid );
+ *(const struct font_backend_funcs **)ptr_out = &font_funcs;
+ return STATUS_SUCCESS;
}
#endif /* HAVE_FREETYPE */
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index c5703689d46..9b48732b73b 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -400,18 +400,17 @@ struct font_backend_funcs
void (CDECL *destroy_font)( struct gdi_font *font );
};
-extern int add_gdi_face( const WCHAR *family_name, const WCHAR *second_name,
- const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
- void *data_ptr, SIZE_T data_size, UINT index, FONTSIGNATURE fs,
- DWORD ntmflags, DWORD version, DWORD flags,
- const struct bitmap_font_size *size ) DECLSPEC_HIDDEN;
+struct font_callback_funcs
+{
+ int (CDECL *add_gdi_face)( const WCHAR *family_name, const WCHAR *second_name,
+ const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
+ void *data_ptr, SIZE_T data_size, UINT index, FONTSIGNATURE fs,
+ DWORD ntmflags, DWORD version, DWORD flags,
+ const struct bitmap_font_size *size );
+};
extern void font_init(void) DECLSPEC_HIDDEN;
-/* freetype.c */
-
-extern BOOL WineEngInit( const struct font_backend_funcs **funcs ) DECLSPEC_HIDDEN;
-
/* gdiobj.c */
extern HGDIOBJ alloc_gdi_handle( void *obj, WORD type, const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list