aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/platform/windows/font.rs
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2017-07-06 15:31:24 +1000
committerXidorn Quan <me@upsuper.org>2017-07-06 15:31:24 +1000
commit8b842f54178140254990fbc0a99677f93934e295 (patch)
treef134a79689485d14fa7f3cad7e9f6e38bccfa37e /components/gfx/platform/windows/font.rs
parent4f0f2fb13eb1e3ce8bf0c5be9749f830545f0bb5 (diff)
downloadservo-8b842f54178140254990fbc0a99677f93934e295.tar.gz
servo-8b842f54178140254990fbc0a99677f93934e295.zip
Use integer for specified and computed font-weight
Diffstat (limited to 'components/gfx/platform/windows/font.rs')
-rw-r--r--components/gfx/platform/windows/font.rs40
1 files changed, 15 insertions, 25 deletions
diff --git a/components/gfx/platform/windows/font.rs b/components/gfx/platform/windows/font.rs
index 1778c9a603f..38a2e6e0db3 100644
--- a/components/gfx/platform/windows/font.rs
+++ b/components/gfx/platform/windows/font.rs
@@ -155,18 +155,8 @@ impl FontInfo {
},
};
- let weight = match min(9, max(1, weight_val / 100)) {
- 1 => font_weight::T::Weight100,
- 2 => font_weight::T::Weight200,
- 3 => font_weight::T::Weight300,
- 4 => font_weight::T::Weight400,
- 5 => font_weight::T::Weight500,
- 6 => font_weight::T::Weight600,
- 7 => font_weight::T::Weight700,
- 8 => font_weight::T::Weight800,
- 9 => font_weight::T::Weight900,
- _ => return Err(()),
- };
+ let weight = font_weight::T::
+ from_int(min(9, max(1, weight_val as i32 / 100)) * 100).unwrap();
let stretch = match min(9, max(1, width_val)) {
1 => font_stretch::T::ultra_condensed,
@@ -198,21 +188,21 @@ impl FontInfo {
fn new_from_font(font: &Font) -> Result<FontInfo, ()> {
let style = font.style();
- let weight = match font.weight() {
- FontWeight::Thin => font_weight::T::Weight100,
- FontWeight::ExtraLight => font_weight::T::Weight200,
- FontWeight::Light => font_weight::T::Weight300,
+ let weight = font_weight::T(match font.weight() {
+ FontWeight::Thin => 100,
+ FontWeight::ExtraLight => 200,
+ FontWeight::Light => 300,
// slightly grayer gray
- FontWeight::SemiLight => font_weight::T::Weight300,
- FontWeight::Regular => font_weight::T::Weight400,
- FontWeight::Medium => font_weight::T::Weight500,
- FontWeight::SemiBold => font_weight::T::Weight600,
- FontWeight::Bold => font_weight::T::Weight700,
- FontWeight::ExtraBold => font_weight::T::Weight800,
- FontWeight::Black => font_weight::T::Weight900,
+ FontWeight::SemiLight => 300,
+ FontWeight::Regular => 400,
+ FontWeight::Medium => 500,
+ FontWeight::SemiBold => 600,
+ FontWeight::Bold => 700,
+ FontWeight::ExtraBold => 800,
+ FontWeight::Black => 900,
// slightly blacker black
- FontWeight::ExtraBlack => font_weight::T::Weight900,
- };
+ FontWeight::ExtraBlack => 900,
+ });
let stretch = match font.stretch() {
FontStretch::Undefined => font_stretch::T::normal,
FontStretch::UltraCondensed => font_stretch::T::ultra_condensed,