Bug 1211867 - Use the font's NBSP glyph (if present) rather than rendering NBSP using the standard <space> glyph. r=jdaggett

This commit is contained in:
Jonathan Kew 2015-10-14 16:00:35 +01:00
parent 47f37fa078
commit 002fc87c38

View File

@ -2343,10 +2343,15 @@ gfxFont::NotifyGlyphsChanged()
}
}
static bool
// If aChar is a "word boundary" for shaped-word caching purposes, return it;
// else return 0.
static char16_t
IsBoundarySpace(char16_t aChar, char16_t aNextChar)
{
return (aChar == ' ' || aChar == 0x00A0) && !IsClusterExtender(aNextChar);
if ((aChar == ' ' || aChar == 0x00A0) && !IsClusterExtender(aNextChar)) {
return aChar;
}
return 0;
}
#ifdef __GNUC__
@ -2765,7 +2770,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
for (uint32_t i = 0; i <= aRunLength; ++i) {
T ch = nextCh;
nextCh = (i < aRunLength - 1) ? aString[i + 1] : '\n';
bool boundary = IsBoundarySpace(ch, nextCh);
T boundary = IsBoundarySpace(ch, nextCh);
bool invalid = !boundary && gfxFontGroup::IsInvalidChar(ch);
uint32_t length = i - wordStart;
@ -2827,16 +2832,21 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
gfxTextRunFactory::TEXT_ORIENT_VERTICAL_UPRIGHT :
gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT;
}
if (!aTextRun->SetSpaceGlyphIfSimple(this, aContext,
if (boundary != ' ' ||
!aTextRun->SetSpaceGlyphIfSimple(this, aContext,
aRunStart + i, ch,
orientation))
{
static const uint8_t space = ' ';
orientation)) {
// Currently, the only "boundary" characters we recognize are
// space and no-break space, which are both 8-bit, so we force
// that flag (below). If we ever change IsBoundarySpace, we
// may need to revise this.
// Avoid tautological-constant-out-of-range-compare in 8-bit:
DebugOnly<char16_t> boundary16 = boundary;
NS_ASSERTION(boundary16 < 256, "unexpected boundary!");
gfxShapedWord *sw =
GetShapedWord(aContext,
&space, 1,
gfxShapedWord::HashMix(0, ' '), aRunScript, aVertical,
appUnitsPerDevUnit,
GetShapedWord(aContext, &boundary, 1,
gfxShapedWord::HashMix(0, boundary),
aRunScript, aVertical, appUnitsPerDevUnit,
flags | gfxTextRunFactory::TEXT_IS_8BIT, tp);
if (sw) {
aTextRun->CopyGlyphDataFrom(sw, aRunStart + i);