New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 640077 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug

Blocking:
issue 642340



Sign in to add a comment

Generic font families always choose the system default font for CJK on Android

Project Member Reported by yutak@chromium.org, Aug 23 2016

Issue description

Version: Dev 54.0.2826.2
OS: Android

What steps will reproduce the problem?
(1) Open data:text/html,<p>MiMi</p><pre>MiMi</pre>
(2) Zoom up and look at the fonts.

What is the expected output?

The first text is rendered with a serif font (I assume that's the default
for latin), and the second text is rendered with a monospace font.

What do you see instead?

Both are rendered with a sans-serif font.

Please use labels and text to provide additional information.

Beta 53.0.2785.70 is OK, while Dev 54.0.2826.2 is bad, so I assume this
is a regression.

See attached images for actual results.

 
dev-54.0.2826.2.png
56.1 KB View Download
beta-53.0.2785.70.png
61.1 KB View Download

Comment 1 by yutak@chromium.org, Aug 23 2016

Cc: kojii@chromium.org kochi@chromium.org
Note that this device is on Japanese locale. That might be related.

Comment 2 by dn080...@gmail.com, Aug 23 2016

Суки верните нормальный шрифт глаза выпадают

Comment 3 by e...@chromium.org, Aug 23 2016

Owner: kojii@chromium.org
Status: Assigned (was: Untriaged)

Comment 4 by kojii@chromium.org, Aug 29 2016

Cc: nona@chromium.org
Looks like "Noto Sans CJK" is used for all generic families when lang is CJK:
http://output.jsbin.com/godemew

nona@, any ideas?

Comment 5 by kojii@chromium.org, Aug 29 2016

Ah, never mind, I just learned Android does not use settings at all for generic font families:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/CSSFontSelector.cpp?q=familyNameFromSettings&sq=package:chromium&l=93&dr=CSs

I'll look into more.

Comment 6 by kojii@chromium.org, Aug 29 2016

Labels: Needs-Bisect
Okay, I understood why this doesn't work on Android. However, I don't understand why this used to work. As far as I tracked code history, this has never worked, at least since 2013 or so.

Comment 7 by kojii@chromium.org, Aug 29 2016

Cc: drott@chromium.org e...@chromium.org js...@chromium.org
Labels: -Needs-Bisect
Summary: Generic font families always choose the system default font for CJK on Android (was: Regression: Wrong font is chosen for "serif" and "monospace" on Android)
Ahh, got it. This is a very unfortunate side effect of a correct fix.

1. The test using lang attribute http://output.jsbin.com/godemew does not work in 53. This has been broken at least since 2013, and the change looks intentional.
2.  Issue 609043  fixed to honor the system locale as the default language when author omits lang attributes, so pages without lang attributes on CJK system will hit the existing issue.

Now we have a hard choice.

a. Undo  issue 609043  and go back to use "en" when lang is omitted.
b. Undo/fix the Android-only code for generic font family. I don't know the history of this code, but this isn't probably an option, I guess Android doesn't pass proper GenericFontFamilySettings to the renderer?
c. Undo/fix the Android-only code for CJK scripts to ignore generic font family. Hard to say, I don't know why it was done so.

b. is in familyNameFromSettings(), which ignores settings and delegates to FontCache.
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/CSSFontSelector.cpp?q=familyNameFromSettings&sq=package:chromium&l=93&dr=CSs

c. is in getGenericFamilyNameForScript(), which goes to system font fallback code if script is CJK.
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroid.cpp?q=getGenericFamilyNameForScript&sq=package:chromium&l=52&dr=CSs

I guess we don't want to revert  issue 609043  do we?

I'm leaning to option c, to not to pick CJK fonts, at least if "monospace". This will change "monospace" with lang="one of CJK" from Noto CJK to Courier, but system fallback should work if there were CJK characters, so I suppose this is a good change.

For other generic families, I guess we need to work this out when we get 2nd CJK fonts on Android.

Thoughts? Any one knows history of this Android-only code?

Comment 8 by kojii@chromium.org, Aug 29 2016

d. Recover the old behavior for M54 (broken only when lang is specified) and remove c for M55 to see if it sticks.

Maybe this is safer?

Comment 9 by kojii@chromium.org, Aug 29 2016

On another thought, we probably should not remove and rely on system fallback. As it'll run per character, while font choice is only font, it is likely to regress performance for CJK.

Assuming "monospace" is primarily used for code even in CJK, fix only for "monospace" looks reasonable.

In a long run, how we'd support generic font family for non-Latin on Android is something we need to consider more.

Comment 10 by drott@chromium.org, Aug 29 2016

How about the FIXME here:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroid.cpp?q=getGenericFamilyNameForScript&sq=package:chromium&dr=CSs&l=55

Is there a way we can query for a suitable language specific font in Android? Does the Android fonts.xml configuration have generic family names for specific languages that could be used?

Comment 11 by kojii@chromium.org, Aug 30 2016

> How about the FIXME here

I hoped you might know who wrote the comment for what purpose, sounds like it's even older.

As far as I checked Skia code or Android fonts.xml, there's no such things. I wonder we might need to to the same thing as we do for Windows when Android got more i18n fonts...

Comment 12 by yutak@chromium.org, Aug 30 2016

As an original reporter, I'm fine with Chromium using a different set of fonts
for Japanese pages. I just want it to pick a sensible font for monospace and,
if Android has serif variants, serif. Currently it's hard to read formatted
code rendered with monospace.

