Fix read/write of bits USE_TYPO_METRICS and WWS for OS/2 version < 4#2274
Conversation
Fix read/write of bits USE_TYPO_METRICS and WWS for OS/2 version < 4
|
Thanks! Are you making a math font? |
|
No, trying to make existing fonts work with Gecko MathML... |
There was a problem hiding this comment.
I’m not sure why this change was needed, as the line above it will correctly set the version to 4 if use_typo_metrics is set.
There was a problem hiding this comment.
because the line just below overrides that :-)
There was a problem hiding this comment.
Right, that is by design. The 0 OS/2 version corresponds to “Automatic” in the GUI, where FontForge will chose which fits best the fields being set, but if the user selects a version explicitly it is always used.
There was a problem hiding this comment.
I think the correct fix here is for the font info dialog to warn the user if he is setting a field not supported by the selected version, not to override it in this low level code. Otherwise it makes no sense to even allow setting OS/2 version explicitly (not necessarily a bad thing) and the support for it can just be dropped.
There was a problem hiding this comment.
Yes, I guess you are right. However, I don't know for the Python interface if we can do such warning.
But the 7th bit is set here. |
|
|
@khaledhosny https://www.microsoft.com/typography/otspec/os2.htm#ver actually says that 0 corresponds to TrueType rev 1.5, so I suspect it is actually not quite correct for fontforge to use it for "automatic"... |
|
In SMT I simply dropped the ability for user to select OS/2 version and left only the automatic calculation at build time, I suggest that FontForge do the same. |
|
@khaledhosny So if you drop the ability to select version of OS/2 table, maybe you shouold add an option to make it possible to specify |
cc'ing @khaledhosny
Download Asana Math and open it with fontforge:
http://www.ctan.org/tex-archive/fonts/Asana-Math/
ttx on Asana-Math.ttf generates fsSelection value="00000000 01000000" for the OS/2 table, USE_TYPO_METRICS is not set.
Open Asana-Math.ttf with fontforge. In the OS/2 menu, you should see that the option "use typo metrics" is checked. Generate a new ttf file (you can uncheck and check the box again if you want). A verification with ttx still indicates that USE_TYPO_METRICS is not set.
Analysis of the problem: parsettf.c sets use_typo_metrics to true by default but only overrides with the font value when OS/2 version >= 4. Also tottf.c set the bit USE_TYPO_METRICS in OS/2 table to true only if has version >= 4.
This patch makes use_typo_metrics default to false when loading a ttf file, so that it is not set by default when opening a font with OS/2 version < 4. It also tries to force upgrade to OS/2 when use_typo_metrics has been enabled by the user, so that this bit can be set during file generation. Similarly for info.weight_width_slope_only.