bug 871453 - part 2 - support font-synthesis options through the platform-font-list backends. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-06-19 08:08:58 +01:00
parent 176feefe44
commit 330a007108
6 changed files with 19 additions and 11 deletions

View File

@ -176,8 +176,9 @@ gfxDWriteFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
continue;
}
if (font->GetSimulations() & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
// We don't want these.
if (font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
// We don't want these in the font list; we'll apply simulations
// on the fly when appropriate.
continue;
}
@ -1642,8 +1643,9 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
continue;
}
if (dwFont->GetSimulations() & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
// We don't want these.
if (dwFont->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
// We don't want these in the font list; we'll apply simulations
// on the fly when appropriate.
continue;
}

View File

@ -89,7 +89,7 @@ gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry,
nsresult rv;
DWRITE_FONT_SIMULATIONS sims = DWRITE_FONT_SIMULATIONS_NONE;
if ((GetStyle()->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) &&
!fe->IsItalic()) {
!fe->IsItalic() && GetStyle()->allowSyntheticStyle) {
// For this we always use the font_matrix for uniformity. Not the
// DWrite simulation.
mNeedsOblique = true;

View File

@ -188,7 +188,8 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle)
// synthetic oblique by skewing via the font matrix
bool needsOblique = !IsItalic() &&
(aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE));
(aStyle->style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) &&
aStyle->allowSyntheticStyle;
if (needsOblique) {
const double kSkewFactor = 0.25;

View File

@ -1072,7 +1072,8 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle,
// If the family has only one face, we simply return it; no further checking needed
if (mAvailableFonts.Length() == 1) {
gfxFontEntry *fe = mAvailableFonts[0];
aNeedsSyntheticBold = wantBold && !fe->IsBold();
aNeedsSyntheticBold =
wantBold && !fe->IsBold() && aFontStyle.allowSyntheticWeight;
return fe;
}
@ -1113,7 +1114,9 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle,
// check remaining faces in order of preference to find the first that actually exists
fe = mAvailableFonts[order[trial]];
if (fe) {
aNeedsSyntheticBold = wantBold && !fe->IsBold();
aNeedsSyntheticBold =
wantBold && !fe->IsBold() &&
aFontStyle.allowSyntheticWeight;
return fe;
}
}
@ -1168,7 +1171,8 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle,
NS_ASSERTION(matchFE,
"weight mapping should always find at least one font in a family");
if (!matchFE->IsBold() && baseWeight >= 6)
if (!matchFE->IsBold() && baseWeight >= 6 &&
aFontStyle.allowSyntheticWeight)
{
aNeedsSyntheticBold = true;
}

View File

@ -184,7 +184,7 @@ gfxGDIFont::Initialize()
GDIFontEntry* fe = static_cast<GDIFontEntry*>(GetFontEntry());
bool wantFakeItalic =
(mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) &&
!fe->IsItalic();
!fe->IsItalic() && 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

View File

@ -64,7 +64,8 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl
bool needsOblique =
(mFontEntry != nullptr) &&
(!mFontEntry->IsItalic() &&
(mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)));
(mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE))) &&
mStyle.allowSyntheticStyle;
if (needsOblique) {
double skewfactor = (needsOblique ? Fix2X(kATSItalicQDSkew) : 0);