Details
-
Technical task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
Description
The fallback / font-merging mechanism (assigning fonts to characters when the main font is not applicable) may end up with different fonts for the characters of the string, even if there exists a single font which can show them all. One typical example would be Japanese text, where you can easily get a Chinese font for the Kanji characters, and a different, Japanese font for the Hiragana/Katakana characters.
The reason is that we only go through the string character by character and assign fonts disregarding context.
A better way would be to check all fonts against all characters and keep the data from this. Then we apply the font which supports the most characters to these characters first. When this is done, we check which font supports the most of the remaining characters and apply this to them. Etc. until the whole string is covered.
This should be an opt-in feature, since it will likely cause a slow-down on systems with a lot of fonts (the fact that the first font in the list is usually sufficient is likely a pretty significant optimization). But it is worth checking if it is fast enough to be useful in cases where you get the wrong appearance by default.