Commit 412774e9 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Freetype: account for more complex font names on Windows

We have to count for "Bold", "Normal" and "Italic" ending in registry

Close #4949
parent aa736eb3
...@@ -545,7 +545,10 @@ static int GetFileFontByName( const char *font_name, char **psz_filename ) ...@@ -545,7 +545,10 @@ static int GetFileFontByName( const char *font_name, char **psz_filename )
wchar_t vbuffer[MAX_PATH]; wchar_t vbuffer[MAX_PATH];
wchar_t dbuffer[256]; wchar_t dbuffer[256];
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey) != ERROR_SUCCESS ) size_t fontname_len = strlen( font_name );
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey)
!= ERROR_SUCCESS )
return 1; return 1;
for( int index = 0;; index++ ) for( int index = 0;; index++ )
...@@ -553,9 +556,10 @@ static int GetFileFontByName( const char *font_name, char **psz_filename ) ...@@ -553,9 +556,10 @@ static int GetFileFontByName( const char *font_name, char **psz_filename )
DWORD vbuflen = MAX_PATH - 1; DWORD vbuflen = MAX_PATH - 1;
DWORD dbuflen = 255; DWORD dbuflen = 255;
if( RegEnumValueW( hKey, index, vbuffer, &vbuflen, LONG i_result = RegEnumValueW( hKey, index, vbuffer, &vbuflen,
NULL, NULL, (LPBYTE)dbuffer, &dbuflen) != ERROR_SUCCESS ) NULL, NULL, (LPBYTE)dbuffer, &dbuflen);
return 2; if( i_result != ERROR_SUCCESS )
return i_result;
char *psz_value = FromWide( vbuffer ); char *psz_value = FromWide( vbuffer );
...@@ -568,7 +572,7 @@ static int GetFileFontByName( const char *font_name, char **psz_filename ) ...@@ -568,7 +572,7 @@ static int GetFileFontByName( const char *font_name, char **psz_filename )
break; break;
} }
else { else {
if( strcasecmp( psz_value, font_name ) == 0 ) if( strncasecmp( psz_value, font_name, fontname_len ) == 0 )
break; break;
} }
} }
...@@ -593,6 +597,9 @@ static char* Win32_Select( filter_t *p_filter, const char* family, ...@@ -593,6 +597,9 @@ static char* Win32_Select( filter_t *p_filter, const char* family,
{ {
VLC_UNUSED( i_size ); VLC_UNUSED( i_size );
if( strlen( family ) < 1 )
goto fail;
/* */ /* */
LOGFONT lf; LOGFONT lf;
lf.lfCharSet = DEFAULT_CHARSET; lf.lfCharSet = DEFAULT_CHARSET;
...@@ -630,6 +637,7 @@ static char* Win32_Select( filter_t *p_filter, const char* family, ...@@ -630,6 +637,7 @@ static char* Win32_Select( filter_t *p_filter, const char* family,
} }
} }
else /* Let's take any font we can */ else /* Let's take any font we can */
fail:
{ {
char *psz_tmp; char *psz_tmp;
if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, "arial.ttf" ) == -1 ) if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, "arial.ttf" ) == -1 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment