Skip to content
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

Fix for some issues on Windows (hinting, and font naming in some programs) #202

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roelandschoukens
Copy link

@roelandschoukens roelandschoukens commented Mar 16, 2024

(nb I don’t know 100% what I’m doing here, so I’d love to hear from someone who knows this stuff what is actually going on here)

This PR contains two commits to fix some weird issues I am seeing on Windows 11.

Chinese glyphs in TTF and OTF thumbnails

image

This stops happening if you remove CJK from the OS/2 charsets. For that I added explicit entries in all the fonts.props files.

GIMP fails to use some fonts

image

The unadorned versions show the 08 weight. I don't know why the italic thumbnail is blank but that variant works. The #1 variants don't work.

I suspect some apps don’t tolerate anything else than the usual "Bold" or "Italic" styles in style names. So I changed the TTF names so the "08" and "12" becomes part of the font family name. This seems not ideal but at least I can use all the fonts now.

So for that I edited the LangName entries like this:

-LangName: 1033 ... ... ... "" "EB Garamond" "08 Regular" "EB Garamond 08 Regular"
+LangName: 1033 ... ... ... "" "EB Garamond 08" "Regular" "EB Garamond 08 Regular"

Hinting

A picture says more than a 1000 words. This is what I got on Windows 11 😟

TTF on the left, OTF on the right.

image

So it took some experimentation to figure out that:

  • I have to write the opentype tables to get ligatures. (Note the word ‘officia’ in the last line)
  • If a TTF file contains opentype tables it sort of counts as an opentype font file. This is important because…
  • It seems ttfautohint does not affect opentype font files.
  • Opentype in particular looks terrible if any hinting information is in the file. So the modified build scripts writes OTF files without hinting information.
  • I don’t know the default flags used in font.generate() if you don’t give it a flags argument. But be advised if you specify it at all, by default you do not get opentype tables in your font unless you use the "opentype" flag.
  • This commit modifies the TTF files to be plain TTF. Note the lack of ligatures so it is possibly a bad idea to make this change. But this means that ttfautohint actually works. It was instructed to use the “slight”, or “natural” hinting.

image

 - Fill in OS/2 character sets: specifically we don’t want to advertise
   coverage of CJK characters, otherwise Windows will display Chinese
   glyphs (which we don’t have) in thumbnails.

 - Adjust font names: the "08" and "12" parts are part of the "family".
   Otherwise programs like GIMP will get really confused, and they will
   fail to use these fonts.
 - Don't export hinting from SF
 - Don't export opentype tables to TTF files (this makes it so the TTF file is actually TTF and not OTF)
 - Must explicitly include opentype if using flags when exporting OTF
 - For ttfautohint use windows compatible mode and "light", aka "natural" hinting. Limit the sizes where hinting happens.
 - We definitely don’t want hinting information in OTF files or it will look absolutely terrible.
@roelandschoukens roelandschoukens changed the title Fix some weird issues on Windows Fix for some issues on Windows (hinting, and font naming in some programs) Mar 16, 2024
@kenmcd
Copy link

kenmcd commented Mar 16, 2024

Do not install the OTF and TTF versions of fonts at the same time.
The duplicate name conflicts cause unexpected results.

@roelandschoukens
Copy link
Author

I only install the OTF versions. The screenshot is the build folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants