Bug 833169 - initialize family name in pango font entries. r=roc
authorJohn Daggett <jdaggett@mozilla.com>
Mon, 18 Feb 2013 11:23:01 +0900
changeset 122200 da82798eb2751aca52f3802a6540db180a591c20
parent 122199 820dff9bdc55add3299ad566fb44070cd762b29b
child 122201 fa40088b0833af00e3d3b064cddf7c2eba0114c2
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs833169
milestone21.0a1
Bug 833169 - initialize family name in pango font entries. r=roc
gfx/thebes/gfxPangoFonts.cpp
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -324,16 +324,22 @@ public:
         : gfxFcFontEntry(aName), mFontFace(aFontFace)
     {
         cairo_font_face_reference(mFontFace);
         cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, this, NULL);
         mPatterns.AppendElement();
         // mPatterns is an nsAutoTArray with 1 space always available, so the
         // AppendElement always succeeds.
         mPatterns[0] = aFontPattern;
+
+        FcChar8 *name;
+        if (FcPatternGetString(aFontPattern,
+                               FC_FAMILY, 0, &name) == FcResultMatch) {
+            mFamilyName = NS_ConvertUTF8toUTF16((const char*)name);
+        }
     }
 
     ~gfxSystemFcFontEntry()
     {
         cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, NULL, NULL);
         cairo_font_face_destroy(mFontFace);
     }
 private:
@@ -381,16 +387,17 @@ class gfxUserFcFontEntry : public gfxFcF
 protected:
     gfxUserFcFontEntry(const gfxProxyFontEntry &aProxyEntry)
         : gfxFcFontEntry(aProxyEntry.Name())
     {
         mItalic = aProxyEntry.mItalic;
         mWeight = aProxyEntry.mWeight;
         mStretch = aProxyEntry.mStretch;
         mIsUserFont = true;
+        mFamilyName = aProxyEntry.mFamilyName;
     }
 
     // Helper function to change a pattern so that it matches the CSS style
     // descriptors and so gets properly sorted in font selection.  This also
     // avoids synthetic style effects being added by the renderer when the
     // style of the font itself does not match the descriptor provided by the
     // author.
     void AdjustPatternToCSS(FcPattern *aPattern);