pango enhance to use PANGO_SCRIPT_COMMON with non-latin fonts.
@fujiwarat
Submitted by Takao Fujiwara Link to original bug (#604149)
Description
Currently Pango has two kind of scripts PANGO_SCRIPT_LATIN and PANGO_SCRIPT_COMMON in ASCII range. e.g. ASCII '@' belongs to PANGO_SCRIPT_COMMON. e.g. ASCII 'a' belongs to PANGO_SCRIPT_LATIN. Pango uses PANGO_SCRIPT_COMMON with latin fonts only in Monospace/Sans/Sans-Serif. Both PANGO_SCRIPT_COMMON and PANGO_SCRIPT_LATIN doesn't indicate ASCII only but also many multi-byte chars.
If users type ASCII "@a", pango_script_iter_next() treats the string with PANGO_SCRIPT_LATIN since 'a' is PANGO_SCRIPT_LATIN and pango gets latin fonts from fontconfig. If users type ASCII "@ ", pango_script_iter_next() treats the string with PANGO_SCRIPT_COMMON and pango gets non-latin fonts from fontconfig. If users type ASCII + Chinese "@\xe4\xb9\x8c", pango_script_iter_next() treats the string with PANGO_SCRIPT_HAN and pango gets non-latin fonts from fontconfig.
Normally both Latin and Non-latin font includes the ASCII PANGO_SCRIPT_COMMON chars.
The problem is some of Chinese fonts(e.g. "AR PL UKai CN") have a worse quality in ASCII chars than one of latin fonts(e.g. "DejuVu").
# env LANG=zh_CN.UTF-8 fc-match
ukai.ttc: "AR PL UKai CN" "Book"
Then they'd like to use latin fonts for PANGO_SCRIPT_LATIN and ASCII PANGO_SCRIPT_COMMON.
But currently Pango treats PANGO_SCRIPT_COMMON with non-latin fonts because the behavior would be good in some languages.
Removing the glyphs in Chinese fonts might not be realistic to resolve this issue since users can choose either Monospace/Sans/Serif or each font. The request is to use latin fonts in ASCII PANGO_SCRIPT_COMMON in Monospace/Sans/Serif and also use non-latin font("AR PL UKai CN") in "AR PL UKai CN".
Currently the behavior of PANGO_SCRIPT_COMMON is hard-coded in pango. My idea is to have a feature to customize the behavior with fontconfig.
I'm adding the patch of fontconfig and pango.