[PATCH v2 0/1] MR9744: win32u: Use PostScript Name as fallback when Unique Name is not found in freetype name table
This patch should remedy an issue with `freetype_set_outline_text_metrics` failing to read a full name for some fonts that don't have a unique name entry in their name table. For example, some Material fonts from Google that DON'T have a unique name entry. | Font | NameID | StringName | |-------------------------|----------------|-------------------------------| | Material Icons Outlined | 0 (Copyright) | (Google Copyright Text) | | | 1 (Family) | Material Icons Outlined | | | 2 (Style) | Regular | | | 6 (PostScript) | MaterialIconsOutlined-Regular | | Material Icons Round | 0 (Copyright) | (Google Copyright Text) | | | 1 (Family) | Material Icons Round | | | 2 (Style) | Regular | | | 6 (PostScript) | MaterialIconsRound-Regular | | Material Icons Sharp | 0 (Copyright) | (Google Copyright Text) | | | 1 (Family) | Material Icons Sharp | | | 2 (Style) | Regular | | | 6 (PostScript) | MaterialIconsSharp-Regular | | Material Icons Two Tone | 0 (Copyright) | (Google Copyright Text) | | | 1 (Family) | Material Icons Two Tone | | | 2 (Style) | Regular | | | 6 (PostScript) | MaterialIconsTwoTone-Regular | This (mostly) follows [Apple's TrueType name table docs](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.h...) for what names should be included for a font (aside from missing a full name entry). While this patch is based on Apple's documentation, it should be reasonable that the PostScript name is treated as an acceptable fallback for a unique name: `"If two fonts are installed with the same PostScript name, Apple platforms treat them as duplicates and only one will be available for use."` -- v2: win32u: Full Name as fallback for Unique Name https://gitlab.winehq.org/wine/wine/-/merge_requests/9744
From: "J. Pfeiffer" <jade@pfeiffer.codes> Use Full Name as fallback for a Unique Name. Following wingdi spec. --- dlls/win32u/freetype.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index aeae190bc46..271e96a19db 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -569,6 +569,7 @@ static WCHAR *ft_face_get_style_name( FT_Face ft_face, LANGID langid ) static WCHAR *ft_face_get_full_name( FT_Face ft_face, LANGID langid ) { + static const WCHAR regular_w[] = {'R', 'e', 'g', 'u', 'l', 'a', 'r',0}; static const WCHAR space_w[] = {' ',0}; WCHAR *full_name, *style_name; SIZE_T length; @@ -579,11 +580,14 @@ static WCHAR *ft_face_get_full_name( FT_Face ft_face, LANGID langid ) full_name = ft_face_get_family_name( ft_face, langid ); style_name = ft_face_get_style_name( ft_face, langid ); - length = lstrlenW( full_name ) + lstrlenW( space_w ) + lstrlenW( style_name ) + 1; - full_name = realloc( full_name, length * sizeof(WCHAR) ); + if (wcsicmp(style_name, regular_w)) { + length = lstrlenW( full_name ) + lstrlenW( space_w ) + lstrlenW( style_name ) + 1; + full_name = realloc( full_name, length * sizeof(WCHAR) ); + + lstrcatW( full_name, space_w ); + lstrcatW( full_name, style_name ); + } - lstrcatW( full_name, space_w ); - lstrcatW( full_name, style_name ); free( style_name ); WARN( "full name not found, using %s instead\n", debugstr_w(full_name) ); @@ -3328,11 +3332,9 @@ static BOOL freetype_set_outline_text_metrics( struct gdi_font *font ) /* note: we store actual pointers in the names instead of offsets, they are fixed up when returned to the app */ - if (!(font->otm.otmpFullName = (char *)get_face_name( ft_face, TT_NAME_ID_UNIQUE_ID, system_lcid ))) - { - static const WCHAR fake_nameW[] = {'f','a','k','e',' ','n','a','m','e', 0}; - FIXME("failed to read full_nameW for font %s!\n", wine_dbgstr_w((WCHAR *)font->otm.otmpFamilyName)); - font->otm.otmpFullName = (char *)wcsdup( fake_nameW ); + font->otm.otmpFullName = (char *)get_face_name( ft_face, TT_NAME_ID_UNIQUE_ID, system_lcid ); + if (!font->otm.otmpFullName) { + font->otm.otmpFullName = (char *)ft_face_get_full_name(ft_face, system_lcid); } needed = sizeof(font->otm) + (lstrlenW( (WCHAR *)font->otm.otmpFamilyName ) + 1 + lstrlenW( (WCHAR *)font->otm.otmpStyleName ) + 1 + -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9744
participants (2)
-
J. Pfeiffer -
Jade Pfeiffer (@Cthuflu)