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
Родитель 6a97734fc7
Коммит 573a197e03
1 изменённых файлов: 19 добавлений и 11 удалений

Просмотреть файл

@ -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,19 @@ 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.
NS_ASSERTION(uint32_t(boundary) < 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);