Commit 8e00956
committed
fonts: fix CJK fallback font loading
Clearing font charset restrictions by copying a font descriptor's attributes and re-creating it sometimes doesn't work; for example, with 'PingFang SC Regular' (derived from '.AppleSystemUIFontMonospaced' in `CoreText.discoverCodepoint(...)`), `face.hasCodepoint(cp, p_mode)` will erroneously return false after copying, and the font will be rejected. This causes fallback font lookup to fail for CJK characters when using '.AppleSystemUIFontMonospaced' (the non-CJK path queries system fonts instead of deriving a font from the current one, so doesn't seem to hit the broken font). If you first render a non-CJK character that loads a font that contains CJK characters, everything will work fine as the CJK fallback path is never hit.
I'm fixing this by only clearing charset restrictions if we know that we've applied them to the font (using `CoreText.discover(...)`, not hitting the special CJK path), but I'm not sure how fragile the charset restriction clearing is for other scenarios.1 parent e7c1b4d commit 8e00956
1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
375 | 376 | | |
376 | 377 | | |
377 | 378 | | |
| |||
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
| 413 | + | |
412 | 414 | | |
413 | 415 | | |
414 | 416 | | |
| |||
433 | 435 | | |
434 | 436 | | |
435 | 437 | | |
| 438 | + | |
436 | 439 | | |
437 | 440 | | |
438 | 441 | | |
| |||
828 | 831 | | |
829 | 832 | | |
830 | 833 | | |
| 834 | + | |
| 835 | + | |
831 | 836 | | |
832 | 837 | | |
833 | 838 | | |
| |||
849 | 854 | | |
850 | 855 | | |
851 | 856 | | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
852 | 861 | | |
853 | 862 | | |
854 | 863 | | |
| |||
0 commit comments