Comment 13 by drott@chromium.org, Aug 30 2016

Perhaps you can talk to Raph about the font configuration on Android and explain the problem? The header of fonts.xml says bcp-47 and language matching has priority (and I assume that Skia implements it that way, but I might be wrong), but that's how we end up with a less than optimal monospace choice for lang="ja", because lang="ja" is explicitly listed in the fonts.xml.

I feel like the fonts.xml should define the sensible default families for sans-serif, serif, monospace, fantasy even for specific languages somehow rather than us making hardcoded choices in Chrome?

Comment 14 by kojii@chromium.org, Aug 30 2016

Blocking: 642340
Project Member

Comment 15 by bugdroid1@chromium.org, Aug 30 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/96e2aeba7ca3d4398a2cfb44f2b864dfa8ea2ad9

commit 96e2aeba7ca3d4398a2cfb44f2b864dfa8ea2ad9
Author: kojii <kojii@chromium.org>
Date: Tue Aug 30 14:01:36 2016

Disable CJK specific generic font families for monospace on Android

Before this patch, when the content locale is one of CJK, Android maps
all generic families to what Skia matchFamilyStyleCharacter() API
returns. This API can find one default font for the specified locale,
but disregards which generic font family was used.

This patch disables the behavior for "monospace", where using the
monospace ASCII glyphs is more important than using the font that has
good coverage of the specified locale.

When characters outside of the monospace font were used, system
fallback can still help to render the characters.

BUG= 640077 

Review-Url: https://codereview.chromium.org/2288383002
Cr-Commit-Position: refs/heads/master@{#415287}

[modify] https://crrev.com/96e2aeba7ca3d4398a2cfb44f2b864dfa8ea2ad9/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroid.cpp
[modify] https://crrev.com/96e2aeba7ca3d4398a2cfb44f2b864dfa8ea2ad9/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroidTest.cpp

Comment 16 by kojii@chromium.org, Aug 31 2016

Labels: Merge-Request-54
Status: Fixed (was: Assigned)

Comment 17 by dimu@chromium.org, Aug 31 2016

Labels: -Merge-Request-54 Merge-Approved-54 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M54 (branch: 2840)
Project Member

Comment 18 by bugdroid1@chromium.org, Aug 31 2016

Labels: -merge-approved-54 merge-merged-2840
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/52239519d59013e93173e9181fb3dbaec7837ac5

commit 52239519d59013e93173e9181fb3dbaec7837ac5
Author: Koji Ishii <kojii@chromium.org>
Date: Wed Aug 31 07:05:46 2016

Merge 2840: Disable CJK specific generic font families for monospace on Android

Before this patch, when the content locale is one of CJK, Android maps
all generic families to what Skia matchFamilyStyleCharacter() API
returns. This API can find one default font for the specified locale,
but disregards which generic font family was used.

This patch disables the behavior for "monospace", where using the
monospace ASCII glyphs is more important than using the font that has
good coverage of the specified locale.

When characters outside of the monospace font were used, system
fallback can still help to render the characters.

BUG= 640077 

Review-Url: https://codereview.chromium.org/2288383002
Cr-Commit-Position: refs/heads/master@{#415287}
(cherry picked from commit 96e2aeba7ca3d4398a2cfb44f2b864dfa8ea2ad9)

Review URL: https://codereview.chromium.org/2292223003 .

Cr-Commit-Position: refs/branch-heads/2840@{#63}
Cr-Branched-From: 1ae106dbab4bddd85132d5b75c670794311f4c57-refs/heads/master@{#414607}

[modify] https://crrev.com/52239519d59013e93173e9181fb3dbaec7837ac5/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroid.cpp
[modify] https://crrev.com/52239519d59013e93173e9181fb3dbaec7837ac5/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroidTest.cpp

Project Member

Comment 19 by bugdroid1@chromium.org, Oct 27 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/52239519d59013e93173e9181fb3dbaec7837ac5

commit 52239519d59013e93173e9181fb3dbaec7837ac5
Author: Koji Ishii <kojii@chromium.org>
Date: Wed Aug 31 07:05:46 2016

Merge 2840: Disable CJK specific generic font families for monospace on Android

Before this patch, when the content locale is one of CJK, Android maps
all generic families to what Skia matchFamilyStyleCharacter() API
returns. This API can find one default font for the specified locale,
but disregards which generic font family was used.

This patch disables the behavior for "monospace", where using the
monospace ASCII glyphs is more important than using the font that has
good coverage of the specified locale.

When characters outside of the monospace font were used, system
fallback can still help to render the characters.

BUG= 640077 

Review-Url: https://codereview.chromium.org/2288383002
Cr-Commit-Position: refs/heads/master@{#415287}
(cherry picked from commit 96e2aeba7ca3d4398a2cfb44f2b864dfa8ea2ad9)

Review URL: https://codereview.chromium.org/2292223003 .

Cr-Commit-Position: refs/branch-heads/2840@{#63}
Cr-Branched-From: 1ae106dbab4bddd85132d5b75c670794311f4c57-refs/heads/master@{#414607}

[modify] https://crrev.com/52239519d59013e93173e9181fb3dbaec7837ac5/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroid.cpp
[modify] https://crrev.com/52239519d59013e93173e9181fb3dbaec7837ac5/third_party/WebKit/Source/platform/fonts/android/FontCacheAndroidTest.cpp

shortcut_quicksettings_expand.png
10.1 KB View Download

Sign in to add a comment