xtermjs / xterm-addon-ligatures

An xterm.js addon that provides font ligature support
MIT License
14 stars 4 forks source link

Update font-finder to fix font lookup bug #17

Closed princjef closed 6 years ago

princjef commented 6 years ago

Fixes #16 via upstream fix in https://github.com/princjef/font-finder/pull/4

Updated versions of font-finder and font-ligatures also include source typescript files for better debugging

princjef commented 6 years ago

Updated with a fix to actually handle fonts missing the OS/2 table rather than skipping them: https://github.com/princjef/font-finder/pull/6

Tyriar commented 6 years ago

@princjef should this fix prevent errors even when the font doesn't exist? https://github.com/xtermjs/xterm-addon-ligatures/issues/16#issuecomment-412345273

princjef commented 6 years ago

@Tyriar Yes the success/failure of this call doesn't depend on the actual font you're looking for. From the perspective of the addon, the logic runs like this once enabled:

  1. Fetch the list of system fonts available (including their family name and some additional metadata) from font-finder
  2. Go through the fonts specified in the terminal's font-family until one is found in the list from step 1, a generic family is reached (e.g. monospace), or the end of the font-family list is reached.
  3. If we found a font in step 2, load the ligature processor with it. If not, register the font resolution as failed (this doesn't throw an error, just internal state tracking to avoid checking for the same font over and over again).

The issue in #16 is related to an error being thrown in step 1 due to some fonts in an unexpected format (regardless of the actual font you're looking for). The actual question of whether your font is present or not is determined in step 2, which will not throw if the font is not present.