зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1454598 - part 2.1 - For system-installed fonts, query FC_VARIABLE to determine if a face has variations rather than instantiating a FT_Face. r=lsalzman
This commit is contained in:
Родитель
b19488bd47
Коммит
13a7aab50e
|
@ -58,6 +58,9 @@ using mozilla::dom::FontPatternListEntry;
|
|||
#ifndef FC_POSTSCRIPT_NAME
|
||||
#define FC_POSTSCRIPT_NAME "postscriptname" /* String */
|
||||
#endif
|
||||
#ifndef FC_VARIABLE
|
||||
#define FC_VARIABLE "variable" /* Bool */
|
||||
#endif
|
||||
|
||||
#define PRINTING_FC_PROPERTY "gfx.printing"
|
||||
|
||||
|
@ -233,6 +236,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
|
|||
: gfxFontEntry(aFaceName), mFontPattern(aFontPattern),
|
||||
mFTFace(nullptr), mFTFaceInitialized(false),
|
||||
mIgnoreFcCharmap(aIgnoreFcCharmap),
|
||||
mHasVariationsInitialized(false),
|
||||
mAspect(0.0), mFontData(nullptr), mLength(0)
|
||||
{
|
||||
// italic
|
||||
|
@ -321,6 +325,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
|
|||
: gfxFontEntry(aFaceName),
|
||||
mFTFace(aFace), mFTFaceInitialized(true),
|
||||
mIgnoreFcCharmap(true),
|
||||
mHasVariationsInitialized(false),
|
||||
mAspect(0.0), mFontData(aData), mLength(aLength)
|
||||
{
|
||||
mWeight = aWeight;
|
||||
|
@ -340,6 +345,7 @@ gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
|
|||
FontSlantStyle aStyle)
|
||||
: gfxFontEntry(aFaceName), mFontPattern(aFontPattern),
|
||||
mFTFace(nullptr), mFTFaceInitialized(false),
|
||||
mHasVariationsInitialized(false),
|
||||
mAspect(0.0), mFontData(nullptr), mLength(0)
|
||||
{
|
||||
mWeight = aWeight;
|
||||
|
@ -1064,11 +1070,28 @@ gfxFontconfigFontEntry::GetFTFace()
|
|||
bool
|
||||
gfxFontconfigFontEntry::HasVariations()
|
||||
{
|
||||
FT_Face face = GetFTFace();
|
||||
if (face) {
|
||||
return face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS;
|
||||
if (mHasVariationsInitialized) {
|
||||
return mHasVariations;
|
||||
}
|
||||
return false;
|
||||
mHasVariationsInitialized = true;
|
||||
mHasVariations = false;
|
||||
|
||||
// For installed fonts, query the fontconfig pattern rather than paying
|
||||
// the cost of loading a FT_Face that we otherwise might never need.
|
||||
if (!IsUserFont() || IsLocalUserFont()) {
|
||||
FcBool variable;
|
||||
if ((FcPatternGetBool(mFontPattern, FC_VARIABLE, 0,
|
||||
&variable) == FcResultMatch) && variable) {
|
||||
mHasVariations = true;
|
||||
}
|
||||
} else {
|
||||
FT_Face face = GetFTFace();
|
||||
if (face) {
|
||||
mHasVariations = face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS;
|
||||
}
|
||||
}
|
||||
|
||||
return mHasVariations;
|
||||
}
|
||||
|
||||
FT_MM_Var*
|
||||
|
|
|
@ -168,6 +168,13 @@ protected:
|
|||
// loaded via @font-face.
|
||||
bool mIgnoreFcCharmap;
|
||||
|
||||
// Whether the face supports variations. For system-installed fonts, we
|
||||
// query fontconfig for this (so they will only work if fontconfig is
|
||||
// recent enough to include support); for downloaded user-fonts we query
|
||||
// the FreeType face.
|
||||
bool mHasVariations;
|
||||
bool mHasVariationsInitialized;
|
||||
|
||||
double mAspect;
|
||||
|
||||
// data font
|
||||
|
|
Загрузка…
Ссылка в новой задаче