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

Selecting fonts and fallbacks #53

Open
dhardy opened this issue Jun 17, 2021 · 2 comments
Open

Selecting fonts and fallbacks #53

dhardy opened this issue Jun 17, 2021 · 2 comments

Comments

@dhardy
Copy link
Contributor

dhardy commented Jun 17, 2021

Since #46 we use fontdb by @RazrFalcon plus some hacky lists of preferred family names to select fonts. This vaguely works but has several issues:

  1. It probably requires tweaking to work acceptably on all systems
  2. It ignores system/user preferences
  3. It loads more fonts than necessary at start-up. This could be fixed with lazy-loading, but that wouldn't help much given the current fallback mechanism.
  4. The "missing glyph" fallback mechanism simply checks each loaded font in order (ttf_parser::Face::glyph_index), for each missing glyph. This now has caching but is still slow with multiple fallback fonts.
  5. It misses many fonts required for various (especially CJK) scripts. While we could simply add more fonts to the standard lists (or even replace them with some globbing rules), this would compound with (3) and (4) causing performance issues for any glyph not in the first (few) fonts and potentially also at start-up (more an issue when using fontdue).

Some significant changes are needed, at least to the way we choose fallback fonts and likely also to the way fonts are selected. This could either be via closer integration with system libraries or via closer adherence to CSS font selection (using the effective character map, and ... CSS recommends using the "system font fallback" mechanism as the next step).

Also relevant: rust-fontconfig by @fschutt.

@fschutt
Copy link

fschutt commented Jun 20, 2021

Use fontdb, rust-fontconfig will be in alpha stage for a long time

@yisibl
Copy link

yisibl commented Apr 11, 2022

Have a look at https://github.com/alibaba/font-toolkit, we plan to implement a better font fallback.

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

No branches or pull requests

3 participants