зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1419615 - Remove old synthetic-italic support from the GDI font code, so we don't double-slant text now that we have generic support in gfxFont. r=lsalzman
This commit is contained in:
Родитель
dff3e46770
Коммит
620b5d3c57
|
@ -191,28 +191,11 @@ gfxGDIFont::Initialize()
|
|||
|
||||
LOGFONTW logFont;
|
||||
|
||||
// Figure out if we want to do synthetic oblique styling.
|
||||
GDIFontEntry* fe = static_cast<GDIFontEntry*>(GetFontEntry());
|
||||
bool wantFakeItalic = mStyle.style != NS_FONT_STYLE_NORMAL &&
|
||||
fe->IsUpright() && mStyle.allowSyntheticStyle;
|
||||
|
||||
// If the font's family has an actual italic face (but font matching
|
||||
// didn't choose it), we have to use a cairo transform instead of asking
|
||||
// GDI to italicize, because that would use a different face and result
|
||||
// in a possible glyph ID mismatch between shaping and rendering.
|
||||
//
|
||||
// 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->mFamilyHasItalicFace;
|
||||
|
||||
if (mAdjustedSize == 0.0) {
|
||||
mAdjustedSize = mStyle.size;
|
||||
if (mStyle.sizeAdjust > 0.0 && mAdjustedSize > 0.0) {
|
||||
// to implement font-size-adjust, we first create the "unadjusted" font
|
||||
FillLogFont(logFont, mAdjustedSize,
|
||||
wantFakeItalic && !useCairoFakeItalic);
|
||||
FillLogFont(logFont, mAdjustedSize);
|
||||
mFont = ::CreateFontIndirectW(&logFont);
|
||||
|
||||
// initialize its metrics so we can calculate size adjustment
|
||||
|
@ -245,7 +228,7 @@ gfxGDIFont::Initialize()
|
|||
|
||||
// this may end up being zero
|
||||
mAdjustedSize = ROUND(mAdjustedSize);
|
||||
FillLogFont(logFont, mAdjustedSize, wantFakeItalic && !useCairoFakeItalic);
|
||||
FillLogFont(logFont, mAdjustedSize);
|
||||
mFont = ::CreateFontIndirectW(&logFont);
|
||||
|
||||
mMetrics = new gfxFont::Metrics;
|
||||
|
@ -458,8 +441,7 @@ gfxGDIFont::Initialize()
|
|||
}
|
||||
|
||||
void
|
||||
gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize,
|
||||
bool aUseGDIFakeItalic)
|
||||
gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize)
|
||||
{
|
||||
GDIFontEntry *fe = static_cast<GDIFontEntry*>(GetFontEntry());
|
||||
|
||||
|
@ -480,11 +462,6 @@ gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize,
|
|||
}
|
||||
|
||||
fe->FillLogFont(&aLogFont, weight, aSize);
|
||||
|
||||
// If GDI synthetic italic is wanted, force the lfItalic field to true
|
||||
if (aUseGDIFakeItalic) {
|
||||
aLogFont.lfItalic = 1;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
|
@ -87,10 +87,11 @@ protected:
|
|||
|
||||
void Initialize(); // creates metrics and Cairo fonts
|
||||
|
||||
// Fill the given LOGFONT record according to our style, but don't adjust
|
||||
// the lfItalic field if we're going to use a cairo transform for fake
|
||||
// italics.
|
||||
void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize, bool aUseGDIFakeItalic);
|
||||
// Fill the given LOGFONT record according to our size.
|
||||
// (Synthetic italic is *not* handled here, because GDI may not reliably
|
||||
// use the face we expect if we tweak the lfItalic field, and because we
|
||||
// have generic support for this in gfxFont::Draw instead.)
|
||||
void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize);
|
||||
|
||||
HFONT mFont;
|
||||
cairo_font_face_t *mFontFace;
|
||||
|
|
|
@ -117,12 +117,10 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
|
|||
gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle, uint16_t aWeight,
|
||||
int16_t aStretch,
|
||||
gfxUserFontData *aUserFontData,
|
||||
bool aFamilyHasItalicFace)
|
||||
gfxUserFontData *aUserFontData)
|
||||
: gfxFontEntry(aFaceName),
|
||||
mFontType(aFontType),
|
||||
mForceGDI(false),
|
||||
mFamilyHasItalicFace(aFamilyHasItalicFace),
|
||||
mUnicodeRanges()
|
||||
{
|
||||
mUserFontData.reset(aUserFontData);
|
||||
|
@ -141,7 +139,7 @@ GDIFontEntry::Clone() const
|
|||
{
|
||||
MOZ_ASSERT(!IsUserFont(), "we can only clone installed fonts!");
|
||||
return new GDIFontEntry(Name(), mFontType, mStyle, mWeight, mStretch,
|
||||
nullptr, mFamilyHasItalicFace);
|
||||
nullptr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -396,14 +394,12 @@ GDIFontEntry::CreateFontEntry(const nsAString& aName,
|
|||
gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle,
|
||||
uint16_t aWeight, int16_t aStretch,
|
||||
gfxUserFontData* aUserFontData,
|
||||
bool aFamilyHasItalicFace)
|
||||
gfxUserFontData* aUserFontData)
|
||||
{
|
||||
// jtdfix - need to set charset, unicode ranges, pitch/family
|
||||
|
||||
GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aStyle,
|
||||
aWeight, aStretch, aUserFontData,
|
||||
aFamilyHasItalicFace);
|
||||
aWeight, aStretch, aUserFontData);
|
||||
|
||||
return fe;
|
||||
}
|
||||
|
@ -486,7 +482,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
|
|||
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName),
|
||||
feType, italicStyle,
|
||||
(uint16_t) (logFont.lfWeight), 0,
|
||||
nullptr, false);
|
||||
nullptr);
|
||||
if (!fe)
|
||||
return 1;
|
||||
|
||||
|
@ -548,29 +544,6 @@ GDIFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
|
|||
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
|
||||
|
||||
// If we ignored italic face(s), we should mark this has italic face.
|
||||
bool hasItalicFace = ShouldIgnoreItalicStyle(mName);
|
||||
|
||||
if (!hasItalicFace) {
|
||||
for (RefPtr<gfxFontEntry>& fontEntry : mAvailableFonts) {
|
||||
if (fontEntry->IsItalic()) {
|
||||
hasItalicFace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasItalicFace) {
|
||||
for (RefPtr<gfxFontEntry>& fontEntry : mAvailableFonts) {
|
||||
static_cast<GDIFontEntry*>(fontEntry.get())->
|
||||
mFamilyHasItalicFace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
|
@ -753,8 +726,7 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName,
|
|||
// 'Arial Vet' which can be used as a key in GDI font lookups).
|
||||
GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(),
|
||||
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
|
||||
lookup->mStyle, lookup->mWeight, aStretch, nullptr,
|
||||
static_cast<GDIFontEntry*>(lookup)->mFamilyHasItalicFace);
|
||||
lookup->mStyle, lookup->mWeight, aStretch, nullptr);
|
||||
|
||||
if (!fe)
|
||||
return nullptr;
|
||||
|
@ -896,7 +868,7 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName,
|
|||
|
||||
GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName,
|
||||
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
|
||||
aStyle, w, aStretch, winUserFontData, false);
|
||||
aStyle, w, aStretch, winUserFontData);
|
||||
|
||||
if (fe) {
|
||||
fe->mIsDataUserFont = true;
|
||||
|
|
|
@ -165,8 +165,7 @@ public:
|
|||
gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle,
|
||||
uint16_t aWeight, int16_t aStretch,
|
||||
gfxUserFontData* aUserFontData,
|
||||
bool aFamilyHasItalicFace);
|
||||
gfxUserFontData* aUserFontData);
|
||||
|
||||
// create a font entry for a font referenced by its fullname
|
||||
static GDIFontEntry* LoadLocalFont(const nsAString& aFontName,
|
||||
|
@ -175,13 +174,7 @@ public:
|
|||
uint8_t aStyle);
|
||||
|
||||
gfxWindowsFontType mFontType;
|
||||
bool mForceGDI : 1;
|
||||
|
||||
// For src:local user-fonts, we keep track of whether the platform family
|
||||
// contains an italic face, because in this case we can't safely ask GDI
|
||||
// to create synthetic italics (oblique) via the LOGFONT.
|
||||
// (For other types of font, this is just set to false.)
|
||||
bool mFamilyHasItalicFace : 1;
|
||||
bool mForceGDI;
|
||||
|
||||
gfxSparseBitSet mUnicodeRanges;
|
||||
|
||||
|
@ -190,7 +183,7 @@ protected:
|
|||
|
||||
GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
|
||||
uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
|
||||
gfxUserFontData *aUserFontData, bool aFamilyHasItalicFace);
|
||||
gfxUserFontData *aUserFontData);
|
||||
|
||||
void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче