kas-gui / kas-text

Rich text processing
Apache License 2.0
58 stars 2 forks source link

Font fallbacks #19

Closed dhardy closed 3 years ago

dhardy commented 3 years ago

This is a meta/planning issue for the use of fallback fonts for glyphs missing from the current font. There are several sub-issues:

  1. Selecting a stack of fallback fonts. This is left out-of-scope for now since it is a significant problem it its own right (Fontconfig) and since a hard-coded lift of font names can be used for testing.
  2. Building a font fallback abstraction. The main difficulty here is determining the API, e.g. if it is an ab_glyph::Font implementation or closer to ttf_parser::Face. See https://github.com/RazrFalcon/ttf-parser/issues/42
  3. Determining how to derive properties like ascender and line_gap — possibly just taking the first font's values or using the maximum — or perhaps the maximum over fonts used on the current line.
  4. Compatibility with harfbuzz_rs::shape. It appears that we must use a separate run for each font, which adds more complexity.
dhardy commented 3 years ago

This is partially done by #46, #47, #48, #49:

  1. We now use fontdb to find system fonts plus a hacky list (hardcoded but adjustable at run-time) of font names as fallbacks. But this misses another problem which deserves its own issue: efficiently selecting a suitable font.
  2. Done
  3. We just take the lazy approach (using the first font face), which so far appears adequate.
  4. Done

The first point deserves a new issue; otherwise this is done.