Bug 1180415 - initialize downloadable font pattern from FTFace. r=karlt
authorJohn Daggett <jdaggett@mozilla.com>
Wed, 08 Jul 2015 14:44:32 +0900
changeset 251895 f4ab476a4cb9a22d778c22a245cdf53b6f3b0ec9
parent 251858 2a70a0ed2866fd33307f51c476d844f534c7742b
child 251896 42e80a07acd65c866112ee2b5e52f68365cfe4ff
push id29017
push userryanvm@gmail.com
push dateWed, 08 Jul 2015 18:33:30 +0000
treeherdermozilla-central@803a6e097827 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1180415
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1180415 - initialize downloadable font pattern from FTFace. r=karlt
gfx/thebes/gfxFcPlatformFontList.cpp
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -274,25 +274,43 @@ gfxFontconfigFontEntry::gfxFontconfigFon
 }
 
 gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
                                                uint16_t aWeight,
                                                int16_t aStretch,
                                                bool aItalic,
                                                const uint8_t *aData,
                                                FT_Face aFace)
-    : gfxFontEntry(aFaceName), mFontPattern(FcPatternCreate()),
+    : gfxFontEntry(aFaceName),
       mFTFace(aFace), mFTFaceInitialized(true),
       mAspect(0.0), mFontData(aData)
 {
     mWeight = aWeight;
     mItalic = aItalic;
     mStretch = aStretch;
     mIsDataUserFont = true;
 
+    // Use fontconfig to fill out the pattern from the FTFace.
+    // The "file" argument cannot be nullptr (in fontconfig-2.6.0 at
+    // least). The dummy file passed here is removed below.
+    //
+    // When fontconfig scans the system fonts, FcConfigGetBlanks(nullptr)
+    // is passed as the "blanks" argument, which provides that unexpectedly
+    // blank glyphs are elided.  Here, however, we pass nullptr for
+    // "blanks", effectively assuming that, if the font has a blank glyph,
+    // then the author intends any associated character to be rendered
+    // blank.
+    mFontPattern = FcFreeTypeQueryFace(mFTFace, ToFcChar8Ptr(""), 0, nullptr);
+    // given that we have a FT_Face, not really sure this is possible...
+    if (!mFontPattern) {
+        mFontPattern = FcPatternCreate();
+    }
+    FcPatternDel(mFontPattern, FC_FILE);
+    FcPatternDel(mFontPattern, FC_INDEX);
+
     // Make a new pattern and store the face in it so that cairo uses
     // that when creating a cairo font face.
     FcPatternAddFTFace(mFontPattern, FC_FT_FACE, mFTFace);
 
     mUserFontData = new FTUserFontData(mFTFace, mFontData);
 }
 
 gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,