Bug 476378. Use U+002D instead of U+2010 for a soft hyphen if the first font in the fontgroup doesn't have a glyph for U+2010. r+sr=roc

This commit is contained in:
Jonathan Kew 2009-02-05 21:23:50 +13:00
parent 410d311d40
commit 534bc96e01
6 changed files with 53 additions and 13 deletions

View File

@ -1463,14 +1463,15 @@ GetHyphenTextRun(gfxTextRun* aTextRun, gfxContext* aContext, nsTextFrame* aTextF
gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
PRUint32 flags = gfxFontGroup::TEXT_IS_PERSISTENT;
// only use U+2010 if it is supported by the first font in the group;
// it's better to use ASCII '-' from the primary font than to fall back to U+2010
// from some other, possibly poorly-matching face
static const PRUnichar unicodeHyphen = 0x2010;
gfxTextRun* textRun =
gfxTextRunCache::MakeTextRun(&unicodeHyphen, 1, fontGroup, ctx,
aTextRun->GetAppUnitsPerDevUnit(), flags);
if (textRun && textRun->CountMissingGlyphs() == 0)
return textRun;
gfxTextRunCache::ReleaseTextRun(textRun);
gfxFont *font = fontGroup->GetFontAt(0);
if (font && font->HasCharacter(unicodeHyphen)) {
return gfxTextRunCache::MakeTextRun(&unicodeHyphen, 1, fontGroup, ctx,
aTextRun->GetAppUnitsPerDevUnit(), flags);
}
static const PRUint8 dash = '-';
return gfxTextRunCache::MakeTextRun(&dash, 1, fontGroup, ctx,

View File

@ -6,7 +6,7 @@
</head>
<body dir="rtl">
<p>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכל</p>
<p>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת&#x2010;<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת&#x2010;<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת&#x2010;<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת&#x2010;<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת&#x2010;<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת&#x2010;<br>אבגדהוזחטיכלמנסעפצקרשת</p>
<p>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת-<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת-<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת-<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת-<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת-<br>אבגדהוזחטיכלמנסעפצקרשתאבגדהוזחטיכלמנסעפצקרשת-<br>אבגדהוזחטיכלמנסעפצקרשת</p>
</p>
</body>
</html>

View File

@ -0,0 +1,19 @@
<html>
<head>
<title>Soft hyphen font fallback (for bug 476378)</title>
</head>
<body>
<!-- On OS X, Hoefler Text has a distinctive hyphen; on Windows, Segoe UI does.
In each case U+2010 will fall back to a font with a very different glyph. -->
<div style="width: 50pt;
font-family: Hoefler Text, Segoe UI, Trebuchet MS, Lucida Grande;
font-size: 24pt;">
<!-- reference text uses an explicit ASCII hyphen at the expected break point -->
<p>aaa-<br>aa</p>
</div>
</body>
</html>

View File

@ -0,0 +1,19 @@
<html>
<head>
<title>Soft hyphen font fallback (for bug 476378)</title>
</head>
<body>
<!-- On OS X, Hoefler Text has a distinctive hyphen; on Windows, Segoe UI does.
In each case U+2010 will fall back to a font with a very different glyph. -->
<div style="width: 50pt;
font-family: Hoefler Text, Segoe UI, Trebuchet MS, Lucida Grande;
font-size: 24pt;">
<!-- test whether soft-hyphen gets rendered from the primary font -->
<p>aaa&shy;aa</p>
</div>
</body>
</html>

View File

@ -32,3 +32,4 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") != zwnj-01.html zwnj-01-notref.html # Bad
fails-if(MOZ_WIDGET_TOOLKIT=="windows") == cgj-01.html cgj-01-ref.html # bug 455455
== 444656.html 444656-ref.html
== 449555-1.html 449555-1-ref.html
== 476378-soft-hyphen-fallback.html 476378-soft-hyphen-fallback-ref.html

View File

@ -2,11 +2,11 @@
<body>
<div>
<p>Hy&#x2010;<br>phen.
<p>Hy&#x2010;<br>phen.
<p>Hy&#x2010;<br>phen.
<p>Hy&#x2010;<br>phen.
<p>Hy&#x2010;<br>phen.
<p>Hy-<br>phen.
<p>Hy-<br>phen.
<p>Hy-<br>phen.
<p>Hy-<br>phen.
<p>Hy-<br>phen.
</div>
</body>