forked from mirrors/gecko-dev
Bug 1812676 - Improve font-style:oblique mapping to 'slnt' variation. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D167989
This commit is contained in:
parent
48a5bc2b56
commit
e9adaa9c22
5 changed files with 18 additions and 10 deletions
|
|
@ -818,7 +818,7 @@ float gfxFont::AngleForSyntheticOblique() const {
|
|||
// If the style doesn't call for italic/oblique, or if the face already
|
||||
// provides it, no synthetic style should be added.
|
||||
if (mStyle.style == FontSlantStyle::NORMAL || !mStyle.allowSyntheticStyle ||
|
||||
!mFontEntry->IsUpright()) {
|
||||
!mFontEntry->IsUpright() || mFontEntry->HasSlantVariation()) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1267,6 +1267,8 @@ void gfxFontEntry::CheckForVariationAxes() {
|
|||
} else if (axis.mTag == HB_TAG('i', 't', 'a', 'l') &&
|
||||
axis.mMaxValue >= 1.0f) {
|
||||
mRangeFlags |= RangeFlags::eItalicVariation;
|
||||
} else if (axis.mTag == HB_TAG('s', 'l', 'n', 't')) {
|
||||
mRangeFlags |= RangeFlags::eSlantVariation;
|
||||
} else if (axis.mTag == HB_TAG('o', 'p', 's', 'z')) {
|
||||
mRangeFlags |= RangeFlags::eOpticalSize;
|
||||
}
|
||||
|
|
@ -1288,6 +1290,13 @@ bool gfxFontEntry::HasItalicVariation() {
|
|||
return bool(mRangeFlags & RangeFlags::eItalicVariation);
|
||||
}
|
||||
|
||||
bool gfxFontEntry::HasSlantVariation() {
|
||||
MOZ_ASSERT(!mIsUserFontContainer,
|
||||
"should not be called for user-font containers!");
|
||||
CheckForVariationAxes();
|
||||
return bool(mRangeFlags & RangeFlags::eSlantVariation);
|
||||
}
|
||||
|
||||
bool gfxFontEntry::HasOpticalSize() {
|
||||
MOZ_ASSERT(!mIsUserFontContainer,
|
||||
"should not be called for user-font containers!");
|
||||
|
|
@ -1336,7 +1345,7 @@ void gfxFontEntry::GetVariationsForStyle(nsTArray<gfxFontVariation>& aResult,
|
|||
// The 'ital' axis is normally a binary toggle; intermediate values
|
||||
// can only be set using font-variation-settings.
|
||||
aResult.AppendElement(gfxFontVariation{HB_TAG('i', 't', 'a', 'l'), 1.0f});
|
||||
} else if (SlantStyle().Min().IsOblique()) {
|
||||
} else if (HasSlantVariation()) {
|
||||
// Figure out what slant angle we should try to match from the
|
||||
// requested style.
|
||||
float angle = aStyle.style.IsNormal() ? 0.0f
|
||||
|
|
|
|||
|
|
@ -452,6 +452,7 @@ class gfxFontEntry {
|
|||
|
||||
bool HasBoldVariableWeight();
|
||||
bool HasItalicVariation();
|
||||
bool HasSlantVariation();
|
||||
bool HasOpticalSize();
|
||||
|
||||
void CheckForVariationAxes();
|
||||
|
|
@ -552,7 +553,7 @@ class gfxFontEntry {
|
|||
// descriptors, it is treated as the initial value for font-matching (and
|
||||
// so that is what we record in the font entry), but when rendering the
|
||||
// range is NOT clamped.
|
||||
enum class RangeFlags : uint8_t {
|
||||
enum class RangeFlags : uint16_t {
|
||||
eNoFlags = 0,
|
||||
eAutoWeight = (1 << 0),
|
||||
eAutoStretch = (1 << 1),
|
||||
|
|
@ -564,16 +565,18 @@ class gfxFontEntry {
|
|||
eBoldVariableWeight = (1 << 3),
|
||||
// Whether the face has an 'ital' axis.
|
||||
eItalicVariation = (1 << 4),
|
||||
// Whether the face has a 'slnt' axis.
|
||||
eSlantVariation = (1 << 5),
|
||||
|
||||
// Flags to record if the face uses a non-CSS-compatible scale
|
||||
// for weight and/or stretch, in which case we won't map the
|
||||
// properties to the variation axes (though they can still be
|
||||
// explicitly set using font-variation-settings).
|
||||
eNonCSSWeight = (1 << 5),
|
||||
eNonCSSStretch = (1 << 6),
|
||||
eNonCSSWeight = (1 << 6),
|
||||
eNonCSSStretch = (1 << 7),
|
||||
|
||||
// Whether the font has an 'opsz' axis.
|
||||
eOpticalSize = (1 << 7)
|
||||
eOpticalSize = (1 << 8)
|
||||
};
|
||||
RangeFlags mRangeFlags = RangeFlags::eNoFlags;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
[font-face-style-auto-variable.html]
|
||||
expected: FAIL
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[font-face-style-default-variable.html]
|
||||
expected: FAIL
|
||||
Loading…
Reference in a new issue