Closed Bug 476378 Opened 13 years ago Closed 13 years ago
Soft hyphens rendered incorrectly when chosen font lacks U+2010 HYPHEN and fallback font is sufficiently different
917 bytes, text/html
6.04 KB, image/png
23.78 KB, image/png
296 bytes, text/html
11.72 KB, image/png
10.34 KB, image/png
7.99 KB, image/png
6.07 KB, patch
|Details | Diff | Splinter Review|
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:188.8.131.52) Gecko/2008120121 Firefox/3.0.5 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:184.108.40.206) Gecko/2008120121 Firefox/3.0.5 Soft hyphens ("shy": ­) are rendered as a character that looks like "रू" (रू). If I copy the rendered character, it is correctly copied as the soft-hyphen character. This is not because of a broken font: it happens with most fonts, including Andale Mono, Arial, Baskerville [Old Face], Comic Sans MS, Courier New, Futura, Garamond, Geneva CY, Georgia, Gill Sans, Helvetica CY, Helvetica Neue, Hoefler Text, Lucida Bright, Lucida Sans, Microsoft Sans Serif, Optima, Palatino, Papyrus, Times, Times New Roman, Verdana, etc. (but renders fine -- like a hyphen -- with American Typewriter, Arial Unicode MS, Courier, Geneva, Gentium, Helvetica, Lucida Grande, Monaco, Trebuchet MS and a few others.) Reproducible: Always Actual Results: Character at end of line looks like रू Expected Results: Character should look like a hyphen
Contains a soft hyphen after every character
This is how it is rendered, with the default font set to Times
Just in case this is related: this is how Attachment 199178 [details] (of Bug 312063) is rendered on my system.
Works fine for me. It appears as a hyphen. I have my default font set to Times 16, which I think is the default default. Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:220.127.116.11) Gecko/2008120121 Firefox/3.0.5 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090201 Minefield/3.2a1pre "रू" is Devanagari, right? Do you have any settings related to Devanagari or languages that use Devanagari (e.g. Hindi)?
Renders fine here as well. This sounds a like bug 455243.
Thanks for mentioning bug 455243 -- there was a particular font on my system removing which fixed the problem. However, unlike bug 455243: * That font was not the last on the list of fonts * The name of that font ("xdvng") was not similar in any way to Times (and it could not have been similar to all of those wide set of fonts anyway) It's a pretty crazy font, but having it around ought not to interfere with existing good fonts (and it doesn't explain why rendering was good with one set of fonts and not with another). Is there any further information that might be helpful?
Could you test with a nightly build ? (with that 'crazy font' installed, ideally). http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/
Yes, the problem is still present in the nightly build. I called the font 'crazy' because it's some ad-hoc encoding that maps characters to Devanagari letters (see http://www-personal.umich.edu/~pehook/devnag.html ). I've put the font at http://web.mit.edu/vatsa/Public/XDVNGm.ttf
(In reply to comment #8) > Yes, the problem is still present in the nightly build. > > I called the font 'crazy' because it's some ad-hoc encoding that maps > characters to Devanagari letters (see > http://www-personal.umich.edu/~pehook/devnag.html ). > I've put the font at http://web.mit.edu/vatsa/Public/XDVNGm.ttf I downloaded that font and installed in ~/library/fonts (and restarted the browsers). * Fx 3.05(Gecko 18.104.22.168) and Camino nightly (Gecko 22.214.171.124pre): I can see the problem * Minefield latest nightly: no problems (tested with a default profile).
I do see it with the Minefield latest nightly [ http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/firefox-3.2a1pre.en-US.mac.dmg ] and a newly created profile, so I don't know what to add :) Maybe it depends on something else as well: what might it be?
John, any idea ? I my have some other (S-Asian) fonts that 'correct' the issue on trunk, but I doubt it.
Component: General → Layout: Text
Product: Firefox → Core
QA Contact: general → layout.fonts-and-text
The problem arises when the current font doesn't support U+2010 HYPHEN, which we are using to render the soft hyphen when a break is actually taken at this position. If the font doesn't support that character, we look for a fallback font, and if the one we happen to find has some other random glyph (such as Devanagari RUU) at that position, it will of course look broken. Unfortunately, there are many widespread fonts, including many of the system ones, that don't support the U+2010 codepoint, so fallback for soft-hyphen will be quite common. Fortunately, fonts that do "support" U+2010 but have an incorrect glyph at that codepoint are relatively rare. Note that even if we get a fallback font that does provide a proper hyphen glyph, this situation is still not ideal because the design of the fallback hyphen will not properly match the current typeface. How glaring this is will depend on the particular fonts involved, of course. While there's no way we can entirely avoid the risk of displaying garbage if the user has hacked, non-Unicode-compliant fonts installed, we could resolve this instance by rendering soft hyphens that are actually chosen as line breaks with U+002D HYPHEN-MINUS rather than U+2010 HYPHEN. This will virtually eliminate the use of fallback font matching for these, as U+002D is supported in virtually every font.
Status: UNCONFIRMED → NEW
Ever confirmed: true
This is a version of the test file that illustrates the font mismatch when using Hoefler, which has a distinctive high, thin hyphen character. The first paragraph has soft hyphens, and will use a fallback glyph at the line-break; the second paragraph shows real Hoefler hyphens for comparison.
Assignee: nobody → jfkthame
note the incorrect glyph for soft-hyphen on the first line
This patch attempts to resolve the issue (not just the glaring problem caused by a bizarre hacked font, but also the more general font mismatch as shown in the Hoefler example) by only using U+2010 if it is supported by the first font in the current fontGroup; otherwise, it uses the ASCII hyphen-minus character instead.
This issue can show up on any platform; I've reproduced it on Vista using text with the style "font-family: Segoe UI, Trebuchet MS". The screenshot shows how soft-hyphen (in the first text run) falls back to the glyph from Trebuchet, which is much shorter and thicker than the hyphen (ASCII 0x2D) in Segoe UI.
Note that this patch will cause the existing soft-hyphen reftests to start failing. I believe this is correct, because those tests have been using U+2010 in the reference text, and encountering font fallback in most cases (exact behavior could depend on the fonts on the test system). We should fix those tests to use U+002D instead (I don't recall seeing any real-life fonts where U+2010 is actually meant to render differently from U+002D). (An alternative would be to explicitly choose fonts that are known to support U+2010, but it may be difficult to do this reliably across all platforms and versions.) Marking the patch for review; if there is agreement on the approach, then I'll incorporate fixes for the reftests, as well as a new reftest that is explicitly designed to check for this bug.
Summary: Soft hyphens rendered incorrectly → Soft hyphens rendered incorrectly when chosen font lacks U+2010 HYPHEN and fallback font is sufficiently different
(In reply to comment #18) > We should fix those tests to use U+002D instead (I don't recall seeing any > real-life fonts where U+2010 is actually meant to render differently from > U+002D). Sigh. I felt full of Unicode righteousness for using U+2010. If this is the case, why don't we just use U+002D and simplify our code? I suppose because someone will promptly create a font that has different hyphens and file a bug against us.
Comment on attachment 360290 [details] [diff] [review] patch to correct soft-hyphen display error + nsRefPtr<gfxFont> font = fontGroup->GetFontAt(0); "gfxFont* font" is adequate here. Or you could just write fontGroup->GetFontAt(0)->HasCharacter ... we rely on the first font being there in many places.
Attachment #360290 - Flags: review?(roc) → review+
(In reply to comment #19) > Sigh. I felt full of Unicode righteousness for using U+2010. If this is the > case, why don't we just use U+002D and simplify our code? I suppose because > someone will promptly create a font that has different hyphens and file a bug > against us. Yes, I considered doing that, but I figured that if a font does support U+2010 then using it is probably the right thing to do, and we wouldn't want to throw away your hard-earned righteousness! :) I'll update the patch and check on the testcases, etc. I have a reftest for this bug, but as mentioned above, I know the patch will break others that we already have.
Comment on attachment 360460 [details] [diff] [review] updated patch following review comments, added/fixed reftests It would be nice if we had a test that checks U+2010 is used if it's available.
Whiteboard: [needs landing]
Pushed http://hg.mozilla.org/mozilla-central/rev/48bf047a9054 Should we take this on 1.9.1 I wonder?
Whiteboard: [needs landing]
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
(In reply to comment #24) > Should we take this on 1.9.1 I wonder? I don't think it deserves to be a blocker, but OTOH the change looks extremely low-risk. The fix would definitely be nice to have, as our current behavior gives incorrect (and unpredictable) rendering; usually it's not too glaring but there's the possibility (as in the original bug report) of it being completely bizarre. So I'd be in favor of asking for 1.9.1 approval. What's the process for that at this stage?
Attachment #360460 - Flags: approval1.9.1+
We should land this on 1.9.1 when the patch has baked a bit
Whiteboard: [needs 191 landing]
Whiteboard: [needs 191 landing]
verified FIXED on builds: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20090721 Minefield/3.6a1pre ID:20090721044139 and Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:126.96.36.199pre) Gecko/20090720 Shiretoko/3.5.1pre ID:20090720042942
You need to log in before you can comment on or make changes to this bug.