On 10/25/2012 09:44 PM, Behdad Esfahbod wrote: > You need to tell us more about the context (system, etc) I think. You can use > Fontconfig. >
It's realtime rendering subtitle rendering I'm doing, and the subtitles are possibly animated, so it must be fast. I'm using fontconfig, but I'm just doing greedy codepoint by codepoint font selection at the moment, i.e. text is processed in sequence from start to end, and every time a glyph isn't found in the current font's cmap, a new font is searched and selected. This kind of fallback selection doesn't cut it in some cases (run of same script/language text is split up irregularly when a codepoint is missing in current font) and fallback is expensive sometimes (needs to check a huge number of fonts for coverage). Before investing much time into testing various strategies, I thought it might be a good idea to ask here. > Note that fallback order should be per-language, not per-script. > What does that mean in practice? Scripts often support multiple languages, so how should I map the script of a codepoint to a language? > CSS recommends trying to choose fallback font for entire grapheme clusters at > a time, but I don't know any implementation that does that. > I tried wading through Firefox source code (Firefox seems to be doing a very good job at fallback), but never really found the crucial part of the code or what the underlying algorithm is. :) Mozilla's codebase is very big and complex. As far as I can see, there are a few maxims for choosing fallbacks: the number of fonts used for a run of text should be minimal, every appearance of a specific character (or grapheme cluster) should always be rendered by the same font, and sequences of characters using the same font should be as long as possible. It doesn't seem to be possible to fulfill all these in an efficient manner, so what compromises work well in practice? What are common fallback implementations doing? Best regards Grigori _______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
