Open rsms opened 2 years ago
What makes you think that this plugin is not open source? https://github.com/schriftgestalt/ShowUnderline/blob/master/ShowUnderline.glyphsPlugin/Contents/Resources/plugin.py
There is a confusion with the way the values is stored in the CFF table. CFF table defines the value as the center of the underline. (Glyphs corrects for this in the CFF table). That has changed for CFF2:
UnderlinePosition: Equivalent to the underlinePosition field in the 'post' table.
Oh! I looked at the mach-o binary at ~/Library/Application\ Support/Glyphs\ 3/Plugins/ShowUnderline.glyphsPlugin/Contents/MacOS/plugin
Interestingly Safari, Chrome and Firefox all draw the underline starting at (top) underlinePosition, not centered on it, even for TrueType fonts and CFF1 fonts. I couldn't find information about underline in CFF v1 (the CFF v1 PDF only lists UnderlinePosition and UnderlineThickness as attributes of a DICT, but does not describe its interpretation.) I'm curious to learn more about this — is there a link you could share with me about this data in CFF?
I tested this by making a simple HTML page and setting the following CSS for the document to have the browsers use the font data instead of making up their own values:
text-decoration-thickness: from-font;
text-underline-position: from-font;
Underline rendered as expected: (last character is an underscore)
However, underline rendering is all over the place in other software. TextEdit and all other standard macOS apps ignores the font's underline position and thickness (which is a shame, but reality is reality I guess.)
The software that does get it right, like Affinity Designer, also does what the web browsers do and draw the underline's top (not center) at underlinePosition.
Affinity Designer example: (notice the underline matching the underscore)
Have you tried to mess with the CFF value to find out if anyone is using them? Maybe the Adobe apps?
No, but that's an interesting idea!
BTW, here's a minimal test font: https://rsms.me/etc/font-underline/ (https://rsms.me/etc/font-underline/RSMSTest.var.ttf) Source: https://www.dropbox.com/s/nxshpmpo70o8794/underline-test-font.zip?dl=1 ,(OFL licensed)
This plugin draws the underline centered on
underlinePosition
while the spec says it should describe the top of the underline.BTW, if this was open source I'd be happy to contribute a fix :-)