bug 635640 - force font metrics of Arial Black to match the main Arial family; r=Bas

This commit is contained in:
Jonathan Kew 2011-03-23 23:01:14 -04:00
parent ed99bde8e4
commit 559ac56c3a
3 changed files with 29 additions and 1 deletions

View File

@ -200,11 +200,35 @@ gfxDWriteFont::GetMetrics()
return *mMetrics;
}
PRBool
gfxDWriteFont::GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics)
{
gfxFontStyle style(mStyle);
style.weight = 700;
PRBool needsBold;
gfxFontEntry *fe = mFontEntry->Family()->FindFontForStyle(style, needsBold);
if (!fe || fe == mFontEntry) {
return PR_FALSE;
}
nsRefPtr<gfxFont> font = fe->FindOrMakeFont(&style, needsBold);
gfxDWriteFont *dwFont = static_cast<gfxDWriteFont*>(font.get());
dwFont->mFontFace->GetMetrics(aFontMetrics);
return PR_TRUE;
}
void
gfxDWriteFont::ComputeMetrics()
{
DWRITE_FONT_METRICS fontMetrics;
mFontFace->GetMetrics(&fontMetrics);
if (!(mFontEntry->Weight() == 900 &&
!mFontEntry->IsUserFont() &&
mFontEntry->FamilyName().EqualsLiteral("Arial") &&
GetFakeMetricsForArialBlack(&fontMetrics)))
{
mFontFace->GetMetrics(&fontMetrics);
}
if (mStyle.sizeAdjust != 0.0) {
gfxFloat aspect = (gfxFloat)fontMetrics.xHeight /

View File

@ -90,6 +90,8 @@ protected:
virtual void CreatePlatformShaper();
PRBool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics);
void ComputeMetrics();
PRBool HasBitmapStrikeForSize(PRUint32 aSize);

View File

@ -223,6 +223,8 @@ public:
// unique name for the face, *not* the family
const nsString& Name() const { return mName; }
gfxFontFamily* Family() const { return mFamily; }
PRUint16 Weight() const { return mWeight; }
PRInt16 Stretch() const { return mStretch; }