glyphr-studio / Glyphr-Studio-2

Glyphr Studio v1 is more than a decade old. V2 is here to save the day.
https://www.glyphrstudio.com/v2
109 stars 13 forks source link

Ligatures based on nonexistent characters produce broken OTF fonts #198

Closed Castux closed 1 month ago

Castux commented 3 months ago

The interface lets the user create ligatures for characters that don't have glyphs in the font. These export and work fine in SVG fonts, but not in OTF.

For instance:

  1. create a new font ("Broken")
  2. fill a glyph as control ("a")
  3. create a ligature based on letters that do not have glyphs ("kh")
  4. export to OTF
brokenfont

Note:

  1. open the font in Fontforge
  2. notice that the ligature glyph is present
  3. notice that in the liga table, the ligature refers to ".notdef"
fontforge

Manual fix:

  1. in Fontforge, editing the liga table entry (in this example to k h) and saving the font works, but generates a warning that the ligature refers to letters without glyphs, and asks confirmation. The fixed font functions without the individual glyphs.

Workaround:

  1. in Glyphr studio, manually create bogus glyphs for the letters, for instance a zero-width rectangle with zero advance width

Suggestion:

  1. check what step of the OTF export generates the broken ligatures in opentype.js and if possible fix it
  2. or if it is not possible, generate bogus glyphs automatically to simplify user experience
  3. or alternatively, warn user of issue at export
mattlag commented 2 months ago

This is a good issue, thank you for filing it.

Option 1 I am tempted just to create dummy characters (no shapes, zero advance width). These would be added to the Glyphr Studio project "just in time" during the export process. These characters would show up in the font as well. This is probably an edge case, but there is a difference between a character not existing in a font, and a character that exists in a font with zero advance width and zero shapes. Typing one of these dummy characters (which you would need to do to start getting the ligature) would result in a blank zero width character. Otherwise, depending on your text editor, typing a non-existent character would result either in the .notdef glyph, or some fallback character being shown.

Option 2 Creating these dummy characters is required, essentially, but as you point out we could either pose it as a question to the user or pop some message to the user. A big scenario for Glyphr Studio is conlangs, many of which are abugidas. Sometimes these are 100% ligatures... I think it would be a bad experience, on export, to pop a message for every single missing ligature character, because this may be hundreds :-) This could also be a single warning that blocks export... but this is also not great. Leaving it up to the user to 'fix' this issue could also result in hundreds of required actions. So, for this option, I think anything beyond just a non-blocking toast notification could be very annoying.

Here's what I'm thinking:

Castux commented 2 months ago

Great! And yes, you called it, my first font was mostly ligatures, for digraphs and vowel diacritics :)