Bug 549861. Trim out kerning from gfxFontStyle. r=jkew

This commit is contained in:
John Daggett 2013-05-13 18:45:38 +09:00
parent bddaba27de
commit 46d5a31f16
4 changed files with 9 additions and 10 deletions

View File

@ -302,12 +302,10 @@ void nsFont::AddFontFeaturesToStyle(gfxFontStyle *aStyle) const
switch (kerning) {
case NS_FONT_KERNING_NONE:
setting.mValue = 0;
aStyle->kerning = false;
aStyle->featureSettings.AppendElement(setting);
break;
case NS_FONT_KERNING_NORMAL:
setting.mValue = 1;
aStyle->kerning = true;
aStyle->featureSettings.AppendElement(setting);
break;
default:

View File

@ -4865,7 +4865,7 @@ gfxFontStyle::gfxFontStyle() :
languageOverride(NO_FONT_LANGUAGE_OVERRIDE),
weight(NS_FONT_WEIGHT_NORMAL), stretch(NS_FONT_STRETCH_NORMAL),
systemFont(true), printerFont(false),
kerning(true), style(NS_FONT_STYLE_NORMAL)
style(NS_FONT_STYLE_NORMAL)
{
}
@ -4879,7 +4879,7 @@ gfxFontStyle::gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
languageOverride(ParseFontLanguageOverride(aLanguageOverride)),
weight(aWeight), stretch(aStretch),
systemFont(aSystemFont), printerFont(aPrinterFont),
kerning(true), style(aStyle)
style(aStyle)
{
MOZ_ASSERT(!mozilla::IsNaN(size));
MOZ_ASSERT(!mozilla::IsNaN(sizeAdjust));
@ -4910,7 +4910,7 @@ gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) :
languageOverride(aStyle.languageOverride),
weight(aStyle.weight), stretch(aStyle.stretch),
systemFont(aStyle.systemFont), printerFont(aStyle.printerFont),
kerning(aStyle.kerning), style(aStyle.style)
style(aStyle.style)
{
featureSettings.AppendElements(aStyle.featureSettings);
alternateValues.AppendElements(aStyle.alternateValues);

View File

@ -126,9 +126,6 @@ struct THEBES_API gfxFontStyle {
// Say that this font is used for print or print preview.
bool printerFont : 1;
// whether kerning is enabled or not (true by default, can be disabled)
bool kerning : 1;
// The style of font (normal, italic, oblique)
uint8_t style : 2;
@ -160,7 +157,6 @@ struct THEBES_API gfxFontStyle {
(language == other.language) &&
(*reinterpret_cast<const uint32_t*>(&sizeAdjust) ==
*reinterpret_cast<const uint32_t*>(&other.sizeAdjust)) &&
(kerning == other.kerning) &&
(featureSettings == other.featureSettings) &&
(languageOverride == other.languageOverride) &&
(alternateValues == other.alternateValues) &&
@ -1601,6 +1597,10 @@ public:
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
{ return gfxPlatform::GetPlatform()->GetScaledFontForFont(aTarget, this); }
bool KerningDisabled() {
return mKerningSet && !mKerningEnabled;
}
protected:
bool HasSubstitutionRulesWithSpaceLookups(int32_t aRunScript) {

View File

@ -965,7 +965,8 @@ gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
}
const gfxFontStyle *style = mFont->GetStyle();
FontCallbackData fcd(this, aContext, style->kerning);
// kerning is enabled *except* when explicitly disabled (font-kerning: none)
FontCallbackData fcd(this, aContext, !mFont->KerningDisabled());
hb_font_t *font = hb_font_create(mHBFace);
hb_font_set_funcs(font, sHBFontFuncs, &fcd, nullptr);
hb_font_set_ppem(font, mFont->GetAdjustedSize(), mFont->GetAdjustedSize());