Bug 41599

Summary: optimizeLegibility doesn't play nice with fonts that do not have a space glyph
Product: WebKit Reporter: Maarten Van Coile <maarten.vancoile>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, mitz, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.6   
Attachments:
Description Flags
Account for font fallback in initializing wordTrailingSpaceWidth sam: review+

Description Maarten Van Coile 2010-07-05 03:08:55 PDT
when using "text-rendering: optimizeLegibility;" on a site with @font-face, webkit tends to clip-off part of the text.

Example:
http://www.fontsquirrel.com/fontfacedemo/Alpha-Echo
+ css:
html { text-rendering: optimizeLegibility; }
Comment 1 mitz 2010-07-05 09:20:57 PDT
The problem appears to be this:

ERROR: Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width will not be overridden.
(WebCore/platform/graphics/SimpleFontData.cpp:164 void WebCore::SimpleFontData::platformGlyphInit())
Comment 2 mitz 2010-07-05 09:43:04 PDT
Further debugging shows that the problem is that the font doesn’t map the SPACE character to a glyph. WebKit substitutes the space glyph from the next font in fallback order, but in some code paths, WebKit uses the cached space width from the font itself, which is bogus. This discrepancy is what’s causing the incorrect line breaking.

Specifically, in RenderBlock::findNextLineBreak(), the initialization of wordTrailingSpaceWidth should probably be changed to measure a space character instead of using the cached space width.
Comment 3 mitz 2010-07-05 10:35:44 PDT
Created attachment 60554 [details]
Account for font fallback in initializing wordTrailingSpaceWidth
Comment 4 mitz 2010-07-05 17:11:46 PDT
Fixed in <http://trac.webkit.org/projects/webkit/changeset/62510>.
Comment 5 WebKit Review Bot 2010-07-06 01:47:07 PDT
http://trac.webkit.org/changeset/62510 might have broken Leopard Intel Release (Tests)