bug 589682 - ignore GDEF table in italic faces of times new roman, to work around font bug. r=jdaggett
authorJonathan Kew <jfkthame@gmail.com>
Tue, 19 Apr 2011 09:01:21 +0100
changeset 68289 b895bc3e7a248cea5668f57a4f6c85fadb4cf007
parent 68288 b17d5f8022afe88b3971309530b64ed8945c6e35
child 68290 1c819504b0bbf65ad7c5260609ad6f07c89734ab
push id19575
push userjkew@mozilla.com
push dateTue, 19 Apr 2011 08:02:36 +0000
treeherdermozilla-central@1c819504b0bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs589682
milestone6.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 589682 - ignore GDEF table in italic faces of times new roman, to work around font bug. r=jdaggett
gfx/thebes/gfxFont.h
gfx/thebes/gfxHarfBuzzShaper.cpp
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -204,16 +204,17 @@ public:
 
     gfxFontEntry(const nsAString& aName, gfxFontFamily *aFamily = nsnull,
                  PRBool aIsStandardFace = PR_FALSE) : 
         mName(aName), mItalic(PR_FALSE), mFixedPitch(PR_FALSE),
         mIsProxy(PR_FALSE), mIsValid(PR_TRUE), 
         mIsBadUnderlineFont(PR_FALSE), mIsUserFont(PR_FALSE),
         mIsLocalUserFont(PR_FALSE), mStandardFace(aIsStandardFace),
         mSymbolFont(PR_FALSE),
+        mIgnoreGDEF(PR_FALSE),
         mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL),
         mHasCmapTable(PR_FALSE),
         mCmapInitialized(PR_FALSE),
         mUVSOffset(0), mUVSData(nsnull),
         mUserFontData(nsnull),
         mLanguageOverride(NO_FONT_LANGUAGE_OVERRIDE),
         mFamily(aFamily)
     { }
@@ -229,16 +230,17 @@ public:
     PRInt16 Stretch() const { return mStretch; }
 
     PRBool IsUserFont() const { return mIsUserFont; }
     PRBool IsLocalUserFont() const { return mIsLocalUserFont; }
     PRBool IsFixedPitch() const { return mFixedPitch; }
     PRBool IsItalic() const { return mItalic; }
     PRBool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above
     PRBool IsSymbolFont() const { return mSymbolFont; }
+    PRBool IgnoreGDEF() const { return mIgnoreGDEF; }
 
     inline PRBool HasCmapTable() {
         if (!mCmapInitialized) {
             ReadCMAP();
         }
         return mHasCmapTable;
     }
 
@@ -304,16 +306,17 @@ public:
     PRPackedBool     mFixedPitch  : 1;
     PRPackedBool     mIsProxy     : 1;
     PRPackedBool     mIsValid     : 1;
     PRPackedBool     mIsBadUnderlineFont : 1;
     PRPackedBool     mIsUserFont  : 1;
     PRPackedBool     mIsLocalUserFont  : 1;
     PRPackedBool     mStandardFace : 1;
     PRPackedBool     mSymbolFont  : 1;
+    PRPackedBool     mIgnoreGDEF  : 1;
 
     PRUint16         mWeight;
     PRInt16          mStretch;
 
     PRPackedBool     mHasCmapTable;
     PRPackedBool     mCmapInitialized;
     gfxSparseBitSet  mCharacterMap;
     PRUint32         mUVSOffset;
@@ -333,16 +336,17 @@ protected:
     gfxFontEntry() :
         mItalic(PR_FALSE), mFixedPitch(PR_FALSE),
         mIsProxy(PR_FALSE), mIsValid(PR_TRUE), 
         mIsBadUnderlineFont(PR_FALSE),
         mIsUserFont(PR_FALSE),
         mIsLocalUserFont(PR_FALSE),
         mStandardFace(PR_FALSE),
         mSymbolFont(PR_FALSE),
+        mIgnoreGDEF(PR_FALSE),
         mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL),
         mHasCmapTable(PR_FALSE),
         mCmapInitialized(PR_FALSE),
         mUVSOffset(0), mUVSData(nsnull),
         mUserFontData(nsnull),
         mLanguageOverride(NO_FONT_LANGUAGE_OVERRIDE),
         mFamily(nsnull)
     { }
@@ -484,16 +488,23 @@ public:
     const nsString& Name() { return mName; }
 
     virtual void LocalizedName(nsAString& aLocalizedName);
     virtual PRBool HasOtherFamilyNames();
     
     nsTArray<nsRefPtr<gfxFontEntry> >& GetFontList() { return mAvailableFonts; }
     
     void AddFontEntry(nsRefPtr<gfxFontEntry> aFontEntry) {
+        // bug 589682 - set the IgnoreGDEF flag on entries for Italic faces
+        // of Times New Roman, because of buggy table in those fonts
+        if (aFontEntry->IsItalic() && !aFontEntry->IsUserFont() &&
+            Name().EqualsLiteral("Times New Roman"))
+        {
+            aFontEntry->mIgnoreGDEF = PR_TRUE;
+        }
         mAvailableFonts.AppendElement(aFontEntry);
         aFontEntry->SetFamily(this);
     }
 
     // note that the styles for this family have been added
     void SetHasStyles(PRBool aHasStyles) { mHasStyles = aHasStyles; }
 
     // choose a specific face to match a style using CSS font matching
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -100,17 +100,27 @@ gfxHarfBuzzShaper::~gfxHarfBuzzShaper()
  */
 
 // callback for HarfBuzz to get a font table (in hb_blob_t form)
 // from the shaper (passed as aUserData)
 static hb_blob_t *
 HBGetTable(hb_tag_t aTag, void *aUserData)
 {
     gfxHarfBuzzShaper *shaper = static_cast<gfxHarfBuzzShaper*>(aUserData);
-    return shaper->GetFont()->GetFontTable(aTag);
+    gfxFont *font = shaper->GetFont();
+
+    // bug 589682 - ignore the GDEF table in buggy fonts (applies to
+    // Italic and BoldItalic faces of Times New Roman)
+    if (aTag == TRUETYPE_TAG('G','D','E','F') &&
+        font->GetFontEntry()->IgnoreGDEF())
+    {
+        return nsnull;
+    }
+
+    return font->GetFontTable(aTag);
 }
 
 /*
  * HarfBuzz font callback functions; user_data is a ptr to a
  * FontCallbackData struct
  */
 
 struct FontCallbackData {