[PATCH 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."` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9744
From: "J. Pfeiffer" <jade@pfeiffer.codes> Use Postscript name as fallback for a unique name. --- dlls/win32u/freetype.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index aeae190bc46..f88a7f44e96 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -3328,8 +3328,13 @@ 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 ))) + font->otm.otmpFullName = (char *)get_face_name( ft_face, TT_NAME_ID_UNIQUE_ID, system_lcid ); + if (!font->otm.otmpFullName) { + /* Fallback to PostScript Name if UniqueID is not found */ + font->otm.otmpFullName = (char *)get_face_name( ft_face, TT_NAME_ID_PS_NAME, system_lcid ); + } + if (!font->otm.otmpFullName) { 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 ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9744
Which name is used on Windows for those fonts? Are those fonts available for testing somewhere? In DirectWrite we are using ids 1, 16, and 21, in different order of priority. So, why not use id 1 here? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9744#note_125316
On Wed Dec 10 18:24:34 2025 +0000, Nikolay Sivov wrote:
Which name is used on Windows for those fonts? Are those fonts available for testing somewhere? In DirectWrite we are using ids 1, 16, and 21, in different order of priority. So, why not use id 1 here? On testing, these fonts cannot be previewed or installed on Windows 10, with an error of "The file '[filename here]' does not appear to be a valid font." They're `.otf`, which is still supported according to Microsoft Support docs, while the base font MaterialIcons-Regular is `.ttf`. The unique name field isn't shown anywhere in font selection (for notepad) or file properties, otherwise it would show as "FontForge 2.0 : Material Icons : 5-3-2019" in any menus.
They are provided by the `material-icons-fonts` package in Fedora. That's reasonable, I was following that because the code was using UniqueID for `otmpFullName` that another unique signature would be necessary. Microsoft's OpenType docs[^1] do not give that much information on that name table value, only stating that is it a unique value for applications to identify the font being used, giving no other fallback information for if this field is missing. Otherwise If it should properly be a Full Name (and human readable), it could be constructed[^2] using 1 (Family) and 2 (Style) based on the examples[^3] given in Microsoft's OpenType docs. [^1]: https://learn.microsoft.com/en-us/typography/opentype/spec/name [^2]: https://learn.microsoft.com/en-us/typography/opentype/spec/recom#name [^3]: https://learn.microsoft.com/en-us/typography/opentype/spec/namesmp -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9744#note_125400
On Wed Dec 10 18:24:34 2025 +0000, Jade Pfeiffer wrote:
On testing, these fonts cannot be previewed or installed on Windows 10, with an error of "The file '[filename here]' does not appear to be a valid font." They're `.otf`, which is still supported according to Microsoft Support docs, while the base font MaterialIcons-Regular is `.ttf`. The unique name field isn't shown anywhere in font selection (for notepad) or file properties, otherwise it would show as "FontForge 2.0 : Material Icons : 5-3-2019" in any menus. They are provided by the `material-icons-fonts` package in Fedora. That's reasonable, I was following that because the code was using UniqueID for `otmpFullName` that another unique signature would be necessary. Microsoft's OpenType docs[^1] do not give that much information on that name table value, only stating that is it a unique value for applications to identify the font being used, giving no other fallback information for if this field is missing. Otherwise If it should properly be a Full Name (and human readable), it could be constructed[^2] using 1 (Family) and 2 (Style) based on the examples[^3] given in Microsoft's OpenType docs. [^1]: https://learn.microsoft.com/en-us/typography/opentype/spec/name [^2]: https://learn.microsoft.com/en-us/typography/opentype/spec/recom#name [^3]: https://learn.microsoft.com/en-us/typography/opentype/spec/namesmp Ok, I see I confused otmpFullName with otmpFamilyName. Yes, unique name is not something for end user to see in a font selection list. It's true that some fonts do not install with font installation utility on Windows, it's not about otf vs ttf, but about missing things that wellformed font should have on Windows. Sometimes it's possible to add such fonts manually to windows/fonts, then to the registry, reboot, and use them.
I don't actually know what Windows is using for otmpFullName on Windows, for the fonts that could be installed. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9744#note_125402
On Wed Dec 10 18:36:30 2025 +0000, Nikolay Sivov wrote:
Ok, I see I confused otmpFullName with otmpFamilyName. Yes, unique name is not something for end user to see in a font selection list. It's true that some fonts do not install with font installation utility on Windows, it's not about otf vs ttf, but about missing things that wellformed font should have on Windows. Sometimes it's possible to add such fonts manually to windows/fonts, then to the registry, reboot, and use them. I don't actually know what Windows is using for otmpFullName on Windows, for the fonts that could be installed. API docs for [wingdi](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-outline...) give: `The offset from the beginning of the structure to a string specifying the full name for the font. This name is unique for the font and often contains a version number or other identifying information.`
Based on that, and what I see commonly used for other fonts, the options are: using 4 (Full Name), if it exists, with 5 (Version), optionally if it exists; using 6 (PostScript), if that (likely) exists as an easy option; or constructing Full Name from 1 (Family) and 2 (Style), where "Regular" is not used for the Full Name. Any input on how to proceed? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9744#note_125404
On Wed Dec 10 20:07:21 2025 +0000, Jade Pfeiffer wrote:
API docs for [wingdi](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-outline...) give: `The offset from the beginning of the structure to a string specifying the full name for the font. This name is unique for the font and often contains a version number or other identifying information.` Based on that, and what I see commonly used for other fonts, the options are: using 4 (Full Name), if it exists, with 5 (Version), optionally if it exists; using 6 (PostScript), if that (likely) exists as an easy option; or constructing Full Name from 1 (Family) and 2 (Style), where "Regular" is not used for the Full Name. Any input on how to proceed? There are options:
* reject such fonts; * use ID1, or some other ID. I don't see PS name being used for anything right now; * ask font developers to fix it. The same package provides a ttf file that works correctly on Windows, and has this string. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9744#note_125452
participants (3)
-
J. Pfeiffer -
Jade Pfeiffer (@Cthuflu) -
Nikolay Sivov (@nsivov)