Skip to content

Commit

Permalink
servo: Merge #17846 - Allow nonstandard font-weight values for system…
Browse files Browse the repository at this point in the history
… fonts (from Manishearth:font-weight); r=upsuper

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1379895

Source-Repo: https://github.com/servo/servo
Source-Revision: b8ac4a7a2efabe11af1366207f9649982250c0e2

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 536b943224fcf4bc326817ca0586b748a4cd78ba
  • Loading branch information
Manishearth committed Jul 25, 2017
1 parent fba4d7c commit c5a2243
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 2 additions & 4 deletions servo/components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2022,10 +2022,8 @@ fn static_assert() {
${impl_simple_copy('font_weight', 'mFont.weight')}

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 <= 900);
debug_assert!(self.gecko.mFont.weight % 10 == 0);
unsafe { transmute(self.gecko.mFont.weight) }
debug_assert!(self.gecko.mFont.weight <= ::std::u16::MAX);
longhands::font_weight::computed_value::T(self.gecko.mFont.weight)
}

${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")}
Expand Down
8 changes: 6 additions & 2 deletions servo/components/style/properties/longhand/font.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ ${helpers.single_keyword_system("font-variant-caps",
pub mod computed_value {
/// As of CSS Fonts Module Level 3, only the following values are
/// 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)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub struct T(pub u16);
Expand All @@ -483,8 +486,9 @@ ${helpers.single_keyword_system("font-variant-caps",

/// Convert from an Gecko weight
pub fn from_gecko_weight(weight: u16) -> Self {
Self::from_int(weight as i32)
.expect("from_gecko_weight: called with invalid weight")
// we allow a wider range of weights than is parseable
// because system fonts may provide custom values
T(weight)
}

/// Weither this weight is bold
Expand Down

0 comments on commit c5a2243

Please sign in to comment.