/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"nsFont.h" #include"gfxFont.h"// for gfxFontStyle #include"gfxFontFeatures.h"// for gfxFontFeature, etc #include"gfxFontUtils.h"// for TRUETYPE_TAG #include"mozilla/ServoStyleConstsInlines.h" #include"nsCRT.h"// for nsCRT #include"nsDebug.h"// for NS_ASSERTION #include"nsISupports.h" #include"nsUnicharUtils.h" #include"nscore.h"// for char16_t #include"mozilla/ArrayUtils.h" #include"mozilla/gfx/2D.h"
if (smoothing != aOther.smoothing) { return MaxDifference::eVisual;
}
return MaxDifference::eNone;
}
// mapping from bitflag to font feature tag/value pair // // these need to be kept in sync with the constants listed // in gfxFontConstants.h (e.g. StyleFontVariantEastAsian::JIS78)
void nsFont::AddFontFeaturesToStyle(gfxFontStyle* aStyle, bool aVertical) const { // add in font-variant features
gfxFontFeature setting;
// -- kerning
setting.mTag = aVertical ? TRUETYPE_TAG('v', 'k', 'r', 'n')
: TRUETYPE_TAG('k', 'e', 'r', 'n'); switch (kerning) { case NS_FONT_KERNING_NONE:
setting.mValue = 0;
aStyle->featureSettings.AppendElement(setting); break; case NS_FONT_KERNING_NORMAL:
setting.mValue = 1;
aStyle->featureSettings.AppendElement(setting); break; default: // auto case implies use user agent default break;
}
// -- alternates // // NOTE(emilio): We handle historical-forms here because it doesn't depend on // other values set by @font-face and thus may be less expensive to do here // than after font-matching. for (auto& alternate : variantAlternates.AsSpan()) { if (alternate.IsHistoricalForms()) {
setting.mValue = 1;
setting.mTag = TRUETYPE_TAG('h', 'i', 's', 't');
aStyle->featureSettings.AppendElement(setting); break;
}
}
// -- copy font-specific alternate info into style // (this will be resolved after font-matching occurs)
aStyle->variantAlternates = variantAlternates;
// indicate common-path case when neither variantCaps or variantSubSuper are // set
aStyle->noFallbackVariantFeatures =
(aStyle->variantCaps == NS_FONT_VARIANT_CAPS_NORMAL) &&
(variantPosition == NS_FONT_VARIANT_POSITION_NORMAL);
// If the feature list is not empty, we insert a "fake" feature with tag=0 // as delimiter between the above "high-level" features from font-variant-* // etc and those coming from the low-level font-feature-settings property. // This will allow us to distinguish high- and low-level settings when it // comes to potentially disabling ligatures because of letter-spacing. if (!aStyle->featureSettings.IsEmpty() || !fontFeatureSettings.IsEmpty()) {
aStyle->featureSettings.AppendElement(gfxFontFeature{0, 0});
}
// 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 { // If auto optical sizing is enabled, and if there's no 'opsz' axis in // fontVariationSettings, then set the automatic value on the style. class VariationTagComparator { public: bool Equals(const gfxFontVariation& aVariation, uint32_t aTag) const { return aVariation.mTag == aTag;
}
}; const uint32_t kTagOpsz = TRUETYPE_TAG('o', 'p', 's', 'z'); if (opticalSizing == NS_FONT_OPTICAL_SIZING_AUTO &&
!fontVariationSettings.Contains(kTagOpsz, VariationTagComparator())) {
aStyle->autoOpticalSize = size.ToCSSPixels();
}
// Add in arbitrary values from font-variation-settings
aStyle->variationSettings.AppendElements(fontVariationSettings);
}
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.