Bug 1436997 - When variation-font support is enabled, accept new CSS Fonts 4 format-hint strings for variation fonts. r=jwatt

This commit is contained in:
Jonathan Kew 2018-02-15 10:56:42 +00:00
Родитель a403fc3f13
Коммит 252d458bf8
3 изменённых файлов: 37 добавлений и 2 удалений

Просмотреть файл

@ -197,14 +197,23 @@ public:
FLAG_FORMAT_WOFF = 1 << 6,
FLAG_FORMAT_WOFF2 = 1 << 7,
FLAG_FORMAT_OPENTYPE_VARIATIONS = 1 << 8,
FLAG_FORMAT_TRUETYPE_VARIATIONS = 1 << 9,
FLAG_FORMAT_WOFF_VARIATIONS = 1 << 10,
FLAG_FORMAT_WOFF2_VARIATIONS = 1 << 11,
// the common formats that we support everywhere
FLAG_FORMATS_COMMON = FLAG_FORMAT_OPENTYPE |
FLAG_FORMAT_TRUETYPE |
FLAG_FORMAT_WOFF |
FLAG_FORMAT_WOFF2,
FLAG_FORMAT_WOFF2 |
FLAG_FORMAT_OPENTYPE_VARIATIONS |
FLAG_FORMAT_TRUETYPE_VARIATIONS |
FLAG_FORMAT_WOFF_VARIATIONS |
FLAG_FORMAT_WOFF2_VARIATIONS,
// mask of all unused bits, update when adding new formats
FLAG_FORMAT_NOT_USED = ~((1 << 8)-1)
FLAG_FORMAT_NOT_USED = ~((1 << 12)-1)
};

Просмотреть файл

@ -148,6 +148,18 @@ InspectorFontFace::GetFormat(nsAString& aFormat)
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2) {
AppendToFormat(aFormat, "woff2");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_OPENTYPE_VARIATIONS) {
AppendToFormat(aFormat, "opentype-variations");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_TRUETYPE_VARIATIONS) {
AppendToFormat(aFormat, "truetype-variations");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF_VARIATIONS) {
AppendToFormat(aFormat, "woff-variations");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2_VARIATIONS) {
AppendToFormat(aFormat, "woff2-variations");
}
}
}

Просмотреть файл

@ -55,6 +55,7 @@
#endif
#include "nsUTF8Utils.h"
#include "nsDOMNavigationTiming.h"
#include "StylePrefs.h"
using namespace mozilla;
using namespace mozilla::css;
@ -1208,6 +1209,19 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_EOT;
} else if (valueString.LowerCaseEqualsASCII("svg")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_SVG;
} else if (StylePrefs::sFontVariationsEnabled &&
valueString.LowerCaseEqualsASCII("woff-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_WOFF_VARIATIONS;
} else if (StylePrefs::sFontVariationsEnabled &&
Preferences::GetBool(GFX_PREF_WOFF2_ENABLED) &&
valueString.LowerCaseEqualsASCII("woff2-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_WOFF2_VARIATIONS;
} else if (StylePrefs::sFontVariationsEnabled &&
valueString.LowerCaseEqualsASCII("opentype-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_OPENTYPE_VARIATIONS;
} else if (StylePrefs::sFontVariationsEnabled &&
valueString.LowerCaseEqualsASCII("truetype-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_TRUETYPE_VARIATIONS;
} else {
// unknown format specified, mark to distinguish from the
// case where no format hints are specified