aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/platform/macos
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2015-07-31 20:18:13 +0700
committerCorey Farwell <coreyf@rwell.org>2015-08-11 18:28:50 -0400
commitdf79c8f8fa6f49d34dfe7e9946715bd7244662b0 (patch)
tree825cd16f40e41351cc8e0f391a030f3ccc7dad8d /components/gfx/platform/macos
parent7dc83e7820df43b1b617ae8dcf661398b0bd0842 (diff)
downloadservo-df79c8f8fa6f49d34dfe7e9946715bd7244662b0.tar.gz
servo-df79c8f8fa6f49d34dfe7e9946715bd7244662b0.zip
Utilize match guard; make methods more similar
Make the structure for the `stretchiness` and `boldness` methods more similar
Diffstat (limited to 'components/gfx/platform/macos')
-rw-r--r--components/gfx/platform/macos/font.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs
index 6ef613572d5..dac669d2215 100644
--- a/components/gfx/platform/macos/font.rs
+++ b/components/gfx/platform/macos/font.rs
@@ -94,24 +94,25 @@ impl FontHandleMethods for FontHandle {
}
fn boldness(&self) -> font_weight::T {
- // -1.0 to 1.0
- let normalized = self.ctfont.all_traits().normalized_weight();
- // 0.0 to 9.0
- let normalized = (normalized + 1.0) / 2.0 * 9.0;
- if normalized < 1.0 { return font_weight::T::Weight100; }
- if normalized < 2.0 { return font_weight::T::Weight200; }
- if normalized < 3.0 { return font_weight::T::Weight300; }
- if normalized < 4.0 { return font_weight::T::Weight400; }
- if normalized < 5.0 { return font_weight::T::Weight500; }
- if normalized < 6.0 { return font_weight::T::Weight600; }
- if normalized < 7.0 { return font_weight::T::Weight700; }
- if normalized < 8.0 { return font_weight::T::Weight800; }
- return font_weight::T::Weight900;
+ let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0]
+ let normalized = (normalized + 1.0) / 2.0 * 9.0; // [0.0, 9.0]
+ match normalized {
+ v if v < 1.0 => font_weight::T::Weight100,
+ v if v < 2.0 => font_weight::T::Weight200,
+ v if v < 3.0 => font_weight::T::Weight300,
+ v if v < 4.0 => font_weight::T::Weight400,
+ v if v < 5.0 => font_weight::T::Weight500,
+ v if v < 6.0 => font_weight::T::Weight600,
+ v if v < 7.0 => font_weight::T::Weight700,
+ v if v < 8.0 => font_weight::T::Weight800,
+ _ => font_weight::T::Weight900,
+ }
}
fn stretchiness(&self) -> font_stretch::T {
- let normalized = self.ctfont.all_traits().normalized_width(); // [-1.0, 1.0]
- match (normalized + 1.0) / 2.0 * 9.0 { // [0.0, 9.0]
+ let normalized = self.ctfont.all_traits().normalized_width(); // [-1.0, 1.0]
+ let normalized = (normalized + 1.0) / 2.0 * 9.0; // [0.0, 9.0]
+ match normalized {
v if v < 1.0 => font_stretch::T::ultra_condensed,
v if v < 2.0 => font_stretch::T::extra_condensed,
v if v < 3.0 => font_stretch::T::condensed,