Bug 1449605 - part 1 - Rearrange thebes font code so that the decision whether to apply synthetic-bold is deferred until actually instantiating a font, not made during the font-matching process. r=jwatt
authorJonathan Kew <jkew@mozilla.com>
Tue, 01 May 2018 10:30:50 +0100
changeset 472562 a4096171bfdbea9956e8afd4d74ac0b7c89506b1
parent 472561 788d134870102c3333a4564db7eef0d4ea8c52ba
child 472563 d6ab3049b56061284e9e0e10410588766c7245d9
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1449605
milestone61.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 1449605 - part 1 - Rearrange thebes font code so that the decision whether to apply synthetic-bold is deferred until actually instantiating a font, not made during the font-matching process. r=jwatt This rearranges how synthetic-bold use is determined in the font selection & rendering code. Previously, we would decide during the font-selection algorithm whether we need to apply synthetic-bold to the chosen face, and then pass that decision through the fontgroup (storing it in the FamilyFace entries of the mFonts array there) down to the actual rendering code that instantiates fonts from the faces (font entries) we've selected. That became a problem for variation fonts because in the case of a user font, we may not have downloaded the resource yet, so we just have a "user font container" entry, which carries the descriptors from the @font-face rule and will fetch the actual resource when needed. But in the case of a @font-face rule without a weight descriptor, we don't actually know at font-selection time whether the face will support "true" bold (via a variation axis) or not, so we can't reliably make the right decision about applying synthetic bold. So we now defer that decision until we actually instantiate a platform font object to shape/measure/draw text. At that point, we have the requested style and we also have the real font resource, so we can easily determine whether fake-bold is required. (This patch should not result in any visible behavior change; that will come in a second patch now that the architecture supports it.)
gfx/thebes/gfxDWriteFontList.cpp
gfx/thebes/gfxDWriteFontList.h
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxDWriteFonts.h
gfx/thebes/gfxFT2FontBase.cpp
gfx/thebes/gfxFT2FontBase.h
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFT2FontList.h
gfx/thebes/gfxFT2Fonts.cpp
gfx/thebes/gfxFT2Fonts.h
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFcPlatformFontList.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontEntry.cpp
gfx/thebes/gfxFontEntry.h
gfx/thebes/gfxGDIFont.cpp
gfx/thebes/gfxGDIFont.h
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxGDIFontList.h
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxMacFont.h
gfx/thebes/gfxMacPlatformFontList.h
gfx/thebes/gfxMacPlatformFontList.mm
gfx/thebes/gfxPlatformFontList.cpp
gfx/thebes/gfxPlatformFontList.h
gfx/thebes/gfxTextRun.cpp
gfx/thebes/gfxTextRun.h
gfx/thebes/gfxUserFontSet.cpp
gfx/thebes/gfxUserFontSet.h
layout/style/FontFaceSet.cpp
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -663,52 +663,52 @@ gfxDWriteFontEntry::GetVariationAxes(nsT
 void
 gfxDWriteFontEntry::GetVariationInstances(
     nsTArray<gfxFontVariationInstance>& aInstances)
 {
     gfxFontUtils::GetVariationInstances(this, aInstances);
 }
 
 gfxFont *
-gfxDWriteFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle,
-                                       bool aNeedsBold)
+gfxDWriteFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle)
 {
+    bool needsBold = aFontStyle->NeedsSyntheticBold(this);
     DWRITE_FONT_SIMULATIONS sims =
-        aNeedsBold ? DWRITE_FONT_SIMULATIONS_BOLD : DWRITE_FONT_SIMULATIONS_NONE;
+        needsBold ? DWRITE_FONT_SIMULATIONS_BOLD : DWRITE_FONT_SIMULATIONS_NONE;
     if (HasVariations() && !aFontStyle->variationSettings.IsEmpty()) {
         // If we need to apply variations, we can't use the cached mUnscaledFont
         // or mUnscaledFontBold here.
         // XXX todo: consider caching a small number of variation instances?
         RefPtr<IDWriteFontFace> fontFace;
         nsresult rv = CreateFontFace(getter_AddRefs(fontFace),
                                      aFontStyle,
                                      sims);
         if (NS_FAILED(rv)) {
             return nullptr;
         }
         RefPtr<UnscaledFontDWrite> unscaledFont =
             new UnscaledFontDWrite(fontFace, mIsSystemFont ? mFont : nullptr, sims);
-        return new gfxDWriteFont(unscaledFont, this, aFontStyle, aNeedsBold);
+        return new gfxDWriteFont(unscaledFont, this, aFontStyle);
     }
 
     ThreadSafeWeakPtr<UnscaledFontDWrite>& unscaledFontPtr =
-        aNeedsBold ? mUnscaledFontBold : mUnscaledFont;
+        needsBold ? mUnscaledFontBold : mUnscaledFont;
     RefPtr<UnscaledFontDWrite> unscaledFont(unscaledFontPtr);
     if (!unscaledFont) {
         RefPtr<IDWriteFontFace> fontFace;
         nsresult rv = CreateFontFace(getter_AddRefs(fontFace), aFontStyle, sims);
         if (NS_FAILED(rv)) {
             return nullptr;
         }
         unscaledFont =
             new UnscaledFontDWrite(fontFace,
                                    mIsSystemFont ? mFont : nullptr, sims);
         unscaledFontPtr = unscaledFont;
     }
-    return new gfxDWriteFont(unscaledFont, this, aFontStyle, aNeedsBold);
+    return new gfxDWriteFont(unscaledFont, this, aFontStyle);
 }
 
 nsresult
 gfxDWriteFontEntry::CreateFontFace(IDWriteFontFace **aFontFace,
                                    const gfxFontStyle* aFontStyle,
                                    DWRITE_FONT_SIMULATIONS aSimulations)
 {
     // Convert an OpenType font tag from our uint32_t representation
@@ -1612,18 +1612,17 @@ gfxDWriteFontList::PlatformGlobalFontFal
     hr = fallbackLayout->Draw(nullptr, mFallbackRenderer, 50.0f, 50.0f);
     if (FAILED(hr)) {
         return nullptr;
     }
 
     gfxFontFamily *family = FindFamily(mFallbackRenderer->FallbackFamilyName());
     if (family) {
         gfxFontEntry *fontEntry;
-        bool needsBold;  // ignored in the system fallback case
-        fontEntry = family->FindFontForStyle(*aMatchStyle, needsBold);
+        fontEntry = family->FindFontForStyle(*aMatchStyle);
         if (fontEntry && fontEntry->HasCharacter(aCh)) {
             *aMatchedFamily = family;
             return fontEntry;
         }
         Telemetry::Accumulate(Telemetry::BAD_FALLBACK_FONT, true);
     }
 
     return nullptr;
--- a/gfx/thebes/gfxDWriteFontList.h
+++ b/gfx/thebes/gfxDWriteFontList.h
@@ -212,18 +212,17 @@ public:
 
 protected:
     friend class gfxDWriteFont;
     friend class gfxDWriteFontList;
 
     virtual nsresult CopyFontTable(uint32_t aTableTag,
                                    nsTArray<uint8_t>& aBuffer) override;
 
-    virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                        bool aNeedsBold);
+    virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle);
     
     nsresult CreateFontFace(
         IDWriteFontFace **aFontFace,
         const gfxFontStyle* aFontStyle = nullptr,
         DWRITE_FONT_SIMULATIONS aSimulations = DWRITE_FONT_SIMULATIONS_NONE);
 
     static bool InitLogFont(IDWriteFont *aFont, LOGFONTW *aLogFont);
 
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -67,23 +67,21 @@ UsingClearType()
     return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // gfxDWriteFont
 gfxDWriteFont::gfxDWriteFont(const RefPtr<UnscaledFontDWrite>& aUnscaledFont,
                              gfxFontEntry *aFontEntry,
                              const gfxFontStyle *aFontStyle,
-                             bool aNeedsBold,
                              AntialiasOption anAAOption)
     : gfxFont(aUnscaledFont, aFontEntry, aFontStyle, anAAOption)
     , mCairoFontFace(nullptr)
     , mMetrics(nullptr)
     , mSpaceGlyph(0)
