Bug 1945637 - Remove the separate 'normal' value of font-style types, as it is a synonym for 'oblique 0deg'; always serialize 'oblique 0deg' as 'normal'. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D236733
This commit is contained in:
@@ -4219,8 +4219,6 @@ bool CanvasRenderingContext2D::SetFontInternalDisconnected(
|
|||||||
// In the OffscreenCanvas case we don't have the context necessary to call
|
// In the OffscreenCanvas case we don't have the context necessary to call
|
||||||
// GetFontStyleForServo(), as we do in the main-thread canvas context, so
|
// GetFontStyleForServo(), as we do in the main-thread canvas context, so
|
||||||
// instead we borrow ParseFontShorthandForMatching to parse the attribute.
|
// instead we borrow ParseFontShorthandForMatching to parse the attribute.
|
||||||
StyleComputedFontStyleDescriptor style(
|
|
||||||
StyleComputedFontStyleDescriptor::Normal());
|
|
||||||
StyleFontFamilyList list;
|
StyleFontFamilyList list;
|
||||||
gfxFontStyle fontStyle;
|
gfxFontStyle fontStyle;
|
||||||
float size = 0.0f;
|
float size = 0.0f;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ void Family::AddFaces(FontList* aList, const nsTArray<Face::InitData>& aFaces) {
|
|||||||
if (f.mWeight.Min().IsBold()) {
|
if (f.mWeight.Min().IsBold()) {
|
||||||
slot |= kBoldMask;
|
slot |= kBoldMask;
|
||||||
}
|
}
|
||||||
if (f.mStyle.Min().IsItalic() || f.mStyle.Min().IsOblique()) {
|
if (!f.mStyle.Min().IsNormal()) {
|
||||||
slot |= kItalicMask;
|
slot |= kItalicMask;
|
||||||
}
|
}
|
||||||
if (slots[slot]) {
|
if (slots[slot]) {
|
||||||
@@ -604,7 +604,7 @@ void Family::SetFacePtrs(FontList* aList, nsTArray<Pointer>& aFaces) {
|
|||||||
if (f->mWeight.Min().IsBold()) {
|
if (f->mWeight.Min().IsBold()) {
|
||||||
slot |= kBoldMask;
|
slot |= kBoldMask;
|
||||||
}
|
}
|
||||||
if (f->mStyle.Min().IsItalic() || f->mStyle.Min().IsOblique()) {
|
if (!f->mStyle.Min().IsNormal()) {
|
||||||
slot |= kItalicMask;
|
slot |= kItalicMask;
|
||||||
}
|
}
|
||||||
if (!slots[slot].IsNull()) {
|
if (!slots[slot].IsNull()) {
|
||||||
|
|||||||
@@ -1334,7 +1334,7 @@ void gfxFontEntry::GetVariationsForStyle(nsTArray<gfxFontVariation>& aResult,
|
|||||||
// The 'ital' axis is normally a binary toggle; intermediate values
|
// The 'ital' axis is normally a binary toggle; intermediate values
|
||||||
// can only be set using font-variation-settings.
|
// can only be set using font-variation-settings.
|
||||||
aResult.AppendElement(gfxFontVariation{HB_TAG('i', 't', 'a', 'l'), 1.0f});
|
aResult.AppendElement(gfxFontVariation{HB_TAG('i', 't', 'a', 'l'), 1.0f});
|
||||||
} else if (aStyle.style != StyleFontStyle::NORMAL && HasSlantVariation()) {
|
} else if (HasSlantVariation()) {
|
||||||
// Figure out what slant angle we should try to match from the
|
// Figure out what slant angle we should try to match from the
|
||||||
// requested style.
|
// requested style.
|
||||||
float angle = aStyle.style.SlantAngle();
|
float angle = aStyle.style.SlantAngle();
|
||||||
|
|||||||
@@ -232,7 +232,9 @@ class gfxFontEntry {
|
|||||||
bool IsLocalUserFont() const { return mIsLocalUserFont; }
|
bool IsLocalUserFont() const { return mIsLocalUserFont; }
|
||||||
bool IsFixedPitch() const { return mFixedPitch; }
|
bool IsFixedPitch() const { return mFixedPitch; }
|
||||||
bool IsItalic() const { return SlantStyle().Min().IsItalic(); }
|
bool IsItalic() const { return SlantStyle().Min().IsItalic(); }
|
||||||
bool IsOblique() const { return SlantStyle().Min().IsOblique(); }
|
// IsOblique returns true if the oblique angle is non-zero; 'oblique 0deg'
|
||||||
|
// is synonymous with 'normal' and will return false here.
|
||||||
|
bool IsOblique() const { return !IsUpright() && !IsItalic(); }
|
||||||
bool IsUpright() const { return SlantStyle().Min().IsNormal(); }
|
bool IsUpright() const { return SlantStyle().Min().IsNormal(); }
|
||||||
inline bool SupportsItalic(); // defined below, because of RangeFlags use
|
inline bool SupportsItalic(); // defined below, because of RangeFlags use
|
||||||
inline bool SupportsBold();
|
inline bool SupportsBold();
|
||||||
|
|||||||
@@ -1241,142 +1241,127 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
|
|||||||
const double kNegate = 200.0;
|
const double kNegate = 200.0;
|
||||||
|
|
||||||
if (aTargetStyle.IsNormal()) {
|
if (aTargetStyle.IsNormal()) {
|
||||||
if (minStyle.IsOblique()) {
|
if (minStyle.IsItalic()) {
|
||||||
// to distinguish oblique 0deg from normal, we add 1.0 to the angle
|
// italic is worse than any non-negative oblique;
|
||||||
const double minAngle = minStyle.ObliqueAngle();
|
// treat as a match in the wrong search direction
|
||||||
if (minAngle >= 0.0) {
|
return kReverse;
|
||||||
return 1.0 + minAngle;
|
|
||||||
}
|
|
||||||
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
|
||||||
const double maxAngle = maxStyle.ObliqueAngle();
|
|
||||||
if (maxAngle >= 0.0) {
|
|
||||||
// [min,max] range includes 0.0, so just return our minimum
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
// negative oblique is even worse than italic
|
|
||||||
return kNegate - maxAngle;
|
|
||||||
}
|
}
|
||||||
// must be italic, which is worse than any non-negative oblique;
|
const double minAngle = minStyle.ObliqueAngle();
|
||||||
// treat as a match in the wrong search direction
|
if (minAngle >= 0.0) {
|
||||||
MOZ_ASSERT(minStyle.IsItalic());
|
return minAngle;
|
||||||
return kReverse;
|
}
|
||||||
|
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
||||||
|
const double maxAngle = maxStyle.ObliqueAngle();
|
||||||
|
if (maxAngle >= 0.0) {
|
||||||
|
// [min,max] range includes 0.0, so it's a perfect match
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
// negative oblique is even worse than italic
|
||||||
|
return kNegate - maxAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double kDefaultAngle = mozilla::FontSlantStyle::DEFAULT_OBLIQUE_DEGREES;
|
const double kDefaultAngle = mozilla::FontSlantStyle::DEFAULT_OBLIQUE_DEGREES;
|
||||||
|
|
||||||
if (aTargetStyle.IsItalic()) {
|
if (aTargetStyle.IsItalic()) {
|
||||||
if (minStyle.IsOblique()) {
|
MOZ_ASSERT(!minStyle.IsItalic()); // we checked for equality above
|
||||||
const double minAngle = minStyle.ObliqueAngle();
|
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
||||||
if (minAngle >= kDefaultAngle) {
|
if (maxStyle.IsItalic()) {
|
||||||
return 1.0 + (minAngle - kDefaultAngle);
|
// Must be a font with an 'ital' axis, so consider this a match.
|
||||||
}
|
return 0.0;
|
||||||
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
|
||||||
const double maxAngle = maxStyle.ObliqueAngle();
|
|
||||||
if (maxAngle >= kDefaultAngle) {
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
if (maxAngle > 0.0) {
|
|
||||||
// wrong direction but still > 0, add bias of 100
|
|
||||||
return kReverse + (kDefaultAngle - maxAngle);
|
|
||||||
}
|
|
||||||
// negative oblique angle, add bias of 300
|
|
||||||
return kReverse + kNegate + (kDefaultAngle - maxAngle);
|
|
||||||
}
|
}
|
||||||
// normal is worse than oblique > 0, but better than oblique <= 0
|
const double minAngle = minStyle.ObliqueAngle();
|
||||||
MOZ_ASSERT(minStyle.IsNormal());
|
if (minAngle >= kDefaultAngle) {
|
||||||
return kNegate;
|
// Add 1.0 to ensure italic vs non-italic never returns 0.0, even if the
|
||||||
|
// angle matches.
|
||||||
|
return minAngle - kDefaultAngle + 1.0;
|
||||||
|
}
|
||||||
|
const double maxAngle = maxStyle.ObliqueAngle();
|
||||||
|
if (maxAngle >= kDefaultAngle) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
if (maxAngle > 0.0) {
|
||||||
|
// wrong direction but still > 0, add bias of 100
|
||||||
|
return kReverse + (kDefaultAngle - maxAngle);
|
||||||
|
}
|
||||||
|
// negative oblique angle, add bias of 300
|
||||||
|
return kReverse + kNegate + (kDefaultAngle - maxAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// target is oblique <angle>: four different cases depending on
|
// target is oblique <angle>: four different cases depending on
|
||||||
// the value of the <angle>, which determines the preferred direction
|
// the value of the <angle>, which determines the preferred direction
|
||||||
// of search
|
// of search
|
||||||
const double targetAngle = aTargetStyle.ObliqueAngle();
|
const double targetAngle = aTargetStyle.ObliqueAngle();
|
||||||
|
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
||||||
if (targetAngle >= kDefaultAngle) {
|
if (targetAngle >= kDefaultAngle) {
|
||||||
if (minStyle.IsOblique()) {
|
if (minStyle.IsItalic() || maxStyle.IsItalic()) {
|
||||||
const double minAngle = minStyle.ObliqueAngle();
|
|
||||||
if (minAngle >= targetAngle) {
|
|
||||||
return minAngle - targetAngle;
|
|
||||||
}
|
|
||||||
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
|
||||||
const double maxAngle = maxStyle.ObliqueAngle();
|
|
||||||
if (maxAngle >= targetAngle) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
if (maxAngle > 0.0) {
|
|
||||||
return kReverse + (targetAngle - maxAngle);
|
|
||||||
}
|
|
||||||
return kReverse + kNegate + (targetAngle - maxAngle);
|
|
||||||
}
|
|
||||||
if (minStyle.IsItalic()) {
|
|
||||||
return kReverse + kNegate;
|
return kReverse + kNegate;
|
||||||
}
|
}
|
||||||
return kReverse + kNegate + 1.0;
|
const double minAngle = minStyle.ObliqueAngle();
|
||||||
|
if (minAngle >= targetAngle) {
|
||||||
|
return minAngle - targetAngle;
|
||||||
|
}
|
||||||
|
const double maxAngle = maxStyle.ObliqueAngle();
|
||||||
|
if (maxAngle >= targetAngle) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
if (maxAngle > 0.0) {
|
||||||
|
return kReverse + (targetAngle - maxAngle);
|
||||||
|
}
|
||||||
|
return kReverse + kNegate + (targetAngle - maxAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetAngle <= -kDefaultAngle) {
|
if (targetAngle <= -kDefaultAngle) {
|
||||||
if (minStyle.IsOblique()) {
|
if (minStyle.IsItalic() || maxStyle.IsItalic()) {
|
||||||
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
|
||||||
const double maxAngle = maxStyle.ObliqueAngle();
|
|
||||||
if (maxAngle <= targetAngle) {
|
|
||||||
return targetAngle - maxAngle;
|
|
||||||
}
|
|
||||||
const double minAngle = minStyle.ObliqueAngle();
|
|
||||||
if (minAngle <= targetAngle) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
if (minAngle < 0.0) {
|
|
||||||
return kReverse + (minAngle - targetAngle);
|
|
||||||
}
|
|
||||||
return kReverse + kNegate + (minAngle - targetAngle);
|
|
||||||
}
|
|
||||||
if (minStyle.IsItalic()) {
|
|
||||||
return kReverse + kNegate;
|
return kReverse + kNegate;
|
||||||
}
|
}
|
||||||
return kReverse + kNegate + 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetAngle >= 0.0) {
|
|
||||||
if (minStyle.IsOblique()) {
|
|
||||||
const double minAngle = minStyle.ObliqueAngle();
|
|
||||||
if (minAngle > targetAngle) {
|
|
||||||
return kReverse + (minAngle - targetAngle);
|
|
||||||
}
|
|
||||||
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
|
||||||
const double maxAngle = maxStyle.ObliqueAngle();
|
|
||||||
if (maxAngle >= targetAngle) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
if (maxAngle > 0.0) {
|
|
||||||
return targetAngle - maxAngle;
|
|
||||||
}
|
|
||||||
return kReverse + kNegate + (targetAngle - maxAngle);
|
|
||||||
}
|
|
||||||
if (minStyle.IsItalic()) {
|
|
||||||
return kReverse + kNegate - 2.0;
|
|
||||||
}
|
|
||||||
return kReverse + kNegate - 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// last case: (targetAngle < 0.0 && targetAngle > kDefaultAngle)
|
|
||||||
if (minStyle.IsOblique()) {
|
|
||||||
const mozilla::FontSlantStyle maxStyle = aRange.Max();
|
|
||||||
const double maxAngle = maxStyle.ObliqueAngle();
|
const double maxAngle = maxStyle.ObliqueAngle();
|
||||||
if (maxAngle < targetAngle) {
|
if (maxAngle <= targetAngle) {
|
||||||
return kReverse + (targetAngle - maxAngle);
|
return targetAngle - maxAngle;
|
||||||
}
|
}
|
||||||
const double minAngle = minStyle.ObliqueAngle();
|
const double minAngle = minStyle.ObliqueAngle();
|
||||||
if (minAngle <= targetAngle) {
|
if (minAngle <= targetAngle) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (minAngle < 0.0) {
|
if (minAngle < 0.0) {
|
||||||
return minAngle - targetAngle;
|
return kReverse + (minAngle - targetAngle);
|
||||||
}
|
}
|
||||||
return kReverse + kNegate + (minAngle - targetAngle);
|
return kReverse + kNegate + (minAngle - targetAngle);
|
||||||
}
|
}
|
||||||
if (minStyle.IsItalic()) {
|
|
||||||
return kReverse + kNegate - 2.0;
|
if (targetAngle >= 0.0) {
|
||||||
|
if (minStyle.IsItalic() || maxStyle.IsItalic()) {
|
||||||
|
return kReverse + kNegate - 1.0;
|
||||||
|
}
|
||||||
|
const double minAngle = minStyle.ObliqueAngle();
|
||||||
|
if (minAngle > targetAngle) {
|
||||||
|
return kReverse + (minAngle - targetAngle);
|
||||||
|
}
|
||||||
|
const double maxAngle = maxStyle.ObliqueAngle();
|
||||||
|
if (maxAngle >= targetAngle) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
if (maxAngle > 0.0) {
|
||||||
|
return targetAngle - maxAngle;
|
||||||
|
}
|
||||||
|
return kReverse + kNegate + (targetAngle - maxAngle);
|
||||||
}
|
}
|
||||||
return kReverse + kNegate - 1.0;
|
|
||||||
|
// last case: (targetAngle < 0.0 && targetAngle > kDefaultAngle)
|
||||||
|
if (minStyle.IsItalic() || maxStyle.IsItalic()) {
|
||||||
|
return kReverse + kNegate - 1.0;
|
||||||
|
}
|
||||||
|
const double maxAngle = maxStyle.ObliqueAngle();
|
||||||
|
if (maxAngle < targetAngle) {
|
||||||
|
return kReverse + (targetAngle - maxAngle);
|
||||||
|
}
|
||||||
|
const double minAngle = minStyle.ObliqueAngle();
|
||||||
|
if (minAngle <= targetAngle) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
if (minAngle < 0.0) {
|
||||||
|
return minAngle - targetAngle;
|
||||||
|
}
|
||||||
|
return kReverse + kNegate + (minAngle - targetAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stretch distance ==> [0,2000]
|
// stretch distance ==> [0,2000]
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ testDescriptor("font-stretch", [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
testDescriptor("font-style", [
|
testDescriptor("font-style", [
|
||||||
{ value: "normal", testDescriptors: ["normal", "oblique 0deg", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "normal", testDescriptors: ["normal", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique 0deg", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
|
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
|
||||||
{ value: "oblique 20deg", testDescriptors: ["oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "oblique 20deg", testDescriptors: ["oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
{ value: "oblique 21deg", testDescriptors: ["oblique 21deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 20deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "oblique 21deg", testDescriptors: ["oblique 21deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 20deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
{ value: "oblique 10deg", testDescriptors: ["oblique 10deg", "oblique 5deg", "oblique 15deg 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "oblique 10deg", testDescriptors: ["oblique 10deg", "oblique 5deg", "oblique 15deg 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
|
|||||||
@@ -595,9 +595,6 @@ bool FontFaceImpl::GetAttributes(gfxUserFontAttributes& aAttr) {
|
|||||||
if (Servo_FontFaceRule_GetFontStyle(data, &styleDesc)) {
|
if (Servo_FontFaceRule_GetFontStyle(data, &styleDesc)) {
|
||||||
aAttr.mRangeFlags &= ~gfxFontEntry::RangeFlags::eAutoSlantStyle;
|
aAttr.mRangeFlags &= ~gfxFontEntry::RangeFlags::eAutoSlantStyle;
|
||||||
switch (styleDesc.tag) {
|
switch (styleDesc.tag) {
|
||||||
case StyleComputedFontStyleDescriptor::Tag::Normal:
|
|
||||||
aAttr.mStyle = SlantStyleRange(FontSlantStyle::NORMAL);
|
|
||||||
break;
|
|
||||||
case StyleComputedFontStyleDescriptor::Tag::Italic:
|
case StyleComputedFontStyleDescriptor::Tag::Italic:
|
||||||
aAttr.mStyle = SlantStyleRange(FontSlantStyle::ITALIC);
|
aAttr.mStyle = SlantStyleRange(FontSlantStyle::ITALIC);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1097,12 +1097,8 @@ inline bool StyleFontWeight::IsBold() const { return *this >= BOLD_THRESHOLD; }
|
|||||||
|
|
||||||
inline bool StyleFontStyle::IsItalic() const { return *this == ITALIC; }
|
inline bool StyleFontStyle::IsItalic() const { return *this == ITALIC; }
|
||||||
|
|
||||||
inline bool StyleFontStyle::IsOblique() const {
|
|
||||||
return !IsItalic() && !IsNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float StyleFontStyle::ObliqueAngle() const {
|
inline float StyleFontStyle::ObliqueAngle() const {
|
||||||
MOZ_ASSERT(IsOblique());
|
MOZ_ASSERT(!IsItalic());
|
||||||
return ToFloat();
|
return ToFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -379,7 +379,6 @@ impl FontStretchRange {
|
|||||||
#[derive(Clone, Debug, PartialEq, ToShmem)]
|
#[derive(Clone, Debug, PartialEq, ToShmem)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum FontStyle {
|
pub enum FontStyle {
|
||||||
Normal,
|
|
||||||
Italic,
|
Italic,
|
||||||
Oblique(Angle, Angle),
|
Oblique(Angle, Angle),
|
||||||
}
|
}
|
||||||
@@ -389,7 +388,6 @@ pub enum FontStyle {
|
|||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum ComputedFontStyleDescriptor {
|
pub enum ComputedFontStyleDescriptor {
|
||||||
Normal,
|
|
||||||
Italic,
|
Italic,
|
||||||
Oblique(f32, f32),
|
Oblique(f32, f32),
|
||||||
}
|
}
|
||||||
@@ -399,9 +397,14 @@ impl Parse for FontStyle {
|
|||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
// We parse 'normal' explicitly here to distinguish it from 'oblique 0deg',
|
||||||
|
// because we must not accept a following angle.
|
||||||
|
if input.try_parse(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||||
|
return Ok(FontStyle::Oblique(Angle::zero(), Angle::zero()));
|
||||||
|
}
|
||||||
|
|
||||||
let style = SpecifiedFontStyle::parse(context, input)?;
|
let style = SpecifiedFontStyle::parse(context, input)?;
|
||||||
Ok(match style {
|
Ok(match style {
|
||||||
GenericFontStyle::Normal => FontStyle::Normal,
|
|
||||||
GenericFontStyle::Italic => FontStyle::Italic,
|
GenericFontStyle::Italic => FontStyle::Italic,
|
||||||
GenericFontStyle::Oblique(angle) => {
|
GenericFontStyle::Oblique(angle) => {
|
||||||
let second_angle = input
|
let second_angle = input
|
||||||
@@ -420,9 +423,13 @@ impl ToCss for FontStyle {
|
|||||||
W: fmt::Write,
|
W: fmt::Write,
|
||||||
{
|
{
|
||||||
match *self {
|
match *self {
|
||||||
FontStyle::Normal => dest.write_str("normal"),
|
|
||||||
FontStyle::Italic => dest.write_str("italic"),
|
FontStyle::Italic => dest.write_str("italic"),
|
||||||
FontStyle::Oblique(ref first, ref second) => {
|
FontStyle::Oblique(ref first, ref second) => {
|
||||||
|
// Not first.is_zero() because we don't want to serialize
|
||||||
|
// `oblique calc(0deg)` as `normal`.
|
||||||
|
if *first == Angle::zero() && first == second {
|
||||||
|
return dest.write_str("normal");
|
||||||
|
}
|
||||||
dest.write_str("oblique")?;
|
dest.write_str("oblique")?;
|
||||||
if *first != SpecifiedFontStyle::default_angle() || first != second {
|
if *first != SpecifiedFontStyle::default_angle() || first != second {
|
||||||
dest.write_char(' ')?;
|
dest.write_char(' ')?;
|
||||||
@@ -442,7 +449,6 @@ impl FontStyle {
|
|||||||
/// Returns a computed font-style descriptor.
|
/// Returns a computed font-style descriptor.
|
||||||
pub fn compute(&self) -> ComputedFontStyleDescriptor {
|
pub fn compute(&self) -> ComputedFontStyleDescriptor {
|
||||||
match *self {
|
match *self {
|
||||||
FontStyle::Normal => ComputedFontStyleDescriptor::Normal,
|
|
||||||
FontStyle::Italic => ComputedFontStyleDescriptor::Italic,
|
FontStyle::Italic => ComputedFontStyleDescriptor::Italic,
|
||||||
FontStyle::Oblique(ref first, ref second) => {
|
FontStyle::Oblique(ref first, ref second) => {
|
||||||
let (min, max) = sort_range(
|
let (min, max) = sort_range(
|
||||||
|
|||||||
@@ -1050,8 +1050,8 @@ impl ToComputedValue for specified::MathDepth {
|
|||||||
|
|
||||||
/// - Use a signed 8.8 fixed-point value (representable range -128.0..128)
|
/// - Use a signed 8.8 fixed-point value (representable range -128.0..128)
|
||||||
///
|
///
|
||||||
/// Values of <angle> below -90 or above 90 not permitted, so we use out of
|
/// Values of <angle> below -90 or above 90 are not permitted, so we use an out
|
||||||
/// range values to represent normal | oblique
|
/// of range value to represent `italic`.
|
||||||
pub const FONT_STYLE_FRACTION_BITS: u16 = 8;
|
pub const FONT_STYLE_FRACTION_BITS: u16 = 8;
|
||||||
|
|
||||||
/// This is an alias which is useful mostly as a cbindgen / C++ inference
|
/// This is an alias which is useful mostly as a cbindgen / C++ inference
|
||||||
@@ -1060,10 +1060,9 @@ pub type FontStyleFixedPoint = FixedPoint<i16, FONT_STYLE_FRACTION_BITS>;
|
|||||||
|
|
||||||
/// The computed value of `font-style`.
|
/// The computed value of `font-style`.
|
||||||
///
|
///
|
||||||
/// - Define out of range values min value (-128.0) as meaning 'normal'
|
/// - Define angle of zero degrees as `normal`
|
||||||
/// - Define max value (127.99609375) as 'italic'
|
/// - Define out-of-range value 100 degrees as `italic`
|
||||||
/// - Other values represent 'oblique <angle>'
|
/// - Other values represent `oblique <angle>`
|
||||||
/// - Note that 'oblique 0deg' is distinct from 'normal' (should it be?)
|
|
||||||
///
|
///
|
||||||
/// cbindgen:derive-lt
|
/// cbindgen:derive-lt
|
||||||
/// cbindgen:derive-lte
|
/// cbindgen:derive-lte
|
||||||
@@ -1086,13 +1085,14 @@ pub type FontStyleFixedPoint = FixedPoint<i16, FONT_STYLE_FRACTION_BITS>;
|
|||||||
pub struct FontStyle(FontStyleFixedPoint);
|
pub struct FontStyle(FontStyleFixedPoint);
|
||||||
|
|
||||||
impl FontStyle {
|
impl FontStyle {
|
||||||
/// The normal keyword.
|
/// The `normal` keyword, equal to `oblique` with angle zero.
|
||||||
pub const NORMAL: FontStyle = FontStyle(FontStyleFixedPoint {
|
pub const NORMAL: FontStyle = FontStyle(FontStyleFixedPoint {
|
||||||
value: 100 << FONT_STYLE_FRACTION_BITS,
|
value: 0 << FONT_STYLE_FRACTION_BITS,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The italic keyword.
|
/// The italic keyword.
|
||||||
pub const ITALIC: FontStyle = FontStyle(FontStyleFixedPoint {
|
pub const ITALIC: FontStyle = FontStyle(FontStyleFixedPoint {
|
||||||
value: 101 << FONT_STYLE_FRACTION_BITS,
|
value: 100 << FONT_STYLE_FRACTION_BITS,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The default angle for `font-style: oblique`.
|
/// The default angle for `font-style: oblique`.
|
||||||
@@ -1121,7 +1121,6 @@ impl FontStyle {
|
|||||||
|
|
||||||
/// Returns the oblique angle for this style.
|
/// Returns the oblique angle for this style.
|
||||||
pub fn oblique_degrees(&self) -> f32 {
|
pub fn oblique_degrees(&self) -> f32 {
|
||||||
debug_assert_ne!(*self, Self::NORMAL);
|
|
||||||
debug_assert_ne!(*self, Self::ITALIC);
|
debug_assert_ne!(*self, Self::ITALIC);
|
||||||
self.0.to_float()
|
self.0.to_float()
|
||||||
}
|
}
|
||||||
@@ -1138,12 +1137,12 @@ impl ToCss for FontStyle {
|
|||||||
if *self == Self::ITALIC {
|
if *self == Self::ITALIC {
|
||||||
return dest.write_str("italic");
|
return dest.write_str("italic");
|
||||||
}
|
}
|
||||||
if *self == Self::OBLIQUE {
|
dest.write_str("oblique")?;
|
||||||
return dest.write_str("oblique");
|
if *self != Self::OBLIQUE {
|
||||||
|
// It's not the default oblique amount, so append the angle in degrees.
|
||||||
|
dest.write_char(' ')?;
|
||||||
|
Angle::from_degrees(self.oblique_degrees()).to_css(dest)?;
|
||||||
}
|
}
|
||||||
dest.write_str("oblique ")?;
|
|
||||||
let angle = Angle::from_degrees(self.oblique_degrees());
|
|
||||||
angle.to_css(dest)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1153,12 +1152,6 @@ impl ToAnimatedValue for FontStyle {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_animated_value(self, _: &crate::values::animated::Context) -> Self::AnimatedValue {
|
fn to_animated_value(self, _: &crate::values::animated::Context) -> Self::AnimatedValue {
|
||||||
if self == Self::NORMAL {
|
|
||||||
// This allows us to animate between normal and oblique values. Per spec,
|
|
||||||
// https://drafts.csswg.org/css-fonts-4/#font-style-prop:
|
|
||||||
// Animation type: by computed value type; 'normal' animates as 'oblique 0deg'
|
|
||||||
return generics::FontStyle::Oblique(Angle::from_degrees(0.0));
|
|
||||||
}
|
|
||||||
if self == Self::ITALIC {
|
if self == Self::ITALIC {
|
||||||
return generics::FontStyle::Italic;
|
return generics::FontStyle::Italic;
|
||||||
}
|
}
|
||||||
@@ -1168,16 +1161,8 @@ impl ToAnimatedValue for FontStyle {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||||
match animated {
|
match animated {
|
||||||
generics::FontStyle::Normal => Self::NORMAL,
|
|
||||||
generics::FontStyle::Italic => Self::ITALIC,
|
generics::FontStyle::Italic => Self::ITALIC,
|
||||||
generics::FontStyle::Oblique(ref angle) => {
|
generics::FontStyle::Oblique(ref angle) => Self::oblique(angle.degrees()),
|
||||||
if angle.degrees() == 0.0 {
|
|
||||||
// Reverse the conversion done in to_animated_value()
|
|
||||||
Self::NORMAL
|
|
||||||
} else {
|
|
||||||
Self::oblique(angle.degrees())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
use crate::parser::{Parse, ParserContext};
|
use crate::parser::{Parse, ParserContext};
|
||||||
use crate::values::animated::ToAnimatedZero;
|
use crate::values::animated::ToAnimatedZero;
|
||||||
use crate::One;
|
use crate::{One, Zero};
|
||||||
use byteorder::{BigEndian, ReadBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt};
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
@@ -208,13 +208,18 @@ impl Parse for FontTag {
|
|||||||
ToResolvedValue,
|
ToResolvedValue,
|
||||||
ToShmem,
|
ToShmem,
|
||||||
)]
|
)]
|
||||||
|
#[value_info(other_values = "normal")]
|
||||||
pub enum FontStyle<Angle> {
|
pub enum FontStyle<Angle> {
|
||||||
#[animation(error)]
|
// Note that 'oblique 0deg' represents 'normal', and will serialize as such.
|
||||||
Normal,
|
|
||||||
#[animation(error)]
|
|
||||||
Italic,
|
|
||||||
#[value_info(starts_with_keyword)]
|
#[value_info(starts_with_keyword)]
|
||||||
Oblique(Angle),
|
Oblique(Angle),
|
||||||
|
#[animation(error)]
|
||||||
|
Italic,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Angle: Zero> FontStyle<Angle> {
|
||||||
|
/// Return the 'normal' value, which is represented as 'oblique 0deg'.
|
||||||
|
pub fn normal() -> Self { Self::Oblique(Angle::zero()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A generic value for the `font-size-adjust` property.
|
/// A generic value for the `font-size-adjust` property.
|
||||||
|
|||||||
@@ -257,13 +257,18 @@ impl ToCss for SpecifiedFontStyle {
|
|||||||
W: Write,
|
W: Write,
|
||||||
{
|
{
|
||||||
match *self {
|
match *self {
|
||||||
generics::FontStyle::Normal => dest.write_str("normal"),
|
|
||||||
generics::FontStyle::Italic => dest.write_str("italic"),
|
generics::FontStyle::Italic => dest.write_str("italic"),
|
||||||
generics::FontStyle::Oblique(ref angle) => {
|
generics::FontStyle::Oblique(ref angle) => {
|
||||||
dest.write_str("oblique")?;
|
// Not angle.is_zero() because we don't want to serialize
|
||||||
if *angle != Self::default_angle() {
|
// `oblique calc(0deg)` as `normal`.
|
||||||
dest.write_char(' ')?;
|
if *angle == Angle::zero() {
|
||||||
angle.to_css(dest)?;
|
dest.write_str("normal")?;
|
||||||
|
} else {
|
||||||
|
dest.write_str("oblique")?;
|
||||||
|
if *angle != Self::default_angle() {
|
||||||
|
dest.write_char(' ')?;
|
||||||
|
angle.to_css(dest)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
@@ -277,7 +282,7 @@ impl Parse for SpecifiedFontStyle {
|
|||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
Ok(try_match_ident_ignore_ascii_case! { input,
|
Ok(try_match_ident_ignore_ascii_case! { input,
|
||||||
"normal" => generics::FontStyle::Normal,
|
"normal" => generics::FontStyle::normal(),
|
||||||
"italic" => generics::FontStyle::Italic,
|
"italic" => generics::FontStyle::Italic,
|
||||||
"oblique" => {
|
"oblique" => {
|
||||||
let angle = input.try_parse(|input| Self::parse_angle(context, input))
|
let angle = input.try_parse(|input| Self::parse_angle(context, input))
|
||||||
@@ -294,16 +299,12 @@ impl ToComputedValue for SpecifiedFontStyle {
|
|||||||
|
|
||||||
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
|
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
|
||||||
match *self {
|
match *self {
|
||||||
Self::Normal => computed::FontStyle::NORMAL,
|
|
||||||
Self::Italic => computed::FontStyle::ITALIC,
|
Self::Italic => computed::FontStyle::ITALIC,
|
||||||
Self::Oblique(ref angle) => computed::FontStyle::oblique(angle.degrees()),
|
Self::Oblique(ref angle) => computed::FontStyle::oblique(angle.degrees()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
if *computed == computed::FontStyle::NORMAL {
|
|
||||||
return Self::Normal;
|
|
||||||
}
|
|
||||||
if *computed == computed::FontStyle::ITALIC {
|
if *computed == computed::FontStyle::ITALIC {
|
||||||
return Self::Italic;
|
return Self::Italic;
|
||||||
}
|
}
|
||||||
@@ -375,7 +376,7 @@ impl FontStyle {
|
|||||||
/// Return the `normal` value.
|
/// Return the `normal` value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn normal() -> Self {
|
pub fn normal() -> Self {
|
||||||
FontStyle::Specified(generics::FontStyle::Normal)
|
FontStyle::Specified(generics::FontStyle::normal())
|
||||||
}
|
}
|
||||||
|
|
||||||
system_font_methods!(FontStyle, font_style);
|
system_font_methods!(FontStyle, font_style);
|
||||||
|
|||||||
@@ -1025,8 +1025,7 @@ renaming_overrides_prefixing = true
|
|||||||
SERVO_FIXED_POINT_HELPERS(StyleFontStyle, int16_t, StyleFONT_STYLE_FRACTION_BITS);
|
SERVO_FIXED_POINT_HELPERS(StyleFontStyle, int16_t, StyleFONT_STYLE_FRACTION_BITS);
|
||||||
bool IsNormal() const { return *this == NORMAL; }
|
bool IsNormal() const { return *this == NORMAL; }
|
||||||
inline bool IsItalic() const;
|
inline bool IsItalic() const;
|
||||||
inline bool IsOblique() const;
|
inline float ObliqueAngle() const; // Not for use when IsItalic() is true
|
||||||
inline float ObliqueAngle() const; // Only for use when IsOblique() is true
|
|
||||||
inline float SlantAngle() const; // Returns angle for any font-style, including
|
inline float SlantAngle() const; // Returns angle for any font-style, including
|
||||||
// normal/italic as well as explicit oblique
|
// normal/italic as well as explicit oblique
|
||||||
"""
|
"""
|
||||||
@@ -1076,6 +1075,12 @@ renaming_overrides_prefixing = true
|
|||||||
float ToMilliseconds() const { return seconds * 1000.0f; }
|
float ToMilliseconds() const { return seconds * 1000.0f; }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
"ComputedFontStyleDescriptor" = """
|
||||||
|
inline static StyleComputedFontStyleDescriptor Normal() {
|
||||||
|
return StyleComputedFontStyleDescriptor::Oblique(0, 0);
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
"FontFaceSourceTechFlags" = """
|
"FontFaceSourceTechFlags" = """
|
||||||
inline static StyleFontFaceSourceTechFlags Empty() {
|
inline static StyleFontFaceSourceTechFlags Empty() {
|
||||||
return StyleFontFaceSourceTechFlags{0};
|
return StyleFontFaceSourceTechFlags{0};
|
||||||
|
|||||||
@@ -5429,11 +5429,11 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(
|
|||||||
longhands::font_size::SpecifiedValue::from_html_size(value as u8)
|
longhands::font_size::SpecifiedValue::from_html_size(value as u8)
|
||||||
},
|
},
|
||||||
FontStyle => {
|
FontStyle => {
|
||||||
style::values::specified::FontStyle::Specified(if value == structs::NS_FONT_STYLE_ITALIC {
|
specified::FontStyle::Specified(if value == structs::NS_FONT_STYLE_ITALIC {
|
||||||
FontStyle::Italic
|
FontStyle::Italic
|
||||||
} else {
|
} else {
|
||||||
debug_assert_eq!(value, structs::NS_FONT_STYLE_NORMAL);
|
debug_assert_eq!(value, structs::NS_FONT_STYLE_NORMAL);
|
||||||
FontStyle::Normal
|
FontStyle::normal()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value),
|
FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value),
|
||||||
@@ -8555,7 +8555,6 @@ pub unsafe extern "C" fn Servo_ParseFontShorthandForMatching(
|
|||||||
};
|
};
|
||||||
|
|
||||||
*style = match *specified_font_style {
|
*style = match *specified_font_style {
|
||||||
GenericFontStyle::Normal => FontStyle::NORMAL,
|
|
||||||
GenericFontStyle::Italic => FontStyle::ITALIC,
|
GenericFontStyle::Italic => FontStyle::ITALIC,
|
||||||
GenericFontStyle::Oblique(ref angle) => FontStyle::oblique(angle.degrees()),
|
GenericFontStyle::Oblique(ref angle) => FontStyle::oblique(angle.degrees()),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
[font-style-computed.html]
|
[font-style-computed.html]
|
||||||
expected:
|
|
||||||
if (os == "android") and fission: [OK, TIMEOUT]
|
|
||||||
[Property font-style value 'oblique calc(30deg + (sign(20cqw - 10px) * 5deg))']
|
[Property font-style value 'oblique calc(30deg + (sign(20cqw - 10px) * 5deg))']
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Property font-style value 'oblique 0deg']
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Property font-style value 'oblique calc(10deg - 10deg)']
|
|
||||||
expected: FAIL
|
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
[font-style-valid.html]
|
[font-style-valid.html]
|
||||||
expected:
|
|
||||||
if (os == "android") and fission: [OK, TIMEOUT]
|
|
||||||
[e.style['font-style'\] = "oblique calc(30deg + (sign(2cqw - 10px) * 5deg))" should set the property value]
|
[e.style['font-style'\] = "oblique calc(30deg + (sign(2cqw - 10px) * 5deg))" should set the property value]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[e.style['font-style'\] = "oblique 0deg" should set the property value]
|
|
||||||
expected: FAIL
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[font-style-parsing.html]
|
|
||||||
[Font-style (computed): 'oblique' followed by zero degrees is valid]
|
|
||||||
expected: FAIL
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>CSS Fonts: parsing 'normal' in the font-style descriptor</title>
|
||||||
|
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.org"/>
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-fonts/#descdef-font-face-font-style">
|
||||||
|
<meta name="assert" content="Ensure that although 'normal' equates to 'oblique 0deg', a following <angle> is not allowed.">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: test1;
|
||||||
|
font-style: normal;
|
||||||
|
src: local(Ahem);
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: test2;
|
||||||
|
font-style: oblique 0deg;
|
||||||
|
src: local(Ahem);
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: test3;
|
||||||
|
font-style: oblique 0deg 10deg;
|
||||||
|
src: local(Ahem);
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: test4;
|
||||||
|
font-style: normal 10deg;
|
||||||
|
src: local(Ahem);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const fonts = await document.fonts.load("12px test1");
|
||||||
|
assert_equals(fonts[0].style, "normal", "'normal' serializes as specified");
|
||||||
|
});
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const fonts = await document.fonts.load("12px test2");
|
||||||
|
assert_equals(fonts[0].style, "normal", "'oblique 0deg' serializes as 'normal'");
|
||||||
|
});
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const fonts = await document.fonts.load("12px test3");
|
||||||
|
assert_equals(fonts[0].style, "oblique 0deg 10deg", "oblique range serializes as specified");
|
||||||
|
});
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const fonts = await document.fonts.load("12px test4");
|
||||||
|
assert_equals(fonts[0].style, "normal", "'normal 10deg' is not a valid range");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -33,6 +33,8 @@ test_computed_value('font-style', 'oblique calc(10deg - 10deg)', 'normal');
|
|||||||
|
|
||||||
test_computed_value('font-style', 'oblique 10deg');
|
test_computed_value('font-style', 'oblique 10deg');
|
||||||
test_computed_value('font-style', 'oblique -10deg');
|
test_computed_value('font-style', 'oblique -10deg');
|
||||||
|
test_computed_value('font-style', 'oblique 14deg', 'oblique');
|
||||||
|
test_computed_value('font-style', 'oblique -14deg');
|
||||||
test_computed_value('font-style', 'oblique -90deg');
|
test_computed_value('font-style', 'oblique -90deg');
|
||||||
test_computed_value('font-style', 'oblique 90deg');
|
test_computed_value('font-style', 'oblique 90deg');
|
||||||
test_computed_value('font-style', 'oblique 10grad', 'oblique 9deg');
|
test_computed_value('font-style', 'oblique 10grad', 'oblique 9deg');
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ test_valid_value('font-style', 'oblique calc(10deg - 10deg)', 'oblique calc(0deg
|
|||||||
|
|
||||||
test_valid_value('font-style', 'oblique 10deg');
|
test_valid_value('font-style', 'oblique 10deg');
|
||||||
test_valid_value('font-style', 'oblique -10deg');
|
test_valid_value('font-style', 'oblique -10deg');
|
||||||
|
test_valid_value('font-style', 'oblique 14deg', 'oblique');
|
||||||
|
test_valid_value('font-style', 'oblique -14deg');
|
||||||
test_valid_value('font-style', 'oblique -90deg');
|
test_valid_value('font-style', 'oblique -90deg');
|
||||||
test_valid_value('font-style', 'oblique 90deg');
|
test_valid_value('font-style', 'oblique 90deg');
|
||||||
test_valid_value('font-style', 'oblique 10grad');
|
test_valid_value('font-style', 'oblique 10grad');
|
||||||
|
|||||||
@@ -126,7 +126,7 @@
|
|||||||
}
|
}
|
||||||
function createFontFaceRules(fontFaceFamily, descriptorName, expectedMatch, unexpectedMatch) {
|
function createFontFaceRules(fontFaceFamily, descriptorName, expectedMatch, unexpectedMatch) {
|
||||||
dynamicStyles.innerHTML =
|
dynamicStyles.innerHTML =
|
||||||
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-100-kerned.ttf'); "+ descriptorName + ": " + expectedMatch + "; }" +
|
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-100-kerned.ttf'); " + descriptorName + ": " + expectedMatch + "; }" +
|
||||||
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-200-kerned.ttf'); " + descriptorName + ": " + unexpectedMatch + "; }";
|
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-200-kerned.ttf'); " + descriptorName + ": " + unexpectedMatch + "; }";
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
@@ -179,8 +179,8 @@
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
testDescriptor("font-style", [
|
testDescriptor("font-style", [
|
||||||
{ value: "normal", testDescriptors: ["normal", "oblique 0deg", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "normal", testDescriptors: ["normal", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique 0deg", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
|
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
|
||||||
{ value: "oblique 20deg", testDescriptors: ["oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "oblique 20deg", testDescriptors: ["oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
{ value: "oblique 21deg", testDescriptors: ["oblique 21deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 20deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "oblique 21deg", testDescriptors: ["oblique 21deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 20deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
{ value: "oblique 10deg", testDescriptors: ["oblique 10deg", "oblique 5deg", "oblique 15deg 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
{ value: "oblique 10deg", testDescriptors: ["oblique 10deg", "oblique 5deg", "oblique 15deg 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
|
||||||
|
|||||||
Reference in New Issue
Block a user