Bug 387703. Make all-8bit Unicode text take the Xft fast path if that's enabled, to ensure it's displayed consistently. r=pavlov

This commit is contained in:
roc+@cs.cmu.edu 2007-07-16 15:49:10 -07:00
parent fdc82745ab
commit 5d094d6109
2 changed files with 22 additions and 6 deletions

View File

@ -139,8 +139,15 @@ protected:
// ****** Textrun glyph conversion helpers ******
/**
* Fill in the glyph-runs for the textrun.
* @param aTake8BitPath the text contains only characters below 0x100
* (TEXT_IS_8BIT can return false when the characters are all below 0x100
* but stored in UTF16 format)
*/
void InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text,
PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength);
PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength,
PRBool aTake8BitPath);
// Returns NS_ERROR_FAILURE if there's a missing glyph
nsresult SetGlyphs(gfxTextRun *aTextRun, gfxPangoFont *aFont,
const gchar *aUTF8, PRUint32 aUTF8Length,

View File

@ -814,7 +814,7 @@ gfxPangoFontGroup::MakeTextRun(const PRUint8 *aString, PRUint32 aLength,
// We don't need to send an override character here, the characters must be all
// LTR
const gchar *utf8Chars = reinterpret_cast<const gchar*>(aString);
InitTextRun(run, utf8Chars, aLength, 0);
InitTextRun(run, utf8Chars, aLength, 0, PR_TRUE);
} else {
const char *chars = reinterpret_cast<const char*>(aString);
// XXX this could be more efficient.
@ -825,7 +825,7 @@ gfxPangoFontGroup::MakeTextRun(const PRUint8 *aString, PRUint32 aLength,
nsCAutoString utf8;
PRInt32 headerLen = AppendDirectionalIndicatorUTF8(isRTL, utf8);
AppendUTF16toUTF8(unicodeString, utf8);
InitTextRun(run, utf8.get(), utf8.Length(), headerLen);
InitTextRun(run, utf8.get(), utf8.Length(), headerLen, PR_TRUE);
}
return run;
}
@ -843,19 +843,28 @@ gfxPangoFontGroup::MakeTextRun(const PRUnichar *aString, PRUint32 aLength,
nsCAutoString utf8;
PRInt32 headerLen = AppendDirectionalIndicatorUTF8(run->IsRightToLeft(), utf8);
AppendUTF16toUTF8(Substring(aString, aString + aLength), utf8);
InitTextRun(run, utf8.get(), utf8.Length(), headerLen);
PRUint32 allBits = 0;
#if defined(ENABLE_XFT_FAST_PATH_8BIT)
PRUint32 i;
for (i = 0; i < aLength; ++i) {
allBits |= aString[i];
}
#endif
PRBool is8Bit = (allBits & 0xFF00) == 0;
InitTextRun(run, utf8.get(), utf8.Length(), headerLen, is8Bit);
return run;
}
void
gfxPangoFontGroup::InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text,
PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength)
PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength,
PRBool aTake8BitPath)
{
#if defined(ENABLE_XFT_FAST_PATH_ALWAYS)
CreateGlyphRunsXft(aTextRun, aUTF8Text + aUTF8HeaderLength, aUTF8Length - aUTF8HeaderLength);
#else
#if defined(ENABLE_XFT_FAST_PATH_8BIT)
if (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_IS_8BIT) {
if (aTake8BitPath) {
CreateGlyphRunsXft(aTextRun, aUTF8Text + aUTF8HeaderLength, aUTF8Length - aUTF8HeaderLength);
return;
}