-    , mNeedsBold(aNeedsBold)
     , mUseSubpixelPositions(false)
     , mAllowManualShowGlyphs(true)
     , mAzureScaledFontUsedClearType(false)
 {
     mFontFace = aUnscaledFont->GetFontFace();
 
     // If the IDWriteFontFace1 interface is available, we can use that for
     // faster glyph width retrieval.
@@ -118,40 +116,39 @@ gfxDWriteFont::UpdateClearTypeUsage()
     }
 }
 
 UniquePtr<gfxFont>
 gfxDWriteFont::CopyWithAntialiasOption(AntialiasOption anAAOption)
 {
     auto entry = static_cast<gfxDWriteFontEntry*>(mFontEntry.get());
     RefPtr<UnscaledFontDWrite> unscaledFont = static_cast<UnscaledFontDWrite*>(mUnscaledFont.get());
-    return MakeUnique<gfxDWriteFont>(unscaledFont, entry, &mStyle, mNeedsBold, anAAOption);
+    return MakeUnique<gfxDWriteFont>(unscaledFont, entry, &mStyle, anAAOption);
 }
 
 const gfxFont::Metrics&
 gfxDWriteFont::GetHorizontalMetrics()
 {
     return *mMetrics;
 }
 
 bool
 gfxDWriteFont::GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics)
 {
     gfxFontStyle style(mStyle);
     style.weight = FontWeight(700);
-    bool needsBold;
 
     gfxFontEntry* fe =
         gfxPlatformFontList::PlatformFontList()->
-            FindFontForFamily(NS_LITERAL_STRING("Arial"), &style, needsBold);
+            FindFontForFamily(NS_LITERAL_STRING("Arial"), &style);
     if (!fe || fe == mFontEntry) {
         return false;
     }
 
-    RefPtr<gfxFont> font = fe->FindOrMakeFont(&style, needsBold);
+    RefPtr<gfxFont> font = fe->FindOrMakeFont(&style);
     gfxDWriteFont *dwFont = static_cast<gfxDWriteFont*>(font.get());
     dwFont->mFontFace->GetMetrics(aFontMetrics);
 
     return true;
 }
 
 void
 gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
--- a/gfx/thebes/gfxDWriteFonts.h
+++ b/gfx/thebes/gfxDWriteFonts.h
@@ -23,17 +23,16 @@
  * \brief Class representing a font face for a font entry.
  */
 class gfxDWriteFont : public gfxFont 
 {
 public:
     gfxDWriteFont(const RefPtr<mozilla::gfx::UnscaledFontDWrite>& aUnscaledFont,
                   gfxFontEntry *aFontEntry,
                   const gfxFontStyle *aFontStyle,
-                  bool aNeedsBold = false,
                   AntialiasOption = kAntialiasDefault);
     ~gfxDWriteFont();
 
     static void UpdateClearTypeUsage();
 
     mozilla::UniquePtr<gfxFont>
     CopyWithAntialiasOption(AntialiasOption anAAOption) override;
 
@@ -96,17 +95,16 @@ protected:
 
     Metrics *mMetrics;
 
     // cache of glyph widths in 16.16 fixed-point pixels
     mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,int32_t>> mGlyphWidths;
 
     uint32_t mSpaceGlyph;
 
-    bool mNeedsBold;
     bool mUseSubpixelPositions;
     bool mAllowManualShowGlyphs;
 
     // Used to record the sUseClearType setting at the time mAzureScaledFont
     // was set up, so we can tell if it's stale and needs to be re-created.
     bool mAzureScaledFontUsedClearType;
 
     static bool sUseClearType;
--- a/gfx/thebes/gfxFT2FontBase.cpp
+++ b/gfx/thebes/gfxFT2FontBase.cpp
@@ -21,22 +21,22 @@
 #define FT_FACE_FLAG_COLOR ( 1L << 14 )
 #endif
 
 using namespace mozilla::gfx;
 
 gfxFT2FontBase::gfxFT2FontBase(const RefPtr<UnscaledFontFreeType>& aUnscaledFont,
                                cairo_scaled_font_t *aScaledFont,
                                gfxFontEntry *aFontEntry,
-                               const gfxFontStyle *aFontStyle,
-                               bool aEmbolden)
+                               const gfxFontStyle *aFontStyle)
     : gfxFont(aUnscaledFont, aFontEntry, aFontStyle, kAntialiasDefault, aScaledFont)
     , mSpaceGlyph(0)
-    , mEmbolden(aEmbolden)
 {
+    mEmbolden = aFontStyle->NeedsSyntheticBold(aFontEntry);
+
     cairo_scaled_font_reference(mScaledFont);
 
     InitMetrics();
 }
 
 gfxFT2FontBase::~gfxFT2FontBase()
 {
     cairo_scaled_font_destroy(mScaledFont);
--- a/gfx/thebes/gfxFT2FontBase.h
+++ b/gfx/thebes/gfxFT2FontBase.h
@@ -14,18 +14,17 @@
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 
 class gfxFT2FontBase : public gfxFont {
 public:
     gfxFT2FontBase(const RefPtr<mozilla::gfx::UnscaledFontFreeType>& aUnscaledFont,
                    cairo_scaled_font_t *aScaledFont,
                    gfxFontEntry *aFontEntry,
-                   const gfxFontStyle *aFontStyle,
-                   bool aEmbolden);
+                   const gfxFontStyle *aFontStyle);
     virtual ~gfxFT2FontBase();
 
     uint32_t GetGlyph(uint32_t aCharCode);
     void GetGlyphExtents(uint32_t aGlyph,
                          cairo_text_extents_t* aExtents);
     virtual uint32_t GetSpaceGlyph() override;
     virtual bool ProvidesGetGlyph() const override { return true; }
     virtual uint32_t GetGlyph(uint32_t unicode,
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -226,17 +226,17 @@ FT2FontEntry::Clone() const
     fe->mFTFontIndex = mFTFontIndex;
     fe->mWeightRange = mWeightRange;
     fe->mStretchRange = mStretchRange;
     fe->mStyleRange = mStyleRange;
     return fe;
 }
 
 gfxFont*
-FT2FontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold)
+FT2FontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle)
 {
     cairo_scaled_font_t *scaledFont = CreateScaledFont(aFontStyle);
     if (!scaledFont) {
         return nullptr;
     }
 
     RefPtr<UnscaledFontFreeType> unscaledFont(mUnscaledFont);
     if (!unscaledFont) {
@@ -244,17 +244,17 @@ FT2FontEntry::CreateFontInstance(const g
             mFilename.IsEmpty() ?
                 new UnscaledFontFreeType(mFTFace) :
                 new UnscaledFontFreeType(mFilename.BeginReading(),
                                          mFTFontIndex);
         mUnscaledFont = unscaledFont;
     }
 
     gfxFont *font = new gfxFT2Font(unscaledFont, scaledFont, this,
-                                   aFontStyle, aNeedsBold);
+                                   aFontStyle);
     cairo_scaled_font_destroy(scaledFont);
     return font;
 }
 
 /* static */
 FT2FontEntry*
 FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
                               WeightRange aWeight,
--- a/gfx/thebes/gfxFT2FontList.h
+++ b/gfx/thebes/gfxFT2FontList.h
@@ -62,18 +62,17 @@ public:
     // aLength is the length of aFontData.
     static FT2FontEntry* 
     CreateFontEntry(FT_Face aFace,
                     const char *aFilename, uint8_t aIndex,
                     const nsAString& aName,
                     const uint8_t* aFontData = nullptr,
                     uint32_t aLength = 0);
 
-    virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                        bool aNeedsBold) override;
+    gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle) override;
 
     // Create (if necessary) and return the cairo_font_face for this font.
     // This may fail and return null, so caller must be prepared to handle this.
     // If a style is passed, any variationSettings in the style will be applied
     // to the resulting font face.
     cairo_font_face_t *CairoFontFace(const gfxFontStyle *aStyle = nullptr);
 
     // Create a cairo_scaled_font for this face, with the given style.
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -159,24 +159,23 @@ gfxFT2Font::AddRange(const char16_t *aTe
                                    &details);
         }
     }
 }
 
 gfxFT2Font::gfxFT2Font(const RefPtr<UnscaledFontFreeType>& aUnscaledFont,
                        cairo_scaled_font_t *aCairoFont,
                        FT2FontEntry *aFontEntry,
-                       const gfxFontStyle *aFontStyle,
-                       bool aNeedsBold)
-    : gfxFT2FontBase(aUnscaledFont, aCairoFont, aFontEntry, aFontStyle, false)
+                       const gfxFontStyle *aFontStyle)
+    : gfxFT2FontBase(aUnscaledFont, aCairoFont, aFontEntry, aFontStyle)
     , mCharGlyphCache(32)
 {
     NS_ASSERTION(mFontEntry, "Unable to find font entry for font.  Something is whack.");
     // TODO: use FreeType emboldening instead of multi-strike?
-    mApplySyntheticBold = aNeedsBold;
+    mApplySyntheticBold = aFontStyle->NeedsSyntheticBold(aFontEntry);
 }
 
 gfxFT2Font::~gfxFT2Font()
 {
 }
 
 already_AddRefed<ScaledFont>
 gfxFT2Font::GetScaledFont(DrawTarget *aTarget)
--- a/gfx/thebes/gfxFT2Fonts.h
+++ b/gfx/thebes/gfxFT2Fonts.h
@@ -17,18 +17,17 @@
 
 class FT2FontEntry;
 
 class gfxFT2Font : public gfxFT2FontBase {
 public: // new functions
     gfxFT2Font(const RefPtr<mozilla::gfx::UnscaledFontFreeType>& aUnscaledFont,
                cairo_scaled_font_t *aCairoFont,
                FT2FontEntry *aFontEntry,
-               const gfxFontStyle *aFontStyle,
-               bool aNeedsBold);
+               const gfxFontStyle *aFontStyle);
     virtual ~gfxFT2Font ();
 
     FT2FontEntry *GetFontEntry();
 
     virtual already_AddRefed<mozilla::gfx::ScaledFont>
     GetScaledFont(DrawTarget *aTarget) override;
 
     virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -565,17 +565,17 @@ gfxFontconfigFontEntry::GetAspect()
     }
 
     // default to aspect = 0.5 if the code below fails
     mAspect = 0.5;
 
     // create a font to calculate x-height / em-height
     gfxFontStyle s;
     s.size = 100.0; // pick large size to avoid possible hinting artifacts
-    RefPtr<gfxFont> font = FindOrMakeFont(&s, false);
+    RefPtr<gfxFont> font = FindOrMakeFont(&s);
     if (font) {
         const gfxFont::Metrics& metrics =
             font->GetMetrics(gfxFont::eHorizontal);
 
         // The factor of 0.1 ensures that xHeight is sane so fonts don't
         // become huge.  Strictly ">" ensures that xHeight and emHeight are
         // not both zero.
         if (metrics.xHeight > 0.1 * metrics.emHeight) {
@@ -747,20 +747,19 @@ static void
 ReleaseFTUserFontData(void* aData)
 {
   static_cast<FTUserFontData*>(aData)->Release();
 }
 
 cairo_scaled_font_t*
 gfxFontconfigFontEntry::CreateScaledFont(FcPattern* aRenderPattern,
                                          gfxFloat aAdjustedSize,
-                                         const gfxFontStyle *aStyle,
-                                         bool aNeedsBold)
+                                         const gfxFontStyle *aStyle)
 {
-    if (aNeedsBold) {
+    if (aStyle->NeedsSyntheticBold(this)) {
         FcPatternAddBool(aRenderPattern, FC_EMBOLDEN, FcTrue);
     }
 
     // will synthetic oblique be applied using a transform?
     bool needsOblique = IsUpright() &&
                         aStyle->style != FontSlantStyle::Normal() &&
                         aStyle->allowSyntheticStyle;
 
@@ -958,18 +957,17 @@ ChooseFontSize(gfxFontconfigFontEntry* a
             scalable) {
             return requestedSize;
         }
     }
     return bestSize;
 }
 
 gfxFont*
-gfxFontconfigFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                           bool aNeedsBold)
+gfxFontconfigFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle)
 {
     nsAutoRef<FcPattern> pattern(FcPatternCreate());
     if (!pattern) {
         NS_WARNING("Failed to create Fontconfig pattern for font instance");
         return nullptr;
     }
 
     double size = ChooseFontSize(this, *aFontStyle);
@@ -1010,17 +1008,17 @@ gfxFontconfigFontEntry::CreateFontInstan
         FcPatternDestroy(fontPattern);
     }
     if (!renderPattern) {
         NS_WARNING("Failed to prepare Fontconfig pattern for font instance");
         return nullptr;
     }
 
     cairo_scaled_font_t* scaledFont =
-        CreateScaledFont(renderPattern, size, aFontStyle, aNeedsBold);
+        CreateScaledFont(renderPattern, size, aFontStyle);
 
     const FcChar8* file = ToFcChar8Ptr("");
     int index = 0;
     if (!mFontData) {
         if (FcPatternGetString(renderPattern, FC_FILE, 0,
                                const_cast<FcChar8**>(&file)) != FcResultMatch ||
             FcPatternGetInteger(renderPattern, FC_INDEX, 0, &index) != FcResultMatch) {
             NS_WARNING("No file in Fontconfig pattern for font instance");
@@ -1036,17 +1034,17 @@ gfxFontconfigFontEntry::CreateFontInstan
                 new UnscaledFontFontconfig(face) :
                 new UnscaledFontFontconfig(ToCharPtr(file), index);
         mUnscaledFontCache.Add(unscaledFont);
     }
 
     gfxFont* newFont =
         new gfxFontconfigFont(unscaledFont, scaledFont,
                               renderPattern, size,
-                              this, aFontStyle, aNeedsBold);
+                              this, aFontStyle);
     cairo_scaled_font_destroy(scaledFont);
 
     return newFont;
 }
 
 FT_Face
 gfxFontconfigFontEntry::GetFTFace()
 {
@@ -1271,22 +1269,20 @@ SizeDistance(gfxFontconfigFontEntry* aEn
         // Reject any non-scalable fonts that are not within tolerance.
         return kRejectDistance;
     }
 }
 
 void
 gfxFontconfigFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
                                               nsTArray<gfxFontEntry*>& aFontEntryList,
-                                              bool& aNeedsSyntheticBold,
                                               bool aIgnoreSizeTolerance)
 {
     gfxFontFamily::FindAllFontsForStyle(aFontStyle,
                                         aFontEntryList,
-                                        aNeedsSyntheticBold,
                                         aIgnoreSizeTolerance);
 
     if (!mHasNonScalableFaces) {
         return;
     }
 
     // Iterate over the the available fonts while compacting any groups
     // of unscalable fonts with matching styles into a single entry
@@ -1418,19 +1414,18 @@ gfxFontconfigFontFamily::AddFacesToFontL
     }
 }
 
 gfxFontconfigFont::gfxFontconfigFont(const RefPtr<UnscaledFontFontconfig>& aUnscaledFont,
                                      cairo_scaled_font_t *aScaledFont,
                                      FcPattern *aPattern,
                                      gfxFloat aAdjustedSize,
                                      gfxFontEntry *aFontEntry,
-                                     const gfxFontStyle *aFontStyle,
-                                     bool aNeedsBold)
-    : gfxFT2FontBase(aUnscaledFont, aScaledFont, aFontEntry, aFontStyle, aNeedsBold)
+                                     const gfxFontStyle *aFontStyle)
+    : gfxFT2FontBase(aUnscaledFont, aScaledFont, aFontEntry, aFontStyle)
     , mPattern(aPattern)
 {
     mAdjustedSize = aAdjustedSize;
 }
 
 gfxFontconfigFont::~gfxFontconfigFont()
 {
 }
--- a/gfx/thebes/gfxFcPlatformFontList.h
+++ b/gfx/thebes/gfxFcPlatformFontList.h
@@ -128,25 +128,23 @@ public:
     void ForgetHBFace() override;
     void ReleaseGrFace(gr_face* aFace) override;
 
     double GetAspect();
 
 protected:
     virtual ~gfxFontconfigFontEntry();
 
-    gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                bool aNeedsBold) override;
+    gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle) override;
 
     // helper method for creating cairo font from pattern
     cairo_scaled_font_t*
     CreateScaledFont(FcPattern* aRenderPattern,
                      gfxFloat aAdjustedSize,
-                     const gfxFontStyle *aStyle,
-                     bool aNeedsBold);
+                     const gfxFontStyle *aStyle);
 
     // override to pull data from FTFace
     virtual nsresult
     CopyFontTable(uint32_t aTableTag,
                   nsTArray<uint8_t>& aBuffer) override;
 
     // if HB or GR faces are gone, close down the FT_Face
     void MaybeReleaseFTFace();
@@ -228,17 +226,16 @@ public:
     void SetFamilyContainsAppFonts(bool aContainsAppFonts)
     {
         mContainsAppFonts = aContainsAppFonts;
     }
 
     void
     FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
                          nsTArray<gfxFontEntry*>& aFontEntryList,
-                         bool& aNeedsSyntheticBold,
                          bool aIgnoreSizeTolerance) override;
 
     bool FilterForFontList(nsAtom* aLangGroup,
                            const nsACString& aGeneric) const final {
         return SupportsLangGroup(aLangGroup);
     }
 
 protected:
@@ -256,18 +253,17 @@ protected:
 
 class gfxFontconfigFont : public gfxFT2FontBase {
 public:
     gfxFontconfigFont(const RefPtr<mozilla::gfx::UnscaledFontFontconfig> &aUnscaledFont,
                       cairo_scaled_font_t *aScaledFont,
                       FcPattern *aPattern,
                       gfxFloat aAdjustedSize,
                       gfxFontEntry *aFontEntry,
-                      const gfxFontStyle *aFontStyle,
-                      bool aNeedsBold);
+                      const gfxFontStyle *aFontStyle);
 
     virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; }
     virtual FcPattern *GetPattern() const { return mPattern; }
 
     virtual already_AddRefed<mozilla::gfx::ScaledFont>
     GetScaledFont(DrawTarget *aTarget) override;
 
 private:
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -3518,28 +3518,26 @@ gfxFont::InitFakeSmallCapsRun(DrawTarget
 
 gfxFont*
 gfxFont::GetSmallCapsFont()
 {
     gfxFontStyle style(*GetStyle());
     style.size *= SMALL_CAPS_SCALE_FACTOR;
     style.variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
     gfxFontEntry* fe = GetFontEntry();
-    bool needsBold = style.weight >= FontWeight(600) && !fe->IsBold();
-    return fe->FindOrMakeFont(&style, needsBold, mUnicodeRangeMap);
+    return fe->FindOrMakeFont(&style, mUnicodeRangeMap);
 }
 
 gfxFont*
 gfxFont::GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel)
 {
     gfxFontStyle style(*GetStyle());
     style.AdjustForSubSuperscript(aAppUnitsPerDevPixel);
     gfxFontEntry* fe = GetFontEntry();
-    bool needsBold = style.weight >= FontWeight(600) && !fe->IsBold();
-    return fe->FindOrMakeFont(&style, needsBold, mUnicodeRangeMap);
+    return fe->FindOrMakeFont(&style, mUnicodeRangeMap);
 }
 
 static void
 DestroyRefCairo(void* aData)
 {
   cairo_t* refCairo = static_cast<cairo_t*>(aData);
   MOZ_ASSERT(refCairo);
   cairo_destroy(refCairo);
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -192,16 +192,23 @@ struct gfxFontStyle {
     }
 
     PLDHashNumber Hash() const;
 
     // Adjust this style to simulate sub/superscript (as requested in the
     // variantSubSuper field) using size and baselineOffset instead.
     void AdjustForSubSuperscript(int32_t aAppUnitsPerDevPixel);
 
+    // Should this style cause the given font entry to use synthetic bold?
+    bool NeedsSyntheticBold(gfxFontEntry* aFontEntry) const {
+        return weight.IsBold() &&
+               allowSyntheticWeight &&
+               !aFontEntry->IsBold();
+    }
+
     bool Equals(const gfxFontStyle& other) const {
         return
             (*reinterpret_cast<const uint64_t*>(&size) ==
              *reinterpret_cast<const uint64_t*>(&other.size)) &&
             (style == other.style) &&
             (weight == other.weight) &&
             (stretch == other.stretch) &&
             (variantCaps == other.variantCaps) &&
--- a/gfx/thebes/gfxFontEntry.cpp
+++ b/gfx/thebes/gfxFontEntry.cpp
@@ -240,25 +240,24 @@ gfxFontEntry::RealFaceName()
             return name;
         }
     }
     return Name();
 }
 
 gfxFont*
 gfxFontEntry::FindOrMakeFont(const gfxFontStyle *aStyle,
-                             bool aNeedsBold,
                              gfxCharacterMap* aUnicodeRangeMap)
 {
     // the font entry name is the psname, not the family name
     gfxFont* font =
         gfxFontCache::GetCache()->Lookup(this, aStyle, aUnicodeRangeMap);
 
     if (!font) {
-        gfxFont *newFont = CreateFontInstance(aStyle, aNeedsBold);
+        gfxFont *newFont = CreateFontInstance(aStyle);
         if (!newFont) {
             return nullptr;
         }
         if (!newFont->Valid()) {
             delete newFont;
             return nullptr;
         }
         font = newFont;
@@ -1278,22 +1277,20 @@ gfxFontFamily::HasOtherFamilyNames()
     if (!mOtherFamilyNamesInitialized) {
         ReadOtherFamilyNames(gfxPlatformFontList::PlatformFontList());  // sets mHasOtherFamilyNames
     }
     return mHasOtherFamilyNames;
 }
 
 gfxFontEntry*
 gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, 
-                                bool& aNeedsSyntheticBold,
                                 bool aIgnoreSizeTolerance)
 {
     AutoTArray<gfxFontEntry*,4> matched;
-    FindAllFontsForStyle(aFontStyle, matched, aNeedsSyntheticBold,
-                         aIgnoreSizeTolerance);
+    FindAllFontsForStyle(aFontStyle, matched, aIgnoreSizeTolerance);
     if (!matched.IsEmpty()) {
         return matched[0];
     }
     return nullptr;
 }
 
 // style distance ==> [0,500]
 static inline double
@@ -1458,61 +1455,55 @@ WeightStyleStretchDistance(gfxFontEntry*
     // so we multiply the stretch and style values to make them dominate
     // the result
     return stretchDist * 1.0e8 + styleDist * 1.0e4 + weightDist;
 }
 
 void
 gfxFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
                                     nsTArray<gfxFontEntry*>& aFontEntryList,
-                                    bool& aNeedsSyntheticBold,
                                     bool aIgnoreSizeTolerance)
 {
     if (!mHasStyles) {
         FindStyleVariations(); // collect faces for the family, if not already done
     }
 
     NS_ASSERTION(mAvailableFonts.Length() > 0, "font family with no faces!");
     NS_ASSERTION(aFontEntryList.IsEmpty(), "non-empty fontlist passed in");
 
-    aNeedsSyntheticBold = false;
-
-    bool wantBold = aFontStyle.weight >= FontWeight(600);
     gfxFontEntry *fe = nullptr;
 
     // If the family has only one face, we simply return it; no further
     // checking needed
     uint32_t count = mAvailableFonts.Length();
     if (count == 1) {
         fe = mAvailableFonts[0];
-        aNeedsSyntheticBold =
-            wantBold && !fe->IsBold() && aFontStyle.allowSyntheticWeight;
         aFontEntryList.AppendElement(fe);
         return;
     }
 
     // Most families are "simple", having just Regular/Bold/Italic/BoldItalic,
     // or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts,
     // stored in the above order; note that some of the entries may be nullptr.
     // We can then pick the required entry based on whether the request is for
     // bold or non-bold, italic or non-italic, without running the more complex
     // matching algorithm used for larger families with many weights and/or widths.
 
     if (mIsSimpleFamily) {
         // Family has no more than the "standard" 4 faces, at fixed indexes;
         // calculate which one we want.
         // Note that we cannot simply return it as not all 4 faces are necessarily present.
+        bool wantBold = aFontStyle.weight >= FontWeight(600);
         bool wantItalic = !aFontStyle.style.IsNormal();
         uint8_t faceIndex = (wantItalic ? kItalicMask : 0) |
                             (wantBold ? kBoldMask : 0);
 
         // if the desired style is available, return it directly
         fe = mAvailableFonts[faceIndex];
         if (fe) {
-            // no need to set aNeedsSyntheticBold here as we matched the boldness request
             aFontEntryList.AppendElement(fe);
             return;
         }
 
         // order to check fallback faces in a simple family, depending on requested style
         static const uint8_t simpleFallbacks[4][3] = {
             { kBoldFaceIndex, kItalicFaceIndex, kBoldItalicFaceIndex },   // fallbacks for Regular
             { kRegularFaceIndex, kBoldItalicFaceIndex, kItalicFaceIndex },// Bold
@@ -1520,19 +1511,16 @@ gfxFontFamily::FindAllFontsForStyle(cons
             { kItalicFaceIndex, kBoldFaceIndex, kRegularFaceIndex }       // BoldItalic
         };
         const uint8_t *order = simpleFallbacks[faceIndex];
 
         for (uint8_t trial = 0; trial < 3; ++trial) {
             // check remaining faces in order of preference to find the first that actually exists
             fe = mAvailableFonts[order[trial]];
             if (fe) {
-                aNeedsSyntheticBold =
-                    wantBold && !fe->IsBold() &&
-                    aFontStyle.allowSyntheticWeight;
                 aFontEntryList.AppendElement(fe);
                 return;
             }
         }
 
         // this can't happen unless we have totally broken the font-list manager!
         NS_NOTREACHED("no face found in simple font family!");
     }
@@ -1569,20 +1557,16 @@ gfxFontFamily::FindAllFontsForStyle(cons
             matched = fe;
         }
     }
 
     NS_ASSERTION(matched, "didn't match a font within a family");
 
     if (matched) {
         aFontEntryList.AppendElement(matched);
-        if (!matched->IsBold() && aFontStyle.weight >= FontWeight(600) &&
-            aFontStyle.allowSyntheticWeight) {
-            aNeedsSyntheticBold = true;
-        }
     }
 }
 
 void
 gfxFontFamily::CheckForSimpleFamily()
 {
     // already checked this family
     if (mIsSimpleFamily) {
@@ -1703,21 +1687,20 @@ void
 gfxFontFamily::FindFontForChar(GlobalFontMatch *aMatchData)
 {
     if (mFamilyCharacterMapInitialized && !TestCharacterMap(aMatchData->mCh)) {
         // none of the faces in the family support the required char,
         // so bail out immediately
         return;
     }
 
-    bool needsBold;
     gfxFontEntry *fe =
         FindFontForStyle(aMatchData->mStyle ? *aMatchData->mStyle
                                             : gfxFontStyle(),
-                         needsBold, true);
+                         true);
 
     if (fe && !fe->SkipDuringSystemFallback()) {
         float rank = 0;
 
         if (fe->HasCharacter(aMatchData->mCh)) {
             rank += RANK_MATCHED_CMAP;
             aMatchData->mCount++;
 
--- a/gfx/thebes/gfxFontEntry.h
+++ b/gfx/thebes/gfxFontEntry.h
@@ -282,17 +282,16 @@ public:
 
     // Return a font instance for a particular style. This may be a newly-
     // created instance, or a font already in the global cache.
     // We can't return a UniquePtr here, because we may be returning a shared
     // cached instance; but we also don't return already_AddRefed, because
     // the caller may only need to use the font temporarily and doesn't need
     // a strong reference.
     gfxFont* FindOrMakeFont(const gfxFontStyle *aStyle,
-                            bool aNeedsBold,
                             gfxCharacterMap* aUnicodeRangeMap = nullptr);
 
     // Get an existing font table cache entry in aBlob if it has been
     // registered, or return false if not.  Callers must call
     // hb_blob_destroy on aBlob if true is returned.
     //
     // Note that some gfxFont implementations may not call this at all,
     // if it is more efficient to get the table from the OS at that level.
@@ -470,18 +469,17 @@ protected:
     friend class gfxSingleFaceMacFontFamily;
     friend class gfxUserFontEntry;
 
     gfxFontEntry();
 
     // Protected destructor, to discourage deletion outside of Release():
     virtual ~gfxFontEntry();
 
-    virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                        bool aNeedsBold) = 0;
+    virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle) = 0;
 
     virtual void CheckForGraphiteTables();
 
     // Copy a font table into aBuffer.
     // The caller will be responsible for ownership of the data.
     virtual nsresult CopyFontTable(uint32_t aTableTag,
                                    nsTArray<uint8_t>& aBuffer) {
         NS_NOTREACHED("forgot to override either GetFontTable or CopyFontTable?");
@@ -728,26 +726,22 @@ public:
 
     // note that the styles for this family have been added
     bool HasStyles() { return mHasStyles; }
     void SetHasStyles(bool aHasStyles) { mHasStyles = aHasStyles; }
 
     // choose a specific face to match a style using CSS font matching
     // rules (weight matching occurs here).  may return a face that doesn't
     // precisely match (e.g. normal face when no italic face exists).
-    // aNeedsSyntheticBold is set to true when synthetic bolding is
-    // needed, false otherwise
     gfxFontEntry *FindFontForStyle(const gfxFontStyle& aFontStyle, 
-                                   bool& aNeedsSyntheticBold,
                                    bool aIgnoreSizeTolerance = false);
 
     virtual void
     FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
                          nsTArray<gfxFontEntry*>& aFontEntryList,
-                         bool& aNeedsSyntheticBold,
                          bool aIgnoreSizeTolerance = false);
 
     // checks for a matching font within the family
     // used as part of the font fallback process
     void FindFontForChar(GlobalFontMatch *aMatchData);
 
     // checks all fonts for a matching font within the family
     void SearchAllFontsForChar(GlobalFontMatch *aMatchData);
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -38,26 +38,26 @@ GetCairoAntialiasOption(gfxFont::Antiali
         return CAIRO_ANTIALIAS_GRAY;
     case gfxFont::kAntialiasSubpixel:
         return CAIRO_ANTIALIAS_SUBPIXEL;
     }
 }
 
 gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry,
                        const gfxFontStyle *aFontStyle,
-                       bool aNeedsBold,
                        AntialiasOption anAAOption)
     : gfxFont(nullptr, aFontEntry, aFontStyle, anAAOption),
       mFont(nullptr),
       mFontFace(nullptr),
       mMetrics(nullptr),
       mSpaceGlyph(0),
-      mNeedsBold(aNeedsBold),
       mScriptCache(nullptr)
 {
+    mNeedsBold = aFontStyle->NeedsSyntheticBold(aFontEntry);
+
     Initialize();
 
     if (mFont) {
         mUnscaledFont = aFontEntry->LookupUnscaledFont(mFont);
     }
 }
 
 gfxGDIFont::~gfxGDIFont()
@@ -76,17 +76,17 @@ gfxGDIFont::~gfxGDIFont()
     }
     delete mMetrics;
 }
 
 UniquePtr<gfxFont>
 gfxGDIFont::CopyWithAntialiasOption(AntialiasOption anAAOption)
 {
     auto entry = static_cast<GDIFontEntry*>(mFontEntry.get());
-    return MakeUnique<gfxGDIFont>(entry, &mStyle, mNeedsBold, anAAOption);
+    return MakeUnique<gfxGDIFont>(entry, &mStyle, anAAOption);
 }
 
 bool
 gfxGDIFont::ShapeText(DrawTarget     *aDrawTarget,
                       const char16_t *aText,
                       uint32_t        aOffset,
                       uint32_t        aLength,
                       Script          aScript,
--- a/gfx/thebes/gfxGDIFont.h
+++ b/gfx/thebes/gfxGDIFont.h
@@ -16,17 +16,16 @@
 #include "cairo.h"
 #include "usp10.h"
 
 class gfxGDIFont : public gfxFont
 {
 public:
     gfxGDIFont(GDIFontEntry *aFontEntry,
                const gfxFontStyle *aFontStyle,
-               bool aNeedsBold,
                AntialiasOption anAAOption = kAntialiasDefault);
 
     virtual ~gfxGDIFont();
 
     HFONT GetHFONT() { return mFont; }
 
     cairo_font_face_t* CairoFontFace() { return mFontFace; }
 
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -203,19 +203,19 @@ GDIFontEntry::ReadCMAP(FontInfoData *aFo
                        NS_ConvertUTF16toUTF8(mName).get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
     }
 
     return rv;
 }
 
 gfxFont *
-GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, bool aNeedsBold)
+GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle)
 {
-    return new gfxGDIFont(this, aFontStyle, aNeedsBold);
+    return new gfxGDIFont(this, aFontStyle);
 }
 
 nsresult
 GDIFontEntry::CopyFontTable(uint32_t aTableTag, nsTArray<uint8_t>& aBuffer)
 {
     if (!IsTrueType()) {
         return NS_ERROR_FAILURE;
     }
--- a/gfx/thebes/gfxGDIFontList.h
+++ b/gfx/thebes/gfxGDIFontList.h
@@ -185,18 +185,17 @@ protected:
     friend class gfxGDIFont;
 
     GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
                  SlantStyleRange aStyle, WeightRange aWeight, StretchRange aStretch,
                  gfxUserFontData *aUserFontData);
 
     void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);
 
-    virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                        bool aNeedsBold) override;
+    gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle) override;
 
     virtual nsresult CopyFontTable(uint32_t aTableTag,
                                    nsTArray<uint8_t>& aBuffer) override;
 
     already_AddRefed<mozilla::gfx::UnscaledFontGDI> LookupUnscaledFont(HFONT aFont);
 
     LOGFONTW mLogFont;
 
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -20,26 +20,25 @@
 
 #include "cairo-quartz.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 gfxMacFont::gfxMacFont(const RefPtr<UnscaledFontMac>& aUnscaledFont,
                        MacOSFontEntry *aFontEntry,
-                       const gfxFontStyle *aFontStyle,
-                       bool aNeedsBold)
+                       const gfxFontStyle *aFontStyle)
     : gfxFont(aUnscaledFont, aFontEntry, aFontStyle),
       mCGFont(nullptr),
       mCTFont(nullptr),
       mFontFace(nullptr),
       mFontSmoothingBackgroundColor(aFontStyle->fontSmoothingBackgroundColor),
       mVariationFont(aFontEntry->HasVariations())
 {
-    mApplySyntheticBold = aNeedsBold;
+    mApplySyntheticBold = aFontStyle->NeedsSyntheticBold(aFontEntry);
 
     if (mVariationFont) {
         CGFontRef baseFont = aUnscaledFont->GetFont();
         if (!baseFont) {
             mIsValid = false;
             return;
         }
 
--- a/gfx/thebes/gfxMacFont.h
+++ b/gfx/thebes/gfxMacFont.h
@@ -14,18 +14,17 @@
 #include "mozilla/gfx/UnscaledFontMac.h"
 
 class MacOSFontEntry;
 
 class gfxMacFont : public gfxFont
 {
 public:
     gfxMacFont(const RefPtr<mozilla::gfx::UnscaledFontMac>& aUnscaledFont,
-               MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle,
-               bool aNeedsBold);
+               MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle);
 
     virtual ~gfxMacFont();
 
     CGFontRef GetCGFontRef() const { return mCGFont; }
 
     /* overrides for the pure virtual methods in gfxFont */
     uint32_t GetSpaceGlyph() override {
         return mSpaceGlyph;
--- a/gfx/thebes/gfxMacPlatformFontList.h
+++ b/gfx/thebes/gfxMacPlatformFontList.h
@@ -75,18 +75,17 @@ public:
 
     bool SupportsOpenTypeFeature(Script aScript, uint32_t aFeatureTag) override;
 
     // Return the tracking (in font units) to be applied for the given size.
     // (This is a floating-point number because of possible interpolation.)
     float TrackingForCSSPx(float aPointSize) const;
 
 protected:
-    gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle,
-                                bool aNeedsBold) override;
+    gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle) override;
 
     bool HasFontTable(uint32_t aTableTag) override;
 
     // Helper for HasTrackingTable; check/parse the table and cache pointers
     // to the subtables we need. Returns false on failure, in which case the
     // table is unusable.
     bool ParseTrakTable();
 
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -263,29 +263,29 @@ MacOSFontEntry::ReadCMAP(FontInfoData *a
                        NS_ConvertUTF16toUTF8(mName).get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
     }
 
     return rv;
 }
 
 gfxFont*
-MacOSFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold)
+MacOSFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle)
 {
     RefPtr<UnscaledFontMac> unscaledFont(mUnscaledFont);
     if (!unscaledFont) {
         CGFontRef baseFont = GetFontRef();
         if (!baseFont) {
             return nullptr;
         }
         unscaledFont = new UnscaledFontMac(baseFont, mIsDataUserFont);
         mUnscaledFont = unscaledFont;
     }
 
-    return new gfxMacFont(unscaledFont, this, aFontStyle, aNeedsBold);
+    return new gfxMacFont(unscaledFont, this, aFontStyle);
 }
 
 bool
 MacOSFontEntry::HasVariations()
 {
     if (!mHasVariationsInitialized) {
         mHasVariationsInitialized = true;
         mHasVariations =
@@ -1486,21 +1486,19 @@ gfxMacPlatformFontList::PlatformGlobalFo
             AutoTArray<UniChar, 1024> buffer;
             CFIndex familyNameLen = ::CFStringGetLength(familyNameRef);
             buffer.SetLength(familyNameLen+1);
             ::CFStringGetCharacters(familyNameRef, ::CFRangeMake(0, familyNameLen),
                                     buffer.Elements());
             buffer[familyNameLen] = 0;
             nsDependentString familyNameString(reinterpret_cast<char16_t*>(buffer.Elements()), familyNameLen);
 
-            bool needsBold;  // ignored in the system fallback case
-
             gfxFontFamily *family = FindSystemFontFamily(familyNameString);
             if (family) {
-                fontEntry = family->FindFontForStyle(*aMatchStyle, needsBold);
+                fontEntry = family->FindFontForStyle(*aMatchStyle);
                 if (fontEntry) {
                     if (fontEntry->HasCharacter(aCh)) {
                         *aMatchedFamily = family;
                     } else {
                         fontEntry = nullptr;
                         cantUseFallbackFont = true;
                     }
                 }
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -569,21 +569,18 @@ gfxPlatformFontList::SystemFindFontForCh
         return nullptr;
     }
 
     // Try to short-circuit font fallback for U+FFFD, used to represent
     // encoding errors: just use cached family from last time U+FFFD was seen.
     // This helps speed up pages with lots of encoding errors, binary-as-text,
     // etc.
     if (aCh == 0xFFFD && mReplacementCharFallbackFamily) {
-        bool needsBold;  // ignored in the system fallback case
-
         fontEntry =
-            mReplacementCharFallbackFamily->FindFontForStyle(*aStyle,
-                                                             needsBold);
+            mReplacementCharFallbackFamily->FindFontForStyle(*aStyle);
 
         // this should never fail, as we must have found U+FFFD in order to set
         // mReplacementCharFallbackFamily at all, but better play it safe
         if (fontEntry && fontEntry->HasCharacter(aCh)) {
             return fontEntry;
         }
     }
 
@@ -666,20 +663,19 @@ gfxPlatformFontList::CommonFontFallback(
 
         familyName.AppendASCII(fallbackFamily);
         gfxFontFamily *fallback = FindFamilyByCanonicalName(familyName);
         if (!fallback) {
             continue;
         }
 
         gfxFontEntry *fontEntry;
-        bool needsBold;  // ignored in the system fallback case
 
         // use first font in list that supports a given character
-        fontEntry = fallback->FindFontForStyle(*aMatchStyle, needsBold);
+        fontEntry = fallback->FindFontForStyle(*aMatchStyle);
         if (fontEntry) {
             if (fontEntry->HasCharacter(aCh)) {
                 *aMatchedFamily = fallback;
                 return fontEntry;
             }
             // If we requested a styled font (bold and/or italic), and the char
             // was not available, check other faces of the family.
             if (!fontEntry->IsNormalStyle()) {
@@ -825,24 +821,23 @@ gfxPlatformFontList::FindAndAddFamilies(
         aOutput->AppendElement(familyEntry);
         return true;
     }
 
     return false;
 }
 
 gfxFontEntry*
-gfxPlatformFontList::FindFontForFamily(const nsAString& aFamily, const gfxFontStyle* aStyle, bool& aNeedsBold)
+gfxPlatformFontList::FindFontForFamily(const nsAString& aFamily,
+                                       const gfxFontStyle* aStyle)
 {
     gfxFontFamily *familyEntry = FindFamily(aFamily);
 
-    aNeedsBold = false;
-
     if (familyEntry)
-        return familyEntry->FindFontForStyle(*aStyle, aNeedsBold);
+        return familyEntry->FindFontForStyle(*aStyle);
 
     return nullptr;
 }
 
 void 
 gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName)
 {
     nsAutoString key;
--- a/gfx/thebes/gfxPlatformFontList.h
+++ b/gfx/thebes/gfxPlatformFontList.h
@@ -166,17 +166,18 @@ public:
     // Return true if any match was found and appended, false if none.
     virtual bool
     FindAndAddFamilies(const nsAString& aFamily,
                        nsTArray<gfxFontFamily*>* aOutput,
                        FindFamiliesFlags aFlags,
                        gfxFontStyle* aStyle = nullptr,
                        gfxFloat aDevToCssSize = 1.0);
 
-    gfxFontEntry* FindFontForFamily(const nsAString& aFamily, const gfxFontStyle* aStyle, bool& aNeedsBold);
+    gfxFontEntry* FindFontForFamily(const nsAString& aFamily,
+                                    const gfxFontStyle* aStyle);
 
     // name lookup table methods
 
     void AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName);
 
     void AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname);
 
     void AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName);
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -1865,22 +1865,21 @@ gfxFontGroup::AddPlatformFont(const nsAS
                              &mStyle, mDevToCssSize);
 }
 
 void
 gfxFontGroup::AddFamilyToFontList(gfxFontFamily* aFamily)
 {
     NS_ASSERTION(aFamily, "trying to add a null font family to fontlist");
     AutoTArray<gfxFontEntry*,4> fontEntryList;
-    bool needsBold;
-    aFamily->FindAllFontsForStyle(mStyle, fontEntryList, needsBold);
+    aFamily->FindAllFontsForStyle(mStyle, fontEntryList);
     // add these to the fontlist
     for (gfxFontEntry* fe : fontEntryList) {
         if (!HasFont(fe)) {
-            FamilyFace ff(aFamily, fe, needsBold);
+            FamilyFace ff(aFamily, fe);
             if (fe->mIsUserFontContainer) {
                 ff.CheckState(mSkipDrawing);
             }
             mFonts.AppendElement(ff);
         }
     }
     // for a family marked as "check fallback faces", only mark the last
     // entry so that fallbacks for a family are only checked once
@@ -1927,18 +1926,17 @@ gfxFontGroup::GetFontAt(int32_t i, uint3
                 ff.CheckState(mSkipDrawing);
             }
             fe = ufe->GetPlatformFontEntry();
             if (!fe) {
                 return nullptr;
             }
             unicodeRangeMap = ufe->GetUnicodeRangeMap();
         }
-        font = fe->FindOrMakeFont(&mStyle, mFonts[i].NeedsBold(),
-                                  unicodeRangeMap);
+        font = fe->FindOrMakeFont(&mStyle, unicodeRangeMap);
         if (!font || !font->Valid()) {
             ff.SetInvalid();
             // We can't just |delete font| here, in case there are other
             // references to the object FindOrMakeFont returned.
             RefPtr<gfxFont> ref(font);
             return nullptr;
         }
         mFonts[i].SetFont(font);
@@ -2006,27 +2004,26 @@ gfxFontGroup::FontLoadingForFamily(gfxFo
 
 gfxFont*
 gfxFontGroup::GetDefaultFont()
 {
     if (mDefaultFont) {
         return mDefaultFont.get();
     }
 
-    bool needsBold;
     gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
     gfxFontFamily *defaultFamily = pfl->GetDefaultFont(&mStyle);
     NS_ASSERTION(defaultFamily,
                  "invalid default font returned by GetDefaultFont");
 
     if (defaultFamily) {
         gfxFontEntry *fe =
-            defaultFamily->FindFontForStyle(mStyle, needsBold, true);
+            defaultFamily->FindFontForStyle(mStyle, true);
         if (fe) {
-            mDefaultFont = fe->FindOrMakeFont(&mStyle, needsBold);
+            mDefaultFont = fe->FindOrMakeFont(&mStyle);
         }
     }
 
     uint32_t numInits, loaderState;
     pfl->GetFontlistInitInfo(numInits, loaderState);
     NS_ASSERTION(numInits != 0,
                  "must initialize system fontlist before getting default font!");
 
@@ -2037,19 +2034,19 @@ gfxFontGroup::GetDefaultFont()
         // that assumes it will be able to get valid metrics for layout,
         // just look for the first usable font and put in the list.
         // (see bug 554544)
         AutoTArray<RefPtr<gfxFontFamily>,200> familyList;
         pfl->GetFontFamilyList(familyList);
         numFonts = familyList.Length();
         for (uint32_t i = 0; i < numFonts; ++i) {
             gfxFontEntry *fe =
-                familyList[i]->FindFontForStyle(mStyle, needsBold, true);
+                familyList[i]->FindFontForStyle(mStyle, true);
             if (fe) {
-                mDefaultFont = fe->FindOrMakeFont(&mStyle, needsBold);
+                mDefaultFont = fe->FindOrMakeFont(&mStyle);
                 if (mDefaultFont) {
                     break;
                 }
             }
         }
     }
 
     if (!mDefaultFont) {
@@ -2814,20 +2811,17 @@ gfxFont*
 gfxFontGroup::FindFallbackFaceForChar(gfxFontFamily* aFamily, uint32_t aCh)
 {
     GlobalFontMatch data(aCh, &mStyle);
     aFamily->SearchAllFontsForChar(&data);
     gfxFontEntry* fe = data.mBestMatch;
     if (!fe) {
         return nullptr;
     }
-
-    bool needsBold = mStyle.weight >= FontWeight(600) && !fe->IsBold() &&
-                     mStyle.allowSyntheticWeight;
-    return fe->FindOrMakeFont(&mStyle, needsBold);
+    return fe->FindOrMakeFont(&mStyle);
 }
 
 gfxFloat
 gfxFontGroup::GetUnderlineOffset()
 {
     if (mUnderlineOffset == UNDERLINE_OFFSET_NOT_SET) {
         // if the fontlist contains a bad underline font, make the underline
         // offset the min of the first valid font and bad font underline offsets
@@ -3398,25 +3392,24 @@ gfxFontGroup::WhichPrefFontSupportsChar(
             // if a pref font is used, it's likely to be used again in the same text run.
             // the style doesn't change so the face lookup can be cached rather than calling
             // FindOrMakeFont repeatedly.  speeds up FindFontForChar lookup times for subsequent
             // pref font lookups
             if (family == mLastPrefFamily && mLastPrefFont->HasCharacter(aCh)) {
                 return mLastPrefFont;
             }
 
-            bool needsBold;
-            gfxFontEntry *fe = family->FindFontForStyle(mStyle, needsBold);
+            gfxFontEntry *fe = family->FindFontForStyle(mStyle);
             if (!fe) {
                 continue;
             }
 
             // if ch in cmap, create and return a gfxFont
             if (fe->HasCharacter(aCh)) {
-                gfxFont* prefFont = fe->FindOrMakeFont(&mStyle, needsBold);
+                gfxFont* prefFont = fe->FindOrMakeFont(&mStyle);
                 if (!prefFont) {
                     continue;
                 }
                 mLastPrefFamily = family;
                 mLastPrefFont = prefFont;
                 mLastPrefLang = charLang;
                 mLastPrefFirstFont = (i == 0 && j == 0);
                 return prefFont;
@@ -3441,18 +3434,17 @@ gfxFontGroup::WhichPrefFontSupportsChar(
 gfxFont*
 gfxFontGroup::WhichSystemFontSupportsChar(uint32_t aCh, uint32_t aNextCh,
                                           Script aRunScript)
 {
     gfxFontEntry *fe =
         gfxPlatformFontList::PlatformFontList()->
             SystemFindFontForChar(aCh, aNextCh, aRunScript, &mStyle);
     if (fe) {
-        bool wantBold = mStyle.weight >= FontWeight(600);
-        return fe->FindOrMakeFont(&mStyle, wantBold && !fe->IsBold());
+        return fe->FindOrMakeFont(&mStyle);
     }
 
     return nullptr;
 }
 
 void
 gfxMissingFontRecorder::Flush()
 {
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -1020,49 +1020,47 @@ protected:
     void ComputeRanges(nsTArray<gfxTextRange>& mRanges,
                        const T *aString, uint32_t aLength,
                        Script aRunScript,
                        mozilla::gfx::ShapedTextFlags aOrientation);
 
     class FamilyFace {
     public:
         FamilyFace() : mFamily(nullptr), mFontEntry(nullptr),
-                       mNeedsBold(false), mFontCreated(false),
+                       mFontCreated(false),
                        mLoading(false), mInvalid(false),
                        mCheckForFallbackFaces(false)
         { }
 
         FamilyFace(gfxFontFamily* aFamily, gfxFont* aFont)
-            : mFamily(aFamily), mNeedsBold(false), mFontCreated(true),
+            : mFamily(aFamily), mFontCreated(true),
               mLoading(false), mInvalid(false), mCheckForFallbackFaces(false)
         {
             NS_ASSERTION(aFont, "font pointer must not be null");
             NS_ASSERTION(!aFamily ||
                          aFamily->ContainsFace(aFont->GetFontEntry()),
                          "font is not a member of the given family");
             mFont = aFont;
             NS_ADDREF(aFont);
         }
 
-        FamilyFace(gfxFontFamily* aFamily, gfxFontEntry* aFontEntry,
-                   bool aNeedsBold)
-            : mFamily(aFamily), mNeedsBold(aNeedsBold), mFontCreated(false),
+        FamilyFace(gfxFontFamily* aFamily, gfxFontEntry* aFontEntry)
+            : mFamily(aFamily), mFontCreated(false),
               mLoading(false), mInvalid(false), mCheckForFallbackFaces(false)
         {
             NS_ASSERTION(aFontEntry, "font entry pointer must not be null");
             NS_ASSERTION(!aFamily ||
                          aFamily->ContainsFace(aFontEntry),
                          "font is not a member of the given family");
             mFontEntry = aFontEntry;
             NS_ADDREF(aFontEntry);
         }
 
         FamilyFace(const FamilyFace& aOtherFamilyFace)
             : mFamily(aOtherFamilyFace.mFamily),
-              mNeedsBold(aOtherFamilyFace.mNeedsBold),
               mFontCreated(aOtherFamilyFace.mFontCreated),
               mLoading(aOtherFamilyFace.mLoading),
               mInvalid(aOtherFamilyFace.mInvalid),
               mCheckForFallbackFaces(aOtherFamilyFace.mCheckForFallbackFaces)
         {
             if (mFontCreated) {
                 mFont = aOtherFamilyFace.mFont;
                 NS_ADDREF(mFont);
@@ -1085,17 +1083,16 @@ protected:
         {
             if (mFontCreated) {
                 NS_RELEASE(mFont);
             } else {
                 NS_IF_RELEASE(mFontEntry);
             }
 
             mFamily = aOther.mFamily;
-            mNeedsBold = aOther.mNeedsBold;
             mFontCreated = aOther.mFontCreated;
             mLoading = aOther.mLoading;
             mInvalid = aOther.mInvalid;
 
             if (mFontCreated) {
                 mFont = aOther.mFont;
                 NS_ADDREF(mFont);
             } else {
@@ -1110,17 +1107,16 @@ protected:
         gfxFont* Font() const {
             return mFontCreated ? mFont : nullptr;
         }
 
         gfxFontEntry* FontEntry() const {
             return mFontCreated ? mFont->GetFontEntry() : mFontEntry;
         }
 
-        bool NeedsBold() const { return mNeedsBold; }
         bool IsUserFontContainer() const {
             return FontEntry()->mIsUserFontContainer;
         }
         bool IsLoading() const { return mLoading; }
         bool IsInvalid() const { return mInvalid; }
         void CheckState(bool& aSkipDrawing);
         void SetLoading(bool aIsLoading) { mLoading = aIsLoading; }
         void SetInvalid() { mInvalid = true; }
@@ -1147,17 +1143,16 @@ protected:
         RefPtr<gfxFontFamily> mFamily;
         // either a font or a font entry exists
         union {
             // Whichever of these fields is actually present will be a strong
             // reference, with refcounting handled manually.
             gfxFont* MOZ_OWNING_REF      mFont;
             gfxFontEntry* MOZ_OWNING_REF mFontEntry;
         };
-        bool                    mNeedsBold   : 1;
         bool                    mFontCreated : 1;
         bool                    mLoading     : 1;
         bool                    mInvalid     : 1;
         bool                    mCheckForFallbackFaces : 1;
     };
 
     // List of font families, either named or generic.
     // Generic names map to system pref fonts based on language.
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -164,17 +164,17 @@ gfxUserFontEntry::Matches(const nsTArray
            mSrcList == aFontFaceSrcList &&
            mFontDisplay == aFontDisplay &&
            mRangeFlags == aRangeFlags &&
            ((!aUnicodeRanges && !mCharacterMap) ||
             (aUnicodeRanges && mCharacterMap && mCharacterMap->Equals(aUnicodeRanges)));
 }
 
 gfxFont*
-gfxUserFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, bool aNeedsBold)
+gfxUserFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle)
 {
     NS_NOTREACHED("should only be creating a gfxFont"
                   " with an actual platform font entry");
 
     // userfont entry is a container, can't create font from the container
     return nullptr;
 }
 
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -577,18 +577,17 @@ public:
                  SlantStyleRange aStyle,
                  const nsTArray<gfxFontFeature>& aFeatureSettings,
                  const nsTArray<gfxFontVariation>& aVariationSettings,
                  uint32_t aLanguageOverride,
                  gfxCharacterMap* aUnicodeRanges,
                  uint8_t aFontDisplay,
                  RangeFlags aRangeFlags);
 
-    gfxFont* CreateFontInstance(const gfxFontStyle* aFontStyle,
-                                bool aNeedsBold) override;
+    gfxFont* CreateFontInstance(const gfxFontStyle* aFontStyle) override;
 
     gfxFontEntry* GetPlatformFontEntry() const { return mPlatformFontEntry; }
 
     // is the font loading or loaded, or did it fail?
     UserFontLoadState LoadState() const { return mUserFontLoadState; }
 
     // whether to wait before using fallback font or not
     bool WaitForUserFont() const {
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -298,18 +298,17 @@ FontFaceSet::FindMatchingFontFaces(const
     RefPtr<gfxFontFamily> family =
       mUserFontSet->LookupFamily(fontFamilyName.mName);
 
     if (!family) {
       continue;
     }
 
     AutoTArray<gfxFontEntry*,4> entries;
-    bool needsBold;
-    family->FindAllFontsForStyle(style, entries, needsBold);
+    family->FindAllFontsForStyle(style, entries);
 
     for (gfxFontEntry* e : entries) {
       FontFace::Entry* entry = static_cast<FontFace::Entry*>(e);
       if (HasAnyCharacterInUnicodeRange(entry, aText)) {
         for (FontFace* f : entry->GetFontFaces()) {
           matchingFaces.PutEntry(f);
         }
       }