This commit is contained in:
John Daggett 2010-06-10 15:51:47 +09:00
commit e974e41624
2 changed files with 18 additions and 55 deletions

View File

@ -78,7 +78,11 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry,
mSpaceGlyph(0),
mNeedsBold(aNeedsBold)
{
mShaper = new gfxGDIShaper(this);
if (static_cast<GDIFontEntry*>(GetFontEntry())->mForceGDI) {
mShaper = new gfxGDIShaper(this);
} else {
mShaper = new gfxUniscribeShaper(this);
}
}
gfxGDIFont::~gfxGDIFont()
@ -102,31 +106,6 @@ gfxGDIFont::CopyWithAntialiasOption(AntialiasOption anAAOption)
&mStyle, mNeedsBold, anAAOption);
}
static PRBool
UseUniscribe(gfxTextRun *aTextRun,
const PRUnichar *aString,
PRUint32 aRunStart,
PRUint32 aRunLength)
{
PRUint32 flags = aTextRun->GetFlags();
PRBool useGDI;
PRBool isXP = (gfxWindowsPlatform::WindowsOSVersion()
< gfxWindowsPlatform::kWindowsVista);
// bug 561304 - Uniscribe bug produces bad positioning at certain
// font sizes on XP, so default to GDI on XP using logic of 3.6
useGDI = isXP &&
(flags &
(gfxTextRunFactory::TEXT_OPTIMIZE_SPEED |
gfxTextRunFactory::TEXT_IS_RTL)
) == gfxTextRunFactory::TEXT_OPTIMIZE_SPEED;
return !useGDI ||
ScriptIsComplex(aString + aRunStart, aRunLength, SIC_COMPLEX) == S_OK;
}
void
gfxGDIFont::InitTextRun(gfxContext *aContext,
gfxTextRun *aTextRun,
@ -141,32 +120,20 @@ gfxGDIFont::InitTextRun(gfxContext *aContext,
NS_WARNING("invalid font! expect incorrect text rendering");
return;
}
PRBool ok;
GDIFontEntry *fe = static_cast<GDIFontEntry*>(GetFontEntry());
if (UseUniscribe(aTextRun, aString, aRunStart, aRunLength)
&& !fe->mForceGDI)
{
if (!mUniscribeShaper) {
mUniscribeShaper = new gfxUniscribeShaper(this);
}
// use Uniscribe shaping
ok = mUniscribeShaper->InitTextRun(aContext, aTextRun, aString,
aRunStart, aRunLength);
if (ok) {
return;
}
NS_WARNING("uniscribe text shaping failed, switching to GDI shaper");
fe->mForceGDI = PR_TRUE;
}
// use GDI shaping
ok = mShaper->InitTextRun(aContext, aTextRun, aString,
PRBool ok = mShaper->InitTextRun(aContext, aTextRun, aString,
aRunStart, aRunLength);
NS_WARN_IF_FALSE(ok, "text shaping failed, expect broken or missing text");
if (!ok) {
// shaping failed; if we were using uniscribe, fall back to GDI
GDIFontEntry *fe = static_cast<GDIFontEntry*>(GetFontEntry());
if (!fe->mForceGDI) {
NS_WARNING("uniscribe failed, switching to GDI shaper");
fe->mForceGDI = PR_TRUE;
mShaper = new gfxGDIShaper(this);
ok = mShaper->InitTextRun(aContext, aTextRun, aString,
aRunStart, aRunLength);
}
}
NS_WARN_IF_FALSE(ok, "shaper failed, expect broken or missing text");
}
const gfxFont::Metrics&

View File

@ -85,10 +85,6 @@ protected:
void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize);
// mShaper is used for the GDI shaper, mUniscribeShaper
// for the Uniscribe version if needed
nsAutoPtr<gfxFontShaper> mUniscribeShaper;
gfxFloat mAdjustedSize;
HFONT mFont;