mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-12 13:24:56 +00:00
Rebuilt on the split `fontdb/`: `KOREAN_SANS_FALLBACKS` and `sans_by_name` sit in `fontdb/fallback.rs` beside `KOREAN_FALLBACKS`, `cjk_chain` takes the style, `fallback_for_styled` is on both `ScopedFonts` and `FontDb`, and the tests live in `fontdb/tests/fallback.rs` where that file's other fallback tests are. `KOREAN_FALLBACKS` is serif-first (AppleMyungjo, Apple SD Gothic Neo, Batang, Malgun Gothic...), so on Windows the first installed entry is Batang. A document whose Korean text asks for faces that are not installed -- KoPub Dotum, KHNP Han Dotum, BM Dohyeon -- came out in a serif face throughout: the report measured 5,298 characters of one school document turning from sans to serif. The font is not installed, so its name is all there is to go on. `sans_by_name` reads the style out of the family name: Dotum (돋움), Gulim (굴림), Gothic (고딕), Sans, Headline, Graphic and Dohyeon are sans; Batang (바탕), Myungjo/Myeongjo (명조), Gungsuh (궁서) and Serif are serif. Serif is tested first, so "Noto Serif KR" is not caught by the `sans` rule. A run whose requested face is sans draws its fallback from the sans chain, which leads with the system faces. If the requested name says neither, the substitute's own name decides, which leaves today's chain in place. The tests do not depend on which fonts the machine has: they pin the name classification and the chain order -- the first sans entry comes before Batang, and the serif chain still leads with a serif face, so a missing Myungjo is not turned into a sans one. `fallback_for` keeps its signature and delegates, so the ruby, kenten and image callers are unchanged.