bug 871453 - part 1 - pass the font-synthesis flags down to gfxFontStyle. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-06-19 08:08:55 +01:00
parent b88760e7ce
commit da86af6995
4 changed files with 19 additions and 1 deletions

View File

@ -2327,6 +2327,8 @@ CanvasRenderingContext2D::SetFont(const nsAString& font,
fontStyle->mFont.systemFont,
printerFont,
fontStyle->mFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS,
fontStyle->mFont.synthesis & NS_FONT_SYNTHESIS_WEIGHT,
fontStyle->mFont.synthesis & NS_FONT_SYNTHESIS_STYLE,
fontStyle->mFont.languageOverride);
fontStyle->mFont.AddFontFeaturesToStyle(&style);

View File

@ -6,6 +6,7 @@
#include "nsFontMetrics.h"
#include <math.h> // for floor, ceil
#include <algorithm> // for max
#include "gfxFontConstants.h" // for NS_FONT_SYNTHESIS_*
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPoint.h" // for gfxPoint
#include "gfxRect.h" // for gfxRect
@ -123,6 +124,8 @@ nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
aFont.systemFont,
mDeviceContext->IsPrinterSurface(),
aFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS,
aFont.synthesis & NS_FONT_SYNTHESIS_WEIGHT,
aFont.synthesis & NS_FONT_SYNTHESIS_STYLE,
aFont.languageOverride);
aFont.AddFontFeaturesToStyle(&style);

View File

@ -6207,7 +6207,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),
smallCaps(false), allowSyntheticWeight(true), allowSyntheticStyle(true),
style(NS_FONT_STYLE_NORMAL)
{
}
@ -6216,6 +6216,8 @@ gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
gfxFloat aSize, nsIAtom *aLanguage,
float aSizeAdjust, bool aSystemFont,
bool aPrinterFont, bool aSmallCaps,
bool aAllowWeightSynthesis,
bool aAllowStyleSynthesis,
const nsString& aLanguageOverride):
language(aLanguage),
size(aSize), sizeAdjust(aSizeAdjust),
@ -6224,6 +6226,8 @@ gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
systemFont(aSystemFont), printerFont(aPrinterFont),
useGrayscaleAntialiasing(false),
smallCaps(aSmallCaps),
allowSyntheticWeight(aAllowWeightSynthesis),
allowSyntheticStyle(aAllowStyleSynthesis),
style(aStyle)
{
MOZ_ASSERT(!mozilla::IsNaN(size));
@ -6257,6 +6261,8 @@ gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) :
systemFont(aStyle.systemFont), printerFont(aStyle.printerFont),
useGrayscaleAntialiasing(aStyle.useGrayscaleAntialiasing),
smallCaps(aStyle.smallCaps),
allowSyntheticWeight(aStyle.allowSyntheticWeight),
allowSyntheticStyle(aStyle.allowSyntheticStyle),
style(aStyle.style)
{
featureSettings.AppendElements(aStyle.featureSettings);

View File

@ -78,6 +78,7 @@ struct gfxFontStyle {
gfxFloat aSize, nsIAtom *aLanguage,
float aSizeAdjust, bool aSystemFont,
bool aPrinterFont, bool aSmallCaps,
bool aWeightSynthesis, bool aStyleSynthesis,
const nsString& aLanguageOverride);
gfxFontStyle(const gfxFontStyle& aStyle);
@ -146,6 +147,10 @@ struct gfxFontStyle {
// otherwise using a synthetic small-caps implementation
bool smallCaps : 1;
// Whether synthetic styles are allowed
bool allowSyntheticWeight : 1;
bool allowSyntheticStyle : 1;
// The style of font (normal, italic, oblique)
uint8_t style : 2;
@ -171,6 +176,8 @@ struct gfxFontStyle {
*reinterpret_cast<const uint64_t*>(&other.size)) &&
(style == other.style) &&
(smallCaps == other.smallCaps) &&
(allowSyntheticWeight == other.allowSyntheticWeight) &&
(allowSyntheticStyle == other.allowSyntheticStyle) &&
(systemFont == other.systemFont) &&
(printerFont == other.printerFont) &&
(useGrayscaleAntialiasing == other.useGrayscaleAntialiasing) &&