-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libass doesn't know how to handle OpenType Variable Fonts #386
Comments
To ease testing, since Microsofts font is hard to get: Using Inconsolata-VF.ttf, I tested the following ASS event:
First line is for comparsion with default font, second line attempts to use named weight variations and third selects the same weight variations via As you can see, the |
Huh. Thanks. It looks like it can't actually parse the weights when you write them as names, right? The second line should show Extra-Light, Light, b1, b0, and Black? But whenever you're not using \b tags, it just uses the regular font. |
An update/correction: According to @astiob's research, VSFilter can't actually select all weight variants of an embedded fonts via I've updated my previous post to reflect that EDIT (2021-07-11): |
This message explain how to generate the name for an Variation font. Overall, there is 3 main steps. 1- Family (each platform does this)If an Typographic Family Name (nameID 16) is available, take it. It seems to follow these recommandations (see Font family): https://learn.microsoft.com/en-us/typography/opentype/spec/otvaroverview#terminology Implementation with Freetype: 2- StyleFor DWrite:1- Use the ElidedFallbackNameID to create an "default instance" 2- For each Axis Value, InstanceRecord, map them to an InstanceRecord. To map them, it is different depending on the format:
Implementation:
So, I have looked into harfbuzz, but to me, it doesn't seems to exposed the all the data from the Axis Value table, so I don't know how we can use it. Also, it doesn't seems to expose the elidedFallbackNameID. In brief, I hardly see how libass can replicate DWrite because it is pretty complicated to get the Stat table. For CoreText and FontConfigEach of them seems to only use the subfamilyNameID from the InstanceRecord. Implementation:
I strongly suggest you to read the face_index input detail from FT_Open_Face 3- Merge the family and the style to create the nameNotes
It is the defaultValue for each VariationAxisRecord.
It will display the "default instance". |
Thank you @moi15moi that is insightful. @TheOneric was any progress made on trying to implement proper support for these fonts? I see a lot of issues were opened with similar issues, and one abandoned PR. |
On Sat, Jan 28, 2023 at 08:57:49 -0800, sheik124 wrote:
was any progress made on trying to implement proper support for these
fonts? I see a lot of issues were opened with similar issues, and one
abandoned PR.
No, when it eventually gets implemented, this issue will be closed and if
its only partially solved a comment updating the status will most likely
be posted here.
|
I have tried to look how GDI create face font variable font. Here is a gist where I have tried to implement, with fonttools, how GDI create a "face". See: https://gist.github.com/moi15moi/dd0fd510c03c7d80a274d69bf2edfb29 If you wanna test how GDI parse the font, you can use this script: https://gist.github.com/moi15moi/3b1f48448f0ea1798beab080cb83821b Finally, if you need to create some test, you can see the one on this PR: moi15moi/FontCollector#19 Important to note:
And this AxisValue
GDI will set the weight to 301, but it will display the 400 one. |
Testing with Segoe UI Variable installed on my system (from #730, but also bundled with modern Windows), I find that asking GDI for simply “Segoe UI Variable” (which is both the family name and the full name in the This is very concerning. FWIW querying DirectWrite with |
This is normal. It happen because none of the AxisValue use the flags ELIDABLE_AXIS_VALUE_NAME. |
https://docs.microsoft.com/en-us/typography/font-list/bahnschrift
This is the font in reference, couldn't include the TTF since Microsoft doesn't seem to allow redistribution. If you have a current install of Windows 10, you have Bahnschrift.ttf already.
Noticed this behavior in MPV and Plex, did some homework and found out they use libass.
Bahnschrift (and other variable fonts) have variable weight and width. Some also include "preset" combinations of weight/width - e.g. regular Bahnschrift is 400 wt 100 wd, but Bahnschrift Condensed is 400 wt 75 wd. If I pick "Bahnschrift Condensed" as a font, MPV and Plex can't display it properly, with MPV showing the regular version, and Plex showing a misscaled bigger version of regular Bahnschrift, even with Bahnschrift.ttf embedded. XySubFilter (or perhaps LAV Splitter?) can properly find the font and select "Condensed", whether it's only attached to the MKV or installed on the system.
Current workaround was to use FontLab 7 (trial, paid) to split Bahnschrift.ttf into independent .otf fonts based on weight. If I pick the new "Bahn-Cond" font I made and attach bond-cond.otf, libass can display it properly.
I don't know if it has anything to do with Aegisub 3.2.2's font name handling.
The text was updated successfully, but these errors were encountered: