Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi32/freetype.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 38d59e3fd9b..2f04b76ef44 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -1482,6 +1482,26 @@ static WCHAR *get_face_name(FT_Face ft_face, FT_UShort name_id, LANGID language_ return NULL; }
+static WCHAR *ft_face_get_family_name( FT_Face ft_face, LANGID langid ) +{ + WCHAR *family_name; + + if ((family_name = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, langid ))) + return family_name; + + return towstr( CP_ACP, ft_face->family_name ); +} + +static WCHAR *ft_face_get_style_name( FT_Face ft_face, LANGID langid ) +{ + WCHAR *style_name; + + if ((style_name = get_face_name( ft_face, TT_NAME_ID_FONT_SUBFAMILY, langid ))) + return style_name; + + return towstr( CP_ACP, ft_face->style_name ); +} + static inline BOOL faces_equal( const Face *f1, const Face *f2 ) { if (strcmpiW( f1->StyleName, f2->StyleName )) return FALSE; @@ -1907,16 +1927,10 @@ static WCHAR *prepend_at(WCHAR *family)
static void get_family_names( FT_Face ft_face, WCHAR **name, WCHAR **english, BOOL vertical ) { - *english = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT) ); - if (!*english) *english = towstr( CP_ACP, ft_face->family_name ); + *english = ft_face_get_family_name( ft_face, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT) ); + *name = ft_face_get_family_name( ft_face, GetSystemDefaultLCID() );
- *name = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, GetSystemDefaultLCID() ); - if (!*name) - { - *name = *english; - *english = NULL; - } - else if (!strcmpiW( *name, *english )) + if (!strcmpiW( *name, *english )) { HeapFree( GetProcessHeap(), 0, *english ); *english = NULL; @@ -2088,9 +2102,7 @@ static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file, Face *face = HeapAlloc( GetProcessHeap(), 0, sizeof(*face) );
face->refcount = 1; - face->StyleName = get_face_name( ft_face, TT_NAME_ID_FONT_SUBFAMILY, GetSystemDefaultLangID() ); - if (!face->StyleName) face->StyleName = towstr( CP_ACP, ft_face->style_name ); - + face->StyleName = ft_face_get_style_name( ft_face, GetSystemDefaultLangID() ); face->FullName = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, GetSystemDefaultLangID() ); if (flags & ADDFONT_VERTICAL_FONT) face->FullName = prepend_at( face->FullName ); @@ -7955,12 +7967,7 @@ static BOOL get_outline_text_metrics(GdiFont *font) lenfam = (strlenW(font->name) + 1) * sizeof(WCHAR); family_nameW = strdupW(font->name);
- style_nameW = get_face_name( ft_face, TT_NAME_ID_FONT_SUBFAMILY, GetSystemDefaultLangID() ); - if (!style_nameW) - { - FIXME("failed to read style_nameW for font %s!\n", wine_dbgstr_w(font->name)); - style_nameW = towstr( CP_ACP, ft_face->style_name ); - } + style_nameW = ft_face_get_style_name( ft_face, GetSystemDefaultLangID() ); lensty = (strlenW(style_nameW) + 1) * sizeof(WCHAR);
face_nameW = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, GetSystemDefaultLangID() );