Bug 213008

Summary: [Win] Stop using MLang font linking for system font fallback
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ews-watchlist, glenn, jbedard, mmaxfield
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP patch
none
[screenshot] with the WIP patch
none
WIP patch none

Description Fujii Hironori 2020-06-09 21:25:26 PDT
[Win] Stop using MLang font linking for system font fallback

1. MLang is a legacy API
2. It has a problem for some Tibetan characters (Bug 212688)

Here is the list of revisions relevant to MLang:

r25543
r28810
r29140 : Bug 16548 – REGRESSION(r28810): Font style and sizes are weird for Japanese text
r30179 : Bug 17041 – Eastern Asian fonts do not display without specific box in Control Panel
Comment 1 Fujii Hironori 2020-06-09 21:26:22 PDT
Created attachment 401511 [details]
WIP patch
Comment 2 Fujii Hironori 2020-06-10 01:06:30 PDT
I realised an unexpected behavior change in the WIP patch.

Windows has two types of code pages, ANSI code page and OEM code page.
https://en.wikipedia.org/wiki/Windows_code_page

The current implementation chooses a CJK font depending on ANSI code page by getting LOCALE_IDEFAULTANSICODEPAGE.
https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp?rev=261013#L170

On the other hand, the WIP patch depends on OEM code page.
This font fallback behavior is same with normal Windows apps, for example notepad.exe.

ANSI code page can be changed by
Control Panel → Region → Format

OEM code page can be changed by
Control Panel → Region → Admistative → Change System Locale...
Comment 3 Fujii Hironori 2020-06-10 18:02:39 PDT
Created attachment 401610 [details]
[screenshot] with the WIP patch

The WIP patch doesn't work well for some CJK ideographs.
https://en.wikibooks.org/wiki/Unicode/Character_reference/6000-6FFF
Comment 4 Fujii Hironori 2020-06-10 20:50:52 PDT
(In reply to Fujii Hironori from comment #3)
> The WIP patch doesn't work well for some CJK ideographs.
> https://en.wikibooks.org/wiki/Unicode/Character_reference/6000-6FFF

Here is what is happening.

1. meta file method returned "Microsoft Sans Serif" font.
2. "Microsoft Sans Serif" doesn't contain the character
3. Get the FontLink registry of "Microsoft Sans Serif"

MSGOTHIC.TTC,MS UI Gothic
YUGOTHM.TTC,Yu Gothic UI
MINGLIU.TTC,PMingLiU
SIMSUN.TTC,SimSun
GULIM.TTC,Gulim
MSJH.TTC,Microsoft JhengHei UI
MSYH.TTC,Microsoft YaHei UI
MALGUN.TTF,Malgun Gothic
SEGUISYM.TTF,Segoe UI Symbol

4. "MS UI Gothic" and "Yu Gothic IU" doesn't contain the character
5. No "PMingLiU" font found in my Windows
6. the function exits with nullptr
Comment 5 Fujii Hironori 2020-06-11 01:30:22 PDT
Created attachment 401627 [details]
WIP patch