mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Allow nonstandard font-weight values for system fonts
This commit is contained in:
parent
a35c8f08e2
commit
9c6f11c965
2 changed files with 8 additions and 6 deletions
|
@ -2022,10 +2022,8 @@ fn static_assert() {
|
||||||
${impl_simple_copy('font_weight', 'mFont.weight')}
|
${impl_simple_copy('font_weight', 'mFont.weight')}
|
||||||
|
|
||||||
pub fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T {
|
pub fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T {
|
||||||
debug_assert!(self.gecko.mFont.weight >= 100);
|
debug_assert!(self.gecko.mFont.weight <= ::std::u16::MAX);
|
||||||
debug_assert!(self.gecko.mFont.weight <= 900);
|
longhands::font_weight::computed_value::T(self.gecko.mFont.weight)
|
||||||
debug_assert!(self.gecko.mFont.weight % 10 == 0);
|
|
||||||
unsafe { transmute(self.gecko.mFont.weight) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")}
|
${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")}
|
||||||
|
|
|
@ -457,6 +457,9 @@ ${helpers.single_keyword_system("font-variant-caps",
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
/// As of CSS Fonts Module Level 3, only the following values are
|
/// As of CSS Fonts Module Level 3, only the following values are
|
||||||
/// valid: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
/// valid: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
||||||
|
///
|
||||||
|
/// However, system fonts may provide other values. Pango
|
||||||
|
/// may provide 350, 380, and 1000 (on top of the existing values), for example.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, ToCss)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, ToCss)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||||
pub struct T(pub u16);
|
pub struct T(pub u16);
|
||||||
|
@ -483,8 +486,9 @@ ${helpers.single_keyword_system("font-variant-caps",
|
||||||
|
|
||||||
/// Convert from an Gecko weight
|
/// Convert from an Gecko weight
|
||||||
pub fn from_gecko_weight(weight: u16) -> Self {
|
pub fn from_gecko_weight(weight: u16) -> Self {
|
||||||
Self::from_int(weight as i32)
|
// we allow a wider range of weights than is parseable
|
||||||
.expect("from_gecko_weight: called with invalid weight")
|
// because system fonts may provide custom values
|
||||||
|
T(weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weither this weight is bold
|
/// Weither this weight is bold
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue