diff --git a/gfx/thebes/src/gfxGDIFont.cpp b/gfx/thebes/src/gfxGDIFont.cpp index d9f6b383619..ab38f78113c 100644 --- a/gfx/thebes/src/gfxGDIFont.cpp +++ b/gfx/thebes/src/gfxGDIFont.cpp @@ -78,7 +78,11 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry, mSpaceGlyph(0), mNeedsBold(aNeedsBold) { - mShaper = new gfxGDIShaper(this); + if (static_cast(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(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(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& diff --git a/gfx/thebes/src/gfxGDIFont.h b/gfx/thebes/src/gfxGDIFont.h index 7bddf125ee2..68633c571e8 100644 --- a/gfx/thebes/src/gfxGDIFont.h +++ b/gfx/thebes/src/gfxGDIFont.h @@ -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 mUniscribeShaper; - gfxFloat mAdjustedSize; HFONT mFont;