gdi32: Add helper functions to compute font paths for AddFontResource.
This commit is contained in:
parent
0f40a031e7
commit
ab0ad4f5d8
|
@ -2614,27 +2614,33 @@ static void load_mac_fonts(void)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BOOL load_font_from_data_dir(LPCWSTR file)
|
static char *get_data_dir_path( LPCWSTR file )
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
char *unix_name = NULL;
|
||||||
const char *data_dir = wine_get_data_dir();
|
const char *data_dir = wine_get_data_dir();
|
||||||
|
|
||||||
if (!data_dir) data_dir = wine_get_build_dir();
|
if (!data_dir) data_dir = wine_get_build_dir();
|
||||||
|
|
||||||
if (data_dir)
|
if (data_dir)
|
||||||
{
|
{
|
||||||
INT len;
|
INT len = WideCharToMultiByte(CP_UNIXCP, 0, file, -1, NULL, 0, NULL, NULL);
|
||||||
char *unix_name;
|
|
||||||
|
|
||||||
len = WideCharToMultiByte(CP_UNIXCP, 0, file, -1, NULL, 0, NULL, NULL);
|
|
||||||
|
|
||||||
unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + len + sizeof("/fonts/"));
|
unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + len + sizeof("/fonts/"));
|
||||||
|
|
||||||
strcpy(unix_name, data_dir);
|
strcpy(unix_name, data_dir);
|
||||||
strcat(unix_name, "/fonts/");
|
strcat(unix_name, "/fonts/");
|
||||||
|
|
||||||
WideCharToMultiByte(CP_UNIXCP, 0, file, -1, unix_name + strlen(unix_name), len, NULL, NULL);
|
WideCharToMultiByte(CP_UNIXCP, 0, file, -1, unix_name + strlen(unix_name), len, NULL, NULL);
|
||||||
|
}
|
||||||
|
return unix_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL load_font_from_data_dir(LPCWSTR file)
|
||||||
|
{
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
char *unix_name = get_data_dir_path( file );
|
||||||
|
|
||||||
|
if (unix_name)
|
||||||
|
{
|
||||||
EnterCriticalSection( &freetype_cs );
|
EnterCriticalSection( &freetype_cs );
|
||||||
ret = AddFontToList(unix_name, NULL, 0, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE);
|
ret = AddFontToList(unix_name, NULL, 0, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE);
|
||||||
LeaveCriticalSection( &freetype_cs );
|
LeaveCriticalSection( &freetype_cs );
|
||||||
|
@ -2643,24 +2649,16 @@ static BOOL load_font_from_data_dir(LPCWSTR file)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL load_font_from_winfonts_dir(LPCWSTR file)
|
static char *get_winfonts_dir_path(LPCWSTR file)
|
||||||
{
|
{
|
||||||
static const WCHAR slashW[] = {'\\','\0'};
|
static const WCHAR slashW[] = {'\\','\0'};
|
||||||
BOOL ret = FALSE;
|
|
||||||
WCHAR windowsdir[MAX_PATH];
|
WCHAR windowsdir[MAX_PATH];
|
||||||
char *unixname;
|
|
||||||
|
|
||||||
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
|
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
|
||||||
strcatW(windowsdir, fontsW);
|
strcatW(windowsdir, fontsW);
|
||||||
strcatW(windowsdir, slashW);
|
strcatW(windowsdir, slashW);
|
||||||
strcatW(windowsdir, file);
|
strcatW(windowsdir, file);
|
||||||
if ((unixname = wine_get_unix_file_name(windowsdir))) {
|
return wine_get_unix_file_name( windowsdir );
|
||||||
EnterCriticalSection( &freetype_cs );
|
|
||||||
ret = AddFontToList(unixname, NULL, 0, ADDFONT_ALLOW_BITMAP);
|
|
||||||
LeaveCriticalSection( &freetype_cs );
|
|
||||||
HeapFree(GetProcessHeap(), 0, unixname);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_system_fonts(void)
|
static void load_system_fonts(void)
|
||||||
|
@ -2846,31 +2844,34 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
||||||
{
|
{
|
||||||
char *unixname;
|
char *unixname;
|
||||||
|
|
||||||
if(flags)
|
EnterCriticalSection( &freetype_cs );
|
||||||
FIXME("Ignoring flags %x\n", flags);
|
|
||||||
|
|
||||||
if((unixname = wine_get_unix_file_name(file)))
|
if((unixname = wine_get_unix_file_name(file)))
|
||||||
{
|
{
|
||||||
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
|
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
|
||||||
|
|
||||||
if(!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
|
if(!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
|
||||||
EnterCriticalSection( &freetype_cs );
|
|
||||||
ret = AddFontToList(unixname, NULL, 0, addfont_flags);
|
ret = AddFontToList(unixname, NULL, 0, addfont_flags);
|
||||||
LeaveCriticalSection( &freetype_cs );
|
|
||||||
HeapFree(GetProcessHeap(), 0, unixname);
|
HeapFree(GetProcessHeap(), 0, unixname);
|
||||||
}
|
}
|
||||||
if (!ret && !strchrW(file, '\\')) {
|
if (!ret && !strchrW(file, '\\')) {
|
||||||
/* Try in %WINDIR%/fonts, needed for Fotobuch Designer */
|
/* Try in %WINDIR%/fonts, needed for Fotobuch Designer */
|
||||||
ret = load_font_from_winfonts_dir(file);
|
if ((unixname = get_winfonts_dir_path( file )))
|
||||||
if (!ret) {
|
{
|
||||||
/* Try in datadir/fonts (or builddir/fonts),
|
ret = AddFontToList(unixname, NULL, 0, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE);
|
||||||
* needed for Magic the Gathering Online
|
HeapFree(GetProcessHeap(), 0, unixname);
|
||||||
*/
|
}
|
||||||
ret = load_font_from_data_dir(file);
|
/* Try in datadir/fonts (or builddir/fonts), needed for Magic the Gathering Online */
|
||||||
|
if (!ret && (unixname = get_data_dir_path( file )))
|
||||||
|
{
|
||||||
|
ret = AddFontToList(unixname, NULL, 0, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE);
|
||||||
|
HeapFree(GetProcessHeap(), 0, unixname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection( &freetype_cs );
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
|
|
Loading…
Reference in New Issue