gdi32: Move the loading of registry fonts out of freetype.c.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
131d3b1f5d
commit
2c1a42bc67
|
@ -109,6 +109,11 @@ static inline INT INTERNAL_YWSTODS(DC *dc, INT height)
|
|||
return pt[1].y - pt[0].y;
|
||||
}
|
||||
|
||||
static inline BOOL is_win9x(void)
|
||||
{
|
||||
return GetVersion() & 0x80000000;
|
||||
}
|
||||
|
||||
static inline WCHAR *strdupW( const WCHAR *p )
|
||||
{
|
||||
WCHAR *ret;
|
||||
|
@ -375,7 +380,7 @@ void get_font_dir( WCHAR *path )
|
|||
else path[1] = '\\'; /* change \??\ to \\?\ */
|
||||
}
|
||||
|
||||
void get_fonts_data_dir_path( const WCHAR *file, WCHAR *path )
|
||||
static void get_fonts_data_dir_path( const WCHAR *file, WCHAR *path )
|
||||
{
|
||||
static const WCHAR slashW[] = {'\\',0};
|
||||
|
||||
|
@ -384,7 +389,7 @@ void get_fonts_data_dir_path( const WCHAR *file, WCHAR *path )
|
|||
strcatW( path, file );
|
||||
}
|
||||
|
||||
void get_fonts_win_dir_path( const WCHAR *file, WCHAR *path )
|
||||
static void get_fonts_win_dir_path( const WCHAR *file, WCHAR *path )
|
||||
{
|
||||
static const WCHAR fontsW[] = {'\\','f','o','n','t','s','\\',0};
|
||||
|
||||
|
@ -5397,6 +5402,46 @@ void load_system_bitmap_fonts(void)
|
|||
RegCloseKey( hkey );
|
||||
}
|
||||
|
||||
void load_registry_fonts(void)
|
||||
{
|
||||
static const WCHAR dot_fonW[] = {'.','f','o','n',0};
|
||||
static const WCHAR win9x_key[] = {'S','o','f','t','w','a','r','e','\\',
|
||||
'M','i','c','r','o','s','o','f','t','\\',
|
||||
'W','i','n','d','o','w','s','\\',
|
||||
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
||||
'F','o','n','t','s',0};
|
||||
static const WCHAR winnt_key[] = {'S','o','f','t','w','a','r','e','\\',
|
||||
'M','i','c','r','o','s','o','f','t','\\',
|
||||
'W','i','n','d','o','w','s',' ','N','T','\\',
|
||||
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
||||
'F','o','n','t','s',0};
|
||||
WCHAR value[MAX_PATH], data[MAX_PATH];
|
||||
DWORD i = 0, type, dlen, vlen;
|
||||
HKEY hkey;
|
||||
|
||||
/* Look under HKLM\Software\Microsoft\Windows[ NT]\CurrentVersion\Fonts
|
||||
for any fonts not installed in %WINDOWSDIR%\Fonts. They will have their
|
||||
full path as the entry. Also look for any .fon fonts, since ReadFontDir
|
||||
will skip these. */
|
||||
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, is_win9x() ? win9x_key : winnt_key, &hkey ))
|
||||
return;
|
||||
|
||||
vlen = ARRAY_SIZE(value);
|
||||
dlen = sizeof(data);
|
||||
while (!RegEnumValueW( hkey, i++, value, &vlen, NULL, &type, (LPBYTE)data, &dlen ))
|
||||
{
|
||||
dlen /= sizeof(WCHAR);
|
||||
if (data[0] && data[1] == ':')
|
||||
add_font_resource( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
|
||||
else if (dlen >= 6 && !strcmpiW( data + dlen - 5, dot_fonW ))
|
||||
add_system_font_resource( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
|
||||
|
||||
vlen = ARRAY_SIZE(value);
|
||||
dlen = sizeof(data);
|
||||
}
|
||||
RegCloseKey( hkey );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* AddFontResourceExW (GDI32.@)
|
||||
*/
|
||||
|
|
|
@ -768,10 +768,6 @@ static char **expand_mac_font(const char *path)
|
|||
|
||||
#endif /* HAVE_CARBON_CARBON_H */
|
||||
|
||||
static inline BOOL is_win9x(void)
|
||||
{
|
||||
return GetVersion() & 0x80000000;
|
||||
}
|
||||
/*
|
||||
This function builds an FT_Fixed from a double. It fails if the absolute
|
||||
value of the float number is greater than 32768.
|
||||
|
@ -3411,10 +3407,8 @@ sym_not_found:
|
|||
|
||||
static void init_font_list(void)
|
||||
{
|
||||
static const WCHAR dot_fonW[] = {'.','f','o','n','\0'};
|
||||
static const WCHAR pathW[] = {'P','a','t','h',0};
|
||||
HKEY hkey;
|
||||
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
|
||||
WCHAR path[MAX_PATH];
|
||||
char *unixname;
|
||||
|
||||
|
@ -3431,52 +3425,7 @@ static void init_font_list(void)
|
|||
get_font_dir( path );
|
||||
read_font_dir( path, TRUE );
|
||||
|
||||
/* now look under HKLM\Software\Microsoft\Windows[ NT]\CurrentVersion\Fonts
|
||||
for any fonts not installed in %WINDOWSDIR%\Fonts. They will have their
|
||||
full path as the entry. Also look for any .fon fonts, since ReadFontDir
|
||||
will skip these. */
|
||||
if(RegOpenKeyW(HKEY_LOCAL_MACHINE,
|
||||
is_win9x() ? win9x_font_reg_key : winnt_font_reg_key,
|
||||
&hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
LPWSTR data, valueW;
|
||||
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&valuelen, &datalen, NULL, NULL);
|
||||
|
||||
valuelen++; /* returned value doesn't include room for '\0' */
|
||||
valueW = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(WCHAR));
|
||||
data = HeapAlloc(GetProcessHeap(), 0, datalen * sizeof(WCHAR));
|
||||
if (valueW && data)
|
||||
{
|
||||
dlen = datalen * sizeof(WCHAR);
|
||||
vlen = valuelen;
|
||||
while(RegEnumValueW(hkey, i++, valueW, &vlen, NULL, &type, (LPBYTE)data,
|
||||
&dlen) == ERROR_SUCCESS)
|
||||
{
|
||||
if(data[0] && (data[1] == ':'))
|
||||
{
|
||||
freetype_add_font( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE);
|
||||
}
|
||||
else if(dlen / 2 >= 6 && !strcmpiW(data + dlen / 2 - 5, dot_fonW))
|
||||
{
|
||||
WCHAR pathW[MAX_PATH];
|
||||
|
||||
get_fonts_win_dir_path( data, pathW );
|
||||
if (!freetype_add_font( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE ))
|
||||
{
|
||||
get_fonts_data_dir_path( data, pathW );
|
||||
freetype_add_font( pathW, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
|
||||
}
|
||||
}
|
||||
/* reset dlen and vlen */
|
||||
dlen = datalen;
|
||||
vlen = valuelen;
|
||||
}
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
HeapFree(GetProcessHeap(), 0, valueW);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
load_registry_fonts();
|
||||
|
||||
#ifdef SONAME_LIBFONTCONFIG
|
||||
load_fontconfig_fonts();
|
||||
|
|
|
@ -390,9 +390,8 @@ struct font_backend_funcs
|
|||
};
|
||||
|
||||
extern void get_font_dir( WCHAR *path ) DECLSPEC_HIDDEN;
|
||||
extern void get_fonts_data_dir_path( const WCHAR *file, WCHAR *path ) DECLSPEC_HIDDEN;
|
||||
extern void get_fonts_win_dir_path( const WCHAR *file, WCHAR *path ) DECLSPEC_HIDDEN;
|
||||
extern void load_system_bitmap_fonts(void) DECLSPEC_HIDDEN;
|
||||
extern void load_registry_fonts(void) DECLSPEC_HIDDEN;
|
||||
|
||||
extern struct gdi_font *alloc_gdi_font( const WCHAR *file, void *data_ptr, SIZE_T data_size ) DECLSPEC_HIDDEN;
|
||||
extern void free_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue