bug 820707 - consistently set familyHasItalic flag on GDI font entries, to avoid referring back to the family during font instantiation. r=roc

This commit is contained in:
Jonathan Kew 2012-12-12 14:09:50 +00:00
parent 43b1ee8155
commit 5ed0d42bd7
3 changed files with 20 additions and 18 deletions

View File

@ -660,17 +660,6 @@ public:
// if so set the mIsSimpleFamily flag (defaults to False before we've checked)
void CheckForSimpleFamily();
// check whether the family has any faces that are marked as Italic
bool HasItalicFace() const {
size_t count = mAvailableFonts.Length();
for (size_t i = 0; i < count; ++i) {
if (mAvailableFonts[i] && mAvailableFonts[i]->IsItalic()) {
return true;
}
}
return false;
}
// For memory reporter
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;

View File

@ -285,12 +285,11 @@ gfxGDIFont::Initialize()
// GDI to italicize, because that would use a different face and result
// in a possible glyph ID mismatch between shaping and rendering.
//
// The font entry's mFamilyHasItalicFace flag is needed for user fonts
// We use the mFamilyHasItalicFace flag in the entry in case of user fonts,
// where the *CSS* family may not know about italic faces that are present
// in the *GDI* family, and which GDI would use if we asked it to perform
// the "italicization".
bool useCairoFakeItalic = wantFakeItalic &&
(fe->Family()->HasItalicFace() || fe->mFamilyHasItalicFace);
bool useCairoFakeItalic = wantFakeItalic && fe->mFamilyHasItalicFace;
if (mAdjustedSize == 0.0) {
mAdjustedSize = mStyle.size;

View File

@ -501,8 +501,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
// We can't set the hasItalicFace flag correctly here,
// because we might not have seen the family's italic face(s) yet.
// Later code does _not_ rely on this flag for platform fonts;
// it is only needed for fonts loaded with src:local
// So we'll set that flag for all members after loading all the faces.
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName),
feType, (logFont.lfItalic == 0xFF),
(uint16_t) (logFont.lfWeight), 0,
@ -578,8 +577,23 @@ GDIFontFamily::FindStyleVariations()
ReleaseDC(nullptr, hdc);
if (mIsBadUnderlineFamily)
if (mIsBadUnderlineFamily) {
SetBadUnderlineFonts();
}
// check for existence of italic face(s); if present, set the
// FamilyHasItalic flag on all faces so that we'll know *not*
// to use GDI's fake-italic effect with them
size_t count = mAvailableFonts.Length();
for (size_t i = 0; i < count; ++i) {
if (mAvailableFonts[i]->IsItalic()) {
for (uint32_t j = 0; j < count; ++j) {
static_cast<GDIFontEntry*>(mAvailableFonts[j].get())->
mFamilyHasItalicFace = true;
}
break;
}
}
}
/***************************************************************
@ -767,7 +781,7 @@ gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
lookup->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL,
lookup->mWeight, aProxyEntry->mStretch, nullptr,
lookup->Family()->HasItalicFace());
static_cast<GDIFontEntry*>(lookup)->mFamilyHasItalicFace);
if (!fe)
return nullptr;