https://bugs.documentfoundation.org/show_bug.cgi?id=174329

--- Comment #16 from gio.bertelli <[email protected]> ---
Confirmed, and it is not the layout/Skia mismatch of bug 170634: here the glyph
fallback never resolves at all, so the missing characters are drawn with the
.notdef glyph of the base font. The striped boxes in the screenshot are glyph 0
of .AppleSystemUIFont (verified by rendering that glyph with CoreText: it is
identical).

Cause:

- .AppleSystemUIFont (SF) has no CJK, Arabic, Hebrew, Thai, Devanagari, kana or
Hangul glyphs.
- For those characters VCL asks CoreText (CTFontCreateForString), which returns
a private system font: family ".PingFang UI SC" (postscript
".PingFangUITextSC-Regular", from
.../FontServices.framework/Resources/Reserved/PingFangUI.ttc, 'hvgl'-only) for
Chinese and Japanese, ".Apple SD Gothic NeoI" for Korean, ".SF Arabic", ".SF
Hebrew", ".ThonburiUI", ".SF Devanagari", etc.
- FindFontSubstitute() only returns the family name, and
PhysicalFontCollection::GetGlyphFallbackFont() then does FindFontFamily(name).
Private families are not in the font list (CoreText does not enumerate them,
and the 'hvgl'-only ones are skipped for tdf#163000), and CoreText refuses to
create them by name ("All system UI font access should be through proper APIs
such as CTFontCreateUIFontForLanguage()"), so the lookup always fails.
- The generic fallback list does not help on macOS either:
DevFontFromCTFontDescriptor() sets quality 0 for every CoreText font, and
ImplInitGenericGlyphFallback() only stores a font when nBestQuality <
family->GetMinQuality() (0 < 0 is false), so mnFallbackCount stays 0 and the
list is never used.
- Result: no fallback font at all, and the characters are drawn with glyph 0 of
the base font.

Before 212571 the app font was not in the font list, so it was substituted with
a normal public font (Liberation Sans, Arial Unicode MS, ...), whose CoreText
cascade returns public names ("PingFang SC") that are in the list. That is why
26.8.2 works and master does not.

This is not specific to Chinese: every non-Latin UI script is affected, because
CoreText returns a private font for all of them (Arabic, Hebrew, Thai,
Devanagari, Japanese, Korean, ...). It also affects document text whose
CoreText fallback is a private or 'hvgl'-only font, e.g. on macOS 26/27 Chinese
text with Liberation Sans is lost for the same reason.

Proposed fix: if the font suggested by CoreText is not usable (private family
name, or 'hvgl'-only), ask CoreText for the public fonts that support the same
language and use the first one that has the characters. With the patch the same
zh-CN UI renders correctly (second screenshot).

Screenshots, same machine (macOS 27.2, aarch64), same zh-CN UI, same dialog:
- before: nightly 27.2.0.0.alpha0, buildid
c65bc3551b5a86b470e711aa7202fcd4c41f7121 (has 212571, no fix)
- after: master + patch, buildid 116fa523e13379147315ad2ab73455b2ce392b5d

Patch: https://gerrit.libreoffice.org/c/core/+/214128

The regression is in 26.8 as well (212571 was cherry-picked to
libreoffice-26-8), so a backport is needed:
https://gerrit.libreoffice.org/c/core/+/214129

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to