gdi32: Take into account the fontdir directory specified at build time.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-03-17 17:23:24 +09:00
parent e8c8ddcbfc
commit 1eac54ef7d
2 changed files with 37 additions and 14 deletions

View File

@ -49,3 +49,5 @@ C_SRCS = \
vertical.c
RC_SRCS = gdi32.rc
freetype_EXTRADEFS = -DWINE_FONT_DIR=\"`$(MAKEDEP) -R ${datadir}/wine ${fontdir}`\"

View File

@ -214,6 +214,10 @@ MAKE_FUNCPTR(FcPatternGetString);
#define GET_BE_WORD(x) RtlUshortByteSwap(x)
#endif
#ifndef WINE_FONT_DIR
#define WINE_FONT_DIR "fonts"
#endif
/* This is basically a copy of FT_Bitmap_Size with an extra element added */
typedef struct {
FT_Short height;
@ -2969,22 +2973,44 @@ static void load_mac_fonts(void)
#endif
static char *get_font_dir(void)
{
const char *build_dir, *data_dir;
char *name = NULL;
if ((data_dir = wine_get_data_dir()))
{
if (!(name = HeapAlloc( GetProcessHeap(), 0, strlen(data_dir) + 1 + sizeof(WINE_FONT_DIR) )))
return NULL;
strcpy( name, data_dir );
strcat( name, "/" );
strcat( name, WINE_FONT_DIR );
}
else if ((build_dir = wine_get_build_dir()))
{
if (!(name = HeapAlloc( GetProcessHeap(), 0, strlen(build_dir) + sizeof("/fonts") )))
return NULL;
strcpy( name, build_dir );
strcat( name, "/fonts" );
}
return name;
}
static char *get_data_dir_path( LPCWSTR file )
{
char *unix_name = NULL;
const char *data_dir = wine_get_data_dir();
char *font_dir = get_font_dir();
if (!data_dir) data_dir = wine_get_build_dir();
if (data_dir)
if (font_dir)
{
INT len = WideCharToMultiByte(CP_UNIXCP, 0, file, -1, NULL, 0, NULL, NULL);
unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + len + sizeof("/fonts/"));
strcpy(unix_name, data_dir);
strcat(unix_name, "/fonts/");
unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(font_dir) + len + 1 );
strcpy(unix_name, font_dir);
strcat(unix_name, "/");
WideCharToMultiByte(CP_UNIXCP, 0, file, -1, unix_name + strlen(unix_name), len, NULL, NULL);
HeapFree( GetProcessHeap(), 0, font_dir );
}
return unix_name;
}
@ -4131,7 +4157,6 @@ static void init_font_list(void)
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
WCHAR windowsdir[MAX_PATH];
char *unixname;
const char *data_dir;
delete_external_font_keys();
@ -4147,13 +4172,9 @@ static void init_font_list(void)
HeapFree(GetProcessHeap(), 0, unixname);
}
/* load the system truetype fonts */
data_dir = wine_get_data_dir();
if (!data_dir) data_dir = wine_get_build_dir();
if (data_dir && (unixname = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + sizeof("/fonts/"))))
/* load the wine fonts */
if ((unixname = get_font_dir()))
{
strcpy(unixname, data_dir);
strcat(unixname, "/fonts/");
ReadFontDir(unixname, TRUE);
HeapFree(GetProcessHeap(), 0, unixname);
}