<input> rendered too wide on python reference manual page |
|||||
Issue descriptionChrome Version : 51.0.2704.106 (Official Build) (64-bit) OS Version: Linux URLs (if applicable) : https://docs.python.org/2/library/string.html What steps will reproduce the problem? 1. Open the URL 2. See search box in the left nav bar 3. Check its width What is the expected result? <input> field should fit in the navigation bar. What happens instead of that? <input> field sticks out of the navigation bar. Please provide any additional information below. Attach a screenshot if possible. The <input> does not have any explicit "width" style, and it should be default to 20-char width of the default font. But it seems it can contain 40 chars. The font selected for the page seems "Noto Snas CJK JP DemiLight" on my Linux desktop, according to the devtools. So probably the default width was calculated with its "full-width" character advance, which is double of the "half-width" characters.
,
Jul 1 2016
,
Jul 1 2016
I checked LayoutTextControl::hasValidAvgCharWidth(), which font name is passed onto the function. On the page (python reference), "-webkit-sans-serif" was passed to the function, so I guess checking the font in the function is too early to determine if it is an invalid font. If the family is one of generic families, the check has to be done after resolving the real font family name on the running platform?
,
Jul 6 2016
I downloaded the latest Noto Sans CJK JP and it looks like it has correct metrics. avgCharWidth=6.63834 zeroWidth=7.39814997 Maybe could you try to update fonts in your system?
,
Jul 6 2016
Unfortunately, it did not make any difference on the python page. Downloaded from: https://www.google.com/get/noto/ Noto-hinted.zip, sha1=c0d29504f8eeedede34eae93b3ac8561cfa5721a In particular, "Noto Sans CJK JP DemiLight", what I used originally was fontRevision=1.00099, while the new one has fontRevision=1.004. (I used 'showttf' command on Linux to get these numbers). How did you get "avgCharWidth" and "zeroWidth"?
,
Jul 8 2016
In the debugger: font->m_fontFallbackList->m_cachedPrimarySimpleFontData->m_avgCharWidth font->m_fontFallbackList->m_cachedPrimarySimpleFontData->m_fontMetrics->m_zeroWidth
,
Jul 8 2016
if you prefer printf: font->primaryFont()->avgCharWidth() font->getFontMetrics()->zeroWidth()
,
Jul 12 2016
,
Jul 13 2016
On my local Ubuntu, when LayoutTextControl::getAvgCharWidth() is called for the python string reference page, the |family| was "-webkit-sans-serif" and avgCharWidth = 14.0 zeroWidth = 7.900497 On test html when I specify explicitly "Noto Sans CJK JP DemiLight", avgCharWidth = 13.0 zeroWidth = 7.317108
,
Jul 13 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/77183f3386fcb2362ca6140ab5fb15958d7cfa2d commit 77183f3386fcb2362ca6140ab5fb15958d7cfa2d Author: kojii <kojii@chromium.org> Date: Wed Jul 13 08:42:54 2016 Add heuristic to LayoutTextControl::hasValidAvgCharWidth() This patch adds a heuristic check to see if the font has invalid avgCharWidth. The spec is silent about how avgCharWidth is computed for CJK fonts, and some fonts selected to match to CJK full-width characters. Since in most fonts, avgCharWidth is close to the width of "0", when it's too big compared to the width of "0" can be considered as invalid. BUG= 625058 Review-Url: https://codereview.chromium.org/2145903002 Cr-Commit-Position: refs/heads/master@{#405086} [modify] https://crrev.com/77183f3386fcb2362ca6140ab5fb15958d7cfa2d/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp [modify] https://crrev.com/77183f3386fcb2362ca6140ab5fb15958d7cfa2d/third_party/WebKit/Source/core/layout/LayoutTextControl.h [modify] https://crrev.com/77183f3386fcb2362ca6140ab5fb15958d7cfa2d/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
,
Jul 13 2016
,
Jul 13 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/77183f3386fcb2362ca6140ab5fb15958d7cfa2d commit 77183f3386fcb2362ca6140ab5fb15958d7cfa2d Author: kojii <kojii@chromium.org> Date: Wed Jul 13 08:42:54 2016 Add heuristic to LayoutTextControl::hasValidAvgCharWidth() This patch adds a heuristic check to see if the font has invalid avgCharWidth. The spec is silent about how avgCharWidth is computed for CJK fonts, and some fonts selected to match to CJK full-width characters. Since in most fonts, avgCharWidth is close to the width of "0", when it's too big compared to the width of "0" can be considered as invalid. BUG= 625058 Review-Url: https://codereview.chromium.org/2145903002 Cr-Commit-Position: refs/heads/master@{#405086} [modify] https://crrev.com/77183f3386fcb2362ca6140ab5fb15958d7cfa2d/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp [modify] https://crrev.com/77183f3386fcb2362ca6140ab5fb15958d7cfa2d/third_party/WebKit/Source/core/layout/LayoutTextControl.h [modify] https://crrev.com/77183f3386fcb2362ca6140ab5fb15958d7cfa2d/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by tkent@chromium.org
, Jul 1 2016