aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-12 22:13:16 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-12 22:13:16 -0600
commit55a9abdf358dd8f05b06849f0d39b4e8ca8f6ba3 (patch)
treebeb67bd68e97e78b00440f53bf4573c891edac0a
parent1542a879a544ca4d32256748b1819567a5c3b6fa (diff)
parentdf79c8f8fa6f49d34dfe7e9946715bd7244662b0 (diff)
downloadservo-55a9abdf358dd8f05b06849f0d39b4e8ca8f6ba3.tar.gz
servo-55a9abdf358dd8f05b06849f0d39b4e8ca8f6ba3.zip
Auto merge of #6867 - frewsxcv:match-guard-and-similar, r=jdm
Utilize match guard; make methods more similar Make the structure for the `stretchiness` and `boldness` methods more similar <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6867) <!-- Reviewable:end -->
-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,