Font Fallback has been archived.
Font Fallback has been archived and is no longer active.
Part of: Gio
Enabling Gio's text shaping, line wrapping, and glyph rendering to support mixed fonts.
Gio's text shaping stack has evolved a lot since Gio's public release, but it has a long way yet to go. You may have noticed that trying to display strings containing characters from multiple languages (or emoji) will display little rectangles in place of the characters not present in the string's primary language. This is due to a lack of a feature called "font fallback."
What is font fallback?
Font fallback is a preprocessing step in text shaping. It takes as input a string and a collection of fonts, and it divides the string into runs which can each be displayed with a single font.
Why don't we have font fallback?
We actually did. The old text shaper implemented a simple font fallback technique based on opentype font collection files. However, when we switched to a text shaper capable of displaying complex scripts and RTL text, we had to drop that implementation. It didn't work with the new text shaper, and the modifications to the shaper in order to support it aren't trivial. We decided it was better to gain support for complex scripts/RTL and do the fallback work later.
What does it take to add font fallback?
The line wrapping algorithm currently accepts a single run of shaped text and divides it into lines based on the available space. This will need to change to accept an arbitrary number of runs of shaped text (each potentially in a different font). This changes a basic assumption of the algorithm, and will require substantial testing (extending the tests here) to ensure that the modification preserves the other important properties of the line-wrapper (like correct output for both RTL and LTR).
Once the line wrapper can handle the new input, Gio's glyph to path logic (converts the results of shaping text into a Gio clip path describing the font glyphs) will need to be updated to be able to consume sequences of glyphs from mixed fonts. Right now the implementation assumes that a single, constant font will be used for an entire line of text.
Additionally, there are pre-processing steps that will need to be added immediately before shaping text to divide the text by font glyph coverage into separate runs.
- After this change, can I render emoji?
- This change will enable single-color emoji like [Noto Emoji Monochrome](https://fonts.google.com/noto/specimen/Noto+Emoji) to work within your strings, assuming you've loaded such a font. Support for rendering colored font glyphs is separate, and would be required for color emoji fonts.
- After this change, can I render bidirectional text (LTR text containing RTL or vice versa)?
- No, but this is a prerequisite to enabling bidi text layout.
- After this change, can I render text containing multiple styles (italics, bold, etc)?
- This change will enable the text shaper to handle this situation, but will not design and implement a public API for describing styled subregions of text. However, adding such an API later is much easier than implementing font fallback.
- Why does Gio want to raise money to implement this? The project has only ever done one feature bounty, and the rest of the work on Gio has been free.
- This isn't actually true. Elias, Chris, and a number of others are often paid to add features to Gio. Not every feature was implemented for money, but major projects like RTL support, Accessibility on Android, and others were funded by companies building with Gio.
- Some members of the Gio community do support the project financially, that money either goes towards supporting Gio's continuous maintenance cost (Chris and Elias need to spend time maintaining, reviewing patches, responding to communications, etc) or is stored in our OpenCollective for funding future work like this. The $1000 dollars that Gio plans to allocate towards this come from that existing support. We can simply wait until the community support we currently have raises another $1000, but this will take a while.
Transparent and open finances.
Estimated annual budget
Font Fallback is all of us
Our contributors 3
Thank you for supporting Font Fallback.