mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 19:27:05 -04:00
fallback_for tried every face that was already loaded before the usual families of the character's script. Which faces are loaded depends on every earlier lookup. On macOS, /Library/Fonts/Arial Unicode.ttf makes Arial Unicode MS the first face in the scan, and it covers every script that has usual families except Sinhala. The variable font search loads it, and so does a fallback for a character that it covers and the bundled faces and the usual families lack, such as the Simplified Chinese 们. After that, Hebrew, Arabic, Indic, Thai and CJK text in a Latin family fell back to Arial Unicode MS instead of Tahoma, Kohinoor Devanagari, Tamil Sangam MN, Hiragino Sans or Apple SD Gothic Neo. In the effectcraft-text unit tests, other_scripts_fall_back_to_a_plain_system_family and cjk_falls_back_to_a_system_family failed in 7 of 100 runs on a Mac, and in 24 of 100 while other builds were running, depending on which faces the other tests had loaded. The usual families now come right after the bundled faces. family_faces lists the installed faces of the script's families in the order they are tried, each in the preferred face's style. The list is cached per script and preferred face, and adding faces or changing the CJK locale clears it. Faces that are already loaded come next, then the per-block cache of the search over every installed font, then the search itself, as before. A search result made for another character of the block (an Armenian character next to Hebrew, Lao next to Thai, or a character that no face covers) is no longer used for a character that a usual family covers. tests/script_fallback.rs runs in a test binary of its own. It records the fallback for eight characters of those scripts, looks up U+0590, Armenian and Lao and runs the variable font search, and checks that the eight get the same faces again. It also checks that U+08A4, which on macOS only faces outside the Arabic list cover, keeps its face after a lookup of U+0870, which no face covers.