Generic font families always choose the system default font for CJK on Android |
|||||||||
Issue descriptionVersion: 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.
,
Aug 23 2016
Суки верните нормальный шрифт глаза выпадают
,
Aug 23 2016
,
Aug 29 2016
Looks like "Noto Sans CJK" is used for all generic families when lang is CJK: http://output.jsbin.com/godemew nona@, any ideas?
,
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.
,
Aug 29 2016
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.
,
Aug 29 2016
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?
,
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?
,
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.
,
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?
,
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...
,
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.
,
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?
,
Aug 30 2016
,
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
,
Aug 31 2016
,
Aug 31 2016
Your change meets the bar and is auto-approved for M54 (branch: 2840)
,
Aug 31 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
,
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
,
Sep 30 2017
|
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by yutak@chromium.org
, Aug 23 2016