mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Fixups for css-fonts-4 font-weight.
This commit is contained in:
parent
0f19c25706
commit
48de556f8c
10 changed files with 51 additions and 64 deletions
|
@ -210,12 +210,14 @@ impl FontHandleMethods for FontHandle {
|
|||
|
||||
fn boldness(&self) -> FontWeight {
|
||||
let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0]
|
||||
// TODO(emilio): It may make sense to make this range [.01, 10.0], to
|
||||
// align with css-fonts-4's range of [1, 1000].
|
||||
let normalized = if normalized <= 0.0 {
|
||||
4.0 + normalized * 3.0 // [1.0, 4.0]
|
||||
} else {
|
||||
4.0 + normalized * 5.0 // [4.0, 9.0]
|
||||
}; // [1.0, 9.0], centered on 4.0
|
||||
FontWeight::from_int(normalized.round() as i32 * 100).unwrap()
|
||||
FontWeight(normalized as f32 * 100.)
|
||||
}
|
||||
|
||||
fn stretchiness(&self) -> FontStretch {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue