Bug 1321022 pt 3 - Add an array of variation settings to nsFont, and hook it up to gfxFontStyle. r=dholbert
authorJonathan Kew <jkew@mozilla.com>
Sat, 03 Dec 2016 12:18:33 +0000
changeset 370170 289358891b5f2d7c1f8d2383a83a9bf86258d9ce
parent 370169 d97f80b77cb2ce37e9f4e6a2ef527bc399404a78
child 370171 763cff42073a4abf77f8586edb289d91eb751cc7
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1321022
milestone53.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 1321022 pt 3 - Add an array of variation settings to nsFont, and hook it up to gfxFontStyle. r=dholbert
gfx/src/nsFont.cpp
gfx/src/nsFont.h
gfx/src/nsFontMetrics.cpp
--- a/gfx/src/nsFont.cpp
+++ b/gfx/src/nsFont.cpp
@@ -70,16 +70,17 @@ bool nsFont::Equals(const nsFont& aOther
       (weight == aOther.weight) &&
       (stretch == aOther.stretch) &&
       (size == aOther.size) &&
       (sizeAdjust == aOther.sizeAdjust) &&
       (fontlist == aOther.fontlist) &&
       (kerning == aOther.kerning) &&
       (synthesis == aOther.synthesis) &&
       (fontFeatureSettings == aOther.fontFeatureSettings) &&
+      (fontVariationSettings == aOther.fontVariationSettings) &&
       (languageOverride == aOther.languageOverride) &&
       (variantAlternates == aOther.variantAlternates) &&
       (variantCaps == aOther.variantCaps) &&
       (variantEastAsian == aOther.variantEastAsian) &&
       (variantLigatures == aOther.variantLigatures) &&
       (variantNumeric == aOther.variantNumeric) &&
       (variantPosition == aOther.variantPosition) &&
       (variantWidth == aOther.variantWidth) &&
@@ -290,8 +291,17 @@ void nsFont::AddFontFeaturesToStyle(gfxF
   // add in features from font-feature-settings
   aStyle->featureSettings.AppendElements(fontFeatureSettings);
 
   // enable grayscale antialiasing for text
   if (smoothing == NS_FONT_SMOOTHING_GRAYSCALE) {
     aStyle->useGrayscaleAntialiasing = true;
   }
 }
+
+void nsFont::AddFontVariationsToStyle(gfxFontStyle *aStyle) const
+{
+  // TODO: add variation settings from specific CSS properties
+  // such as weight, width, optical-size
+
+  // Add in arbitrary values from font-variation-settings
+  aStyle->variationSettings.AppendElements(fontVariationSettings);
+}
--- a/gfx/src/nsFont.h
+++ b/gfx/src/nsFont.h
@@ -5,16 +5,17 @@
 
 #ifndef nsFont_h___
 #define nsFont_h___
 
 #include <stdint.h>                     // for uint8_t, uint16_t
 #include <sys/types.h>                  // for int16_t
 #include "gfxFontFamilyList.h"
 #include "gfxFontFeatures.h"
+#include "gfxFontVariations.h"
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "nsCoord.h"                    // for nscoord
 #include "nsStringFwd.h"                // for nsSubstring
 #include "nsString.h"               // for nsString
 #include "nsTArray.h"                   // for nsTArray
 
 struct gfxFontStyle;
 
@@ -96,16 +97,19 @@ struct nsFont {
   nsTArray<gfxAlternateValue> alternateValues;
 
   // -- object used to look these up once the font is matched
   RefPtr<gfxFontFeatureValueSet> featureValueLookup;
 
   // Font features from CSS font-feature-settings
   nsTArray<gfxFontFeature> fontFeatureSettings;
 
+  // Font variations from CSS font-variation-settings
+  nsTArray<gfxFontVariation> fontVariationSettings;
+
   // Language system tag, to override document language;
   // this is an OpenType "language system" tag represented as a 32-bit integer
   // (see http://www.microsoft.com/typography/otspec/languagetags.htm).
   nsString languageOverride;
 
   // initialize the font with a fontlist
   nsFont(const mozilla::FontFamilyList& aFontlist, nscoord aSize);
 
@@ -132,16 +136,18 @@ struct nsFont {
 
   nsFont& operator=(const nsFont& aOther);
 
   void CopyAlternates(const nsFont& aOther);
 
   // Add featureSettings into style
   void AddFontFeaturesToStyle(gfxFontStyle *aStyle) const;
 
+  void AddFontVariationsToStyle(gfxFontStyle *aStyle) const;
+
 protected:
   void Init(); // helper method for initialization
 };
 
 #define NS_FONT_VARIANT_NORMAL            0
 #define NS_FONT_VARIANT_SMALL_CAPS        1
 
 #endif /* nsFont_h___ */
--- a/gfx/src/nsFontMetrics.cpp
+++ b/gfx/src/nsFontMetrics.cpp
@@ -130,16 +130,17 @@ nsFontMetrics::nsFontMetrics(const nsFon
                        aFont.sizeAdjust,
                        aFont.systemFont,
                        mDeviceContext->IsPrinterContext(),
                        aFont.synthesis & NS_FONT_SYNTHESIS_WEIGHT,
                        aFont.synthesis & NS_FONT_SYNTHESIS_STYLE,
                        aFont.languageOverride);
 
     aFont.AddFontFeaturesToStyle(&style);
+    aFont.AddFontVariationsToStyle(&style);
 
     gfxFloat devToCssSize = gfxFloat(mP2A) /
         gfxFloat(mDeviceContext->AppUnitsPerCSSPixel());
     mFontGroup = gfxPlatform::GetPlatform()->
         CreateFontGroup(aFont.fontlist, &style, aParams.textPerf,
                         aParams.userFontSet, devToCssSize);
 }