Commit 789a381
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 `discoverCodepoint(...)`, using
`CTFontCreateForString(...)`), `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'.
(note: 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 isn't 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 fonts.1 parent e7c1b4d commit 789a381
1 file changed
Lines changed: 9 additions & 0 deletions
| 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