From 1be74705a61d50331f990a81c58fda086048c7a6 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Mon, 26 May 2014 14:23:31 +0100 Subject: [PATCH] bug 1015603 part 3 - add a smallCaps field to gfxFontStyle, and pass it through from layout when creating gfxFontStyle records. r=roc --- content/canvas/src/CanvasRenderingContext2D.cpp | 1 + gfx/src/nsFont.cpp | 2 +- gfx/src/nsFontMetrics.cpp | 1 + gfx/thebes/gfxFont.cpp | 8 ++++++-- gfx/thebes/gfxFont.h | 7 ++++++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 2d091fb7cd9..b408b7d593e 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -2313,6 +2313,7 @@ CanvasRenderingContext2D::SetFont(const nsAString& font, fontStyle->mFont.sizeAdjust, fontStyle->mFont.systemFont, printerFont, + fontStyle->mFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS, fontStyle->mFont.languageOverride); fontStyle->mFont.AddFontFeaturesToStyle(&style); diff --git a/gfx/src/nsFont.cpp b/gfx/src/nsFont.cpp index a219aba0e76..c394042d5be 100644 --- a/gfx/src/nsFont.cpp +++ b/gfx/src/nsFont.cpp @@ -115,6 +115,7 @@ bool nsFont::BaseEquals(const nsFont& aOther) const (synthesis == aOther.synthesis) && (fontFeatureSettings == aOther.fontFeatureSettings) && (languageOverride == aOther.languageOverride) && + (variant == aOther.variant) && (variantAlternates == aOther.variantAlternates) && (variantCaps == aOther.variantCaps) && (variantEastAsian == aOther.variantEastAsian) && @@ -132,7 +133,6 @@ bool nsFont::BaseEquals(const nsFont& aOther) const bool nsFont::Equals(const nsFont& aOther) const { if (BaseEquals(aOther) && - (variant == aOther.variant) && (decorations == aOther.decorations)) { return true; } diff --git a/gfx/src/nsFontMetrics.cpp b/gfx/src/nsFontMetrics.cpp index a54ae57123a..320069d1e87 100644 --- a/gfx/src/nsFontMetrics.cpp +++ b/gfx/src/nsFontMetrics.cpp @@ -122,6 +122,7 @@ nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage, aFont.sizeAdjust, aFont.systemFont, mDeviceContext->IsPrinterSurface(), + aFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS, aFont.languageOverride); aFont.AddFontFeaturesToStyle(&style); diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 86607b81cb3..56436acea51 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -5981,6 +5981,7 @@ gfxFontStyle::gfxFontStyle() : languageOverride(NO_FONT_LANGUAGE_OVERRIDE), weight(NS_FONT_WEIGHT_NORMAL), stretch(NS_FONT_STRETCH_NORMAL), systemFont(true), printerFont(false), useGrayscaleAntialiasing(false), + smallCaps(false), style(NS_FONT_STYLE_NORMAL) { } @@ -5988,14 +5989,16 @@ gfxFontStyle::gfxFontStyle() : gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxFloat aSize, nsIAtom *aLanguage, float aSizeAdjust, bool aSystemFont, - bool aPrinterFont, + bool aPrinterFont, bool aSmallCaps, const nsString& aLanguageOverride): language(aLanguage), size(aSize), sizeAdjust(aSizeAdjust), languageOverride(ParseFontLanguageOverride(aLanguageOverride)), weight(aWeight), stretch(aStretch), systemFont(aSystemFont), printerFont(aPrinterFont), - useGrayscaleAntialiasing(false), style(aStyle) + useGrayscaleAntialiasing(false), + smallCaps(aSmallCaps), + style(aStyle) { MOZ_ASSERT(!mozilla::IsNaN(size)); MOZ_ASSERT(!mozilla::IsNaN(sizeAdjust)); @@ -6027,6 +6030,7 @@ gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) : weight(aStyle.weight), stretch(aStyle.stretch), systemFont(aStyle.systemFont), printerFont(aStyle.printerFont), useGrayscaleAntialiasing(aStyle.useGrayscaleAntialiasing), + smallCaps(aStyle.smallCaps), style(aStyle.style) { featureSettings.AppendElements(aStyle.featureSettings); diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 0dd8ead753a..ad023e81455 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -74,7 +74,7 @@ struct gfxFontStyle { gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch, gfxFloat aSize, nsIAtom *aLanguage, float aSizeAdjust, bool aSystemFont, - bool aPrinterFont, + bool aPrinterFont, bool aSmallCaps, const nsString& aLanguageOverride); gfxFontStyle(const gfxFontStyle& aStyle); @@ -139,6 +139,10 @@ struct gfxFontStyle { // Used to imitate -webkit-font-smoothing: antialiased bool useGrayscaleAntialiasing : 1; + // Font should render as small-caps, using OT feature if available, + // otherwise using a synthetic small-caps implementation + bool smallCaps : 1; + // The style of font (normal, italic, oblique) uint8_t style : 2; @@ -163,6 +167,7 @@ struct gfxFontStyle { (*reinterpret_cast(&size) == *reinterpret_cast(&other.size)) && (style == other.style) && + (smallCaps == other.smallCaps) && (systemFont == other.systemFont) && (printerFont == other.printerFont) && (useGrayscaleAntialiasing == other.useGrayscaleAntialiasing) &&