Open Bug 1934421 Opened 2 months ago Updated 2 months ago

Improve heuristics for choosing between Chinese & Japanese fonts [was: Japanese default font selection in macOS is incorrect]

Categories

(Core :: Layout: Text and Fonts, enhancement)

Firefox 133
ARM64
macOS
enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: shallow7280, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0

Steps to reproduce:

Visit any website without an explicit declaration of a Japanese typeface, like YouTube for example on macOS 15.1.1 using Firefox 133.

This is an example: https://www.youtube.com/watch?v=rttrXjvlR_c

Actual results:

Japanese text is rendered with the default Chinese font selection (Arial, PingFang SC, STHeiti, Heiti SC), resulting in inconsistencies with hiragana, katakana and kanji glyphs which is quite painful to look at.

Attached screenshot showing bug along with font tab in dev tools.

I'm guessing that Firefox is confusing Japanese text for Chinese text.

Expected results:

Japanese text should be rendered using the default Japanese typefaces (Hiragino Kaku Gothic ProN, Hiragino Kaku Gothic Pro, Hiragino Sans) rather than Chinese (Arial, PingFang SC, STHeiti, Heiti SC).

OS: Unspecified → macOS
Hardware: Unspecified → ARM64

Correction: So far this actually seems to be specific to YouTube.

Component: Untriaged → Layout: Text and Fonts
Product: Firefox → Core

I have also confirmed on my end that this bug occurs with Windows 10 on another system, so it's not specific to macOS or my system.

If the content is not tagged as lang="ja", the browser doesn't really know whether characters from the "unified Han" range should be assigned a Japanese or Chinese font. When I load the youtube example from comment 0, I see the page has lang="en-GB", so Firefox uses the Latin-script font preferences; then the Asian characters fall back to a Chinese font by default.

Note that if you add Japanese to the list of preferred languages for web content (see the Language section in about:preferences), this will act as a hint that you'd prefer to default to Japanese fonts when the page has not correctly tagged the content.

Arguably, the presence of Hiragana (or Katakana) characters in the content could be a "hint" that the unified-Han characters should be treated as Japanese (rather than Chinese), but this gets tricky... by the time the first kana character is encountered, font selection for earlier unified-Han ideographs may already have happened (and chosen Chinese). And a page may legitimately have both Chinese and Japanese text on it, so that if explicit language tagging is not present, some of the content is almost certain to use the "wrong" font, whatever heuristics are applied.

So basically I think the browser is working as expected here; in the absence of explicit language tagging, it has some fallback heuristics (including the user's language preferences) to try and guess which fonts to prefer, but depending on the environment, it's likely that some Japanese content will end up being displayed with Chinese fonts, or vice versa.

If no other "hints" are found, I think the default fallback is to prefer Chinese (see the font.cjk_pref_fallback_order pref).

While I think things are currently working as expected given the current prefs, I'm going to morph this into an "enhancement request" as there may be scope for improved heuristics that would try to get this "right" in more cases.

Severity: -- → S3
Type: defect → enhancement
Summary: Japanese default font selection in macOS is incorrect → Improve heuristics for choosing between Chinese & Japanese fonts [was: Japanese default font selection in macOS is incorrect]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: