Bug 312156 - Make gfxFont::HasCharacter work for Pango fonts. r=roc
authorMats Palmgren <matspal@gmail.com>
Wed, 22 Jun 2011 20:11:47 +0200
changeset 71548 a24270f2784306cb5674b29bf732743b1b74b920
parent 71542 e302cef502f617c76d3a3d1a40b21f6d60cb5139
child 71549 847fc92f36eeea85ef92cb4600b37240fde730d0
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs312156
milestone7.0a1
Bug 312156 - Make gfxFont::HasCharacter work for Pango fonts. r=roc
gfx/thebes/gfxPangoFonts.cpp
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -156,16 +156,24 @@ FindFunctionSymbol(const char *name)
     PRFuncPtr result = PR_FindFunctionSymbolAndLibrary(name, &lib);
     if (lib) {
         PR_UnloadLibrary(lib);
     }
 
     return result;
 }
 
+static PRBool HasChar(FcPattern *aFont, FcChar32 wc)
+{
+    FcCharSet *charset = NULL;
+    FcPatternGetCharSet(aFont, FC_CHARSET, 0, &charset);
+
+    return charset && FcCharSetHasChar(charset, wc);
+}
+
 /**
  * gfxFcFontEntry:
  *
  * An abstract base class of for gfxFontEntry implementations used by
  * gfxFcFont and gfxUserFontSet.
  */
 
 class gfxFcFontEntry : public gfxFontEntry {
@@ -194,16 +202,27 @@ public:
     // gfxFcFontEntries in families; just read the name from fontconfig
     virtual nsString FamilyName() const;
 
     // override the gfxFontEntry impl to read the name from fontconfig
     // instead of trying to get the 'name' table, as we don't implement
     // GetFontTable() here
     virtual nsString RealFaceName();
 
+    // This is needed to make gfxFontEntry::HasCharacter(aCh) work.
+    virtual PRBool TestCharacterMap(PRUint32 aCh)
+    {
+        for (PRUint32 i = 0; i < mPatterns.Length(); ++i) {
+            if (HasChar(mPatterns[i], aCh)) {
+                return PR_TRUE;
+            }
+        }
+        return PR_FALSE;
+    }
+
 protected:
     gfxFcFontEntry(const nsAString& aName)
         : gfxFontEntry(aName),
           mSkipHarfBuzz(PR_FALSE), mSkipGraphiteCheck(PR_FALSE)
     {
     }
 
     // One pattern is the common case and some subclasses rely on successful
@@ -1629,24 +1648,16 @@ gfxFcFontSet::GetFontPatternAt(PRUint32 
             // finished with this font set
             mFcFontSet.reset();
         }
     }
 
     return mFonts[i].mPattern;
 }
 
-static PRBool HasChar(FcPattern *aFont, FcChar32 wc)
-{
-    FcCharSet *charset = NULL;
-    FcPatternGetCharSet(aFont, FC_CHARSET, 0, &charset);
-
-    return charset && FcCharSetHasChar(charset, wc);
-}
-
 /**
  * gfxPangoFontMap: An implementation of a PangoFontMap.
  *
  * This is a PangoFcFontMap for gfxPangoFcFont.  It will only ever be used if
  * some day pango_cairo_font_map_get_default() does not return a
  * PangoFcFontMap.
  */