And rename the field to full_name for consistency with most face fields.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi32/freetype.c | 81 ++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 36 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index ed4dc9f034e..fad7143dd58 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -270,7 +270,7 @@ typedef struct tagFace { struct list entry; unsigned int refcount; WCHAR *StyleName; - WCHAR *FullName; + WCHAR *full_name; WCHAR *file; dev_t dev; ino_t ino; @@ -1502,6 +1502,29 @@ static WCHAR *ft_face_get_style_name( FT_Face ft_face, LANGID langid ) return towstr( CP_ACP, ft_face->style_name ); }
+static WCHAR *ft_face_get_full_name( FT_Face ft_face, LANGID langid ) +{ + static const WCHAR space_w[] = {' ',0}; + WCHAR *full_name, *style_name; + SIZE_T length; + + if ((full_name = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, langid ))) + return full_name; + + full_name = ft_face_get_family_name( ft_face, langid ); + style_name = ft_face_get_style_name( ft_face, langid ); + + length = strlenW( full_name ) + strlenW( style_name ) + 1; + full_name = HeapReAlloc( GetProcessHeap(), 0, full_name, length * sizeof(WCHAR) ); + + strcatW( full_name, space_w ); + strcatW( full_name, style_name ); + HeapFree( GetProcessHeap(), 0, style_name ); + + WARN( "full name not found, using %s instead\n", debugstr_w(full_name) ); + return full_name; +} + static inline BOOL faces_equal( const Face *f1, const Face *f2 ) { if (strcmpiW( f1->StyleName, f2->StyleName )) return FALSE; @@ -1531,7 +1554,7 @@ static void release_face( Face *face ) } HeapFree( GetProcessHeap(), 0, face->file ); HeapFree( GetProcessHeap(), 0, face->StyleName ); - HeapFree( GetProcessHeap(), 0, face->FullName ); + HeapFree( GetProcessHeap(), 0, face->full_name ); HeapFree( GetProcessHeap(), 0, face->cached_enum_data ); HeapFree( GetProcessHeap(), 0, face ); } @@ -1677,10 +1700,14 @@ static void load_face(HKEY hkey_face, WCHAR *face_name, Family *family, void *bu face->StyleName = strdupW(face_name);
needed = buffer_size; - if(RegQueryValueExW(hkey_face, face_full_name_value, NULL, NULL, buffer, &needed) == ERROR_SUCCESS) - face->FullName = strdupW( buffer ); - else - face->FullName = NULL; + if (RegQueryValueExW( hkey_face, face_full_name_value, NULL, NULL, buffer, &needed ) != ERROR_SUCCESS) + { + ERR( "couldn't find full name for %s %s in cache\n", debugstr_w(family->FamilyName), + debugstr_w(face->StyleName) ); + release_face( face ); + return; + } + face->full_name = strdupW( buffer );
reg_load_ftlong(hkey_face, face_index_value, &face->face_index); reg_load_dword(hkey_face, face_ntmflags_value, &face->ntmFlags); @@ -1866,9 +1893,8 @@ static void add_face_to_cache(Face *face)
RegSetValueExW(hkey_face, face_file_name_value, 0, REG_SZ, (BYTE *)face->file, (strlenW(face->file) + 1) * sizeof(WCHAR)); - if (face->FullName) - RegSetValueExW(hkey_face, face_full_name_value, 0, REG_SZ, (BYTE*)face->FullName, - (strlenW(face->FullName) + 1) * sizeof(WCHAR)); + RegSetValueExW( hkey_face, face_full_name_value, 0, REG_SZ, (BYTE *)face->full_name, + (strlenW( face->full_name ) + 1) * sizeof(WCHAR) );
reg_save_dword(hkey_face, face_index_value, face->face_index); reg_save_dword(hkey_face, face_ntmflags_value, face->ntmFlags); @@ -2102,8 +2128,8 @@ static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file,
face->refcount = 1; 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 = get_vertical_name( face->FullName ); + face->full_name = ft_face_get_full_name( ft_face, GetSystemDefaultLangID() ); + if (flags & ADDFONT_VERTICAL_FONT) face->full_name = get_vertical_name( face->full_name );
face->dev = 0; face->ino = 0; @@ -3202,18 +3228,14 @@ static void update_reg_entries(void) LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) { LIST_FOR_EACH_ENTRY( face, &family->faces, Face, entry ) { char *buffer; - WCHAR *name; - if (!(face->flags & ADDFONT_EXTERNAL_FONT)) continue;
- name = face->FullName ? face->FullName : family->FamilyName; - - len = strlenW(name) + 1; + len = strlenW( face->full_name ) + 1; if (face->scalable) len += ARRAY_SIZE(TrueType);
valueW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - strcpyW(valueW, name); + strcpyW( valueW, face->full_name );
if (face->scalable) strcatW(valueW, TrueType); @@ -5688,8 +5710,7 @@ static HFONT CDECL freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) { face_list = get_face_list_from_family(family); LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) { - if(face->FullName && !strncmpiW(face->FullName, FaceName, LF_FACESIZE - 1) && - (face->scalable || can_use_bitmap)) + if (!strncmpiW( face->full_name, FaceName, LF_FACESIZE - 1 ) && (face->scalable || can_use_bitmap)) { if (csi.fs.fsCsb[0] & face->fs.fsCsb[0] || !csi.fs.fsCsb[0]) goto found_face; @@ -6182,10 +6203,7 @@ static void GetEnumStructs(Face *face, const WCHAR *family_name, LPENUMLOGFONTEX pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
lstrcpynW(pelf->elfLogFont.lfFaceName, family_name, LF_FACESIZE); - if (face->FullName) - lstrcpynW(pelf->elfFullName, face->FullName, LF_FULLFACESIZE); - else - lstrcpynW(pelf->elfFullName, family_name, LF_FULLFACESIZE); + lstrcpynW( pelf->elfFullName, face->full_name, LF_FULLFACESIZE ); lstrcpynW(pelf->elfStyle, face->StyleName, LF_FACESIZE); }
@@ -6236,7 +6254,7 @@ static BOOL family_matches(Family *family, const WCHAR *face_name)
face_list = get_face_list_from_family(family); LIST_FOR_EACH_ENTRY(face, face_list, Face, entry) - if (face->FullName && !strncmpiW(face_name, face->FullName, LF_FACESIZE - 1)) return TRUE; + if (!strncmpiW( face_name, face->full_name, LF_FACESIZE - 1 )) return TRUE;
return FALSE; } @@ -6244,8 +6262,7 @@ static BOOL family_matches(Family *family, const WCHAR *face_name) static BOOL face_matches(const WCHAR *family_name, Face *face, const WCHAR *face_name) { if (!strncmpiW(face_name, family_name, LF_FACESIZE - 1)) return TRUE; - - return (face->FullName && !strncmpiW(face_name, face->FullName, LF_FACESIZE - 1)); + return !strncmpiW( face_name, face->full_name, LF_FACESIZE - 1 ); }
static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list, @@ -6278,10 +6295,7 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha if (family != face->family) { lstrcpynW(elf.elfLogFont.lfFaceName, family->FamilyName, LF_FACESIZE); - if (face->FullName) - lstrcpynW(elf.elfFullName, face->FullName, LF_FULLFACESIZE); - else - lstrcpynW(elf.elfFullName, family->FamilyName, LF_FULLFACESIZE); + lstrcpynW( elf.elfFullName, face->full_name, LF_FULLFACESIZE ); } if (subst) strcpyW(elf.elfLogFont.lfFaceName, subst); @@ -7968,12 +7982,7 @@ static BOOL get_outline_text_metrics(GdiFont *font) 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() ); - if (!face_nameW) - { - FIXME("failed to read face_nameW for font %s!\n", wine_dbgstr_w(font->name)); - face_nameW = strdupW(font->name); - } + face_nameW = ft_face_get_full_name( ft_face, GetSystemDefaultLangID() ); if (font->name[0] == '@') face_nameW = get_vertical_name( face_nameW ); lenface = (strlenW(face_nameW) + 1) * sizeof(WCHAR);