mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
This commit is contained in:
parent
37cd870a9e
commit
af879523ea
60 changed files with 921 additions and 836 deletions
|
@ -20,7 +20,8 @@ use platform::font_template::FontTemplateData;
|
|||
use std::{mem, ptr};
|
||||
use std::os::raw::{c_char, c_long};
|
||||
use std::sync::Arc;
|
||||
use style::computed_values::{font_stretch, font_weight};
|
||||
use style::computed_values::font_stretch::T as FontStretch;
|
||||
use style::computed_values::font_weight::T as FontWeight;
|
||||
use super::c_str_to_string;
|
||||
use text::glyph::GlyphId;
|
||||
use text::util::fixed_to_float;
|
||||
|
@ -134,8 +135,8 @@ impl FontHandleMethods for FontHandle {
|
|||
fn is_italic(&self) -> bool {
|
||||
unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 }
|
||||
}
|
||||
fn boldness(&self) -> font_weight::T {
|
||||
let default_weight = font_weight::T::normal();
|
||||
fn boldness(&self) -> FontWeight {
|
||||
let default_weight = FontWeight::normal();
|
||||
if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD as c_long == 0 } {
|
||||
default_weight
|
||||
} else {
|
||||
|
@ -145,9 +146,9 @@ impl FontHandleMethods for FontHandle {
|
|||
if valid {
|
||||
let weight =(*os2).usWeightClass as i32;
|
||||
if weight < 10 {
|
||||
font_weight::T::from_int(weight * 100).unwrap()
|
||||
FontWeight::from_int(weight * 100).unwrap()
|
||||
} else if weight >= 100 && weight < 1000 {
|
||||
font_weight::T::from_int(weight / 100 * 100).unwrap()
|
||||
FontWeight::from_int(weight / 100 * 100).unwrap()
|
||||
} else {
|
||||
default_weight
|
||||
}
|
||||
|
@ -157,9 +158,9 @@ impl FontHandleMethods for FontHandle {
|
|||
}
|
||||
}
|
||||
}
|
||||
fn stretchiness(&self) -> font_stretch::T {
|
||||
fn stretchiness(&self) -> FontStretch {
|
||||
// TODO(pcwalton): Implement this.
|
||||
font_stretch::T::normal
|
||||
FontStretch::Normal
|
||||
}
|
||||
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
|
||||
|
|
|
@ -21,7 +21,8 @@ use platform::macos::font_context::FontContextHandle;
|
|||
use std::{fmt, ptr};
|
||||
use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
use style::computed_values::{font_stretch, font_weight};
|
||||
use style::computed_values::font_stretch::T as FontStretch;
|
||||
use style::computed_values::font_weight::T as FontWeight;
|
||||
use text::glyph::GlyphId;
|
||||
|
||||
const KERN_PAIR_LEN: usize = 6;
|
||||
|
@ -210,29 +211,29 @@ impl FontHandleMethods for FontHandle {
|
|||
self.ctfont.symbolic_traits().is_italic()
|
||||
}
|
||||
|
||||
fn boldness(&self) -> font_weight::T {
|
||||
fn boldness(&self) -> FontWeight {
|
||||
let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0]
|
||||
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
|
||||
font_weight::T::from_int(normalized.round() as i32 * 100).unwrap()
|
||||
FontWeight::from_int(normalized.round() as i32 * 100).unwrap()
|
||||
}
|
||||
|
||||
fn stretchiness(&self) -> font_stretch::T {
|
||||
fn stretchiness(&self) -> FontStretch {
|
||||
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,
|
||||
v if v < 4.0 => font_stretch::T::semi_condensed,
|
||||
v if v < 5.0 => font_stretch::T::normal,
|
||||
v if v < 6.0 => font_stretch::T::semi_expanded,
|
||||
v if v < 7.0 => font_stretch::T::expanded,
|
||||
v if v < 8.0 => font_stretch::T::extra_expanded,
|
||||
_ => font_stretch::T::ultra_expanded,
|
||||
v if v < 1.0 => FontStretch::UltraCondensed,
|
||||
v if v < 2.0 => FontStretch::ExtraCondensed,
|
||||
v if v < 3.0 => FontStretch::Condensed,
|
||||
v if v < 4.0 => FontStretch::SemiCondensed,
|
||||
v if v < 5.0 => FontStretch::Normal,
|
||||
v if v < 6.0 => FontStretch::SemiExpanded,
|
||||
v if v < 7.0 => FontStretch::Expanded,
|
||||
v if v < 8.0 => FontStretch::ExtraExpanded,
|
||||
_ => FontStretch::UltraExpanded,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ use platform::font_template::FontTemplateData;
|
|||
use platform::windows::font_context::FontContextHandle;
|
||||
use platform::windows::font_list::font_from_atom;
|
||||
use std::sync::Arc;
|
||||
use style::computed_values::{font_stretch, font_weight};
|
||||
use style::computed_values::font_stretch::T as StyleFontStretch;
|
||||
use style::computed_values::font_weight::T as StyleFontWeight;
|
||||
use text::glyph::GlyphId;
|
||||
use truetype;
|
||||
|
||||
|
@ -94,8 +95,8 @@ fn get_family_face_indices(records: &[truetype::naming_table::Record]) -> Option
|
|||
struct FontInfo {
|
||||
family_name: String,
|
||||
face_name: String,
|
||||
weight: font_weight::T,
|
||||
stretch: font_stretch::T,
|
||||
weight: StyleFontWeight,
|
||||
stretch: StyleFontStretch,
|
||||
style: FontStyle,
|
||||
}
|
||||
|
||||
|
@ -155,19 +156,21 @@ impl FontInfo {
|
|||
},
|
||||
};
|
||||
|
||||
let weight = font_weight::T::
|
||||
from_int(min(9, max(1, weight_val as i32 / 100)) * 100).unwrap();
|
||||
let weight =
|
||||
StyleFontWeight::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,
|
||||
2 => font_stretch::T::extra_condensed,
|
||||
3 => font_stretch::T::condensed,
|
||||
4 => font_stretch::T::semi_condensed,
|
||||
5 => font_stretch::T::normal,
|
||||
6 => font_stretch::T::semi_expanded,
|
||||
7 => font_stretch::T::expanded,
|
||||
8 => font_stretch::T::extra_expanded,
|
||||
9 => font_stretch::T::ultra_expanded,
|
||||
1 => StyleFontStretch::UltraCondensed,
|
||||
2 => StyleFontStretch::ExtraCondensed,
|
||||
3 => StyleFontStretch::Condensed,
|
||||
4 => StyleFontStretch::SemiCondensed,
|
||||
5 => StyleFontStretch::Normal,
|
||||
6 => StyleFontStretch::SemiExpanded,
|
||||
7 => StyleFontStretch::Expanded,
|
||||
8 => StyleFontStretch::ExtraExpanded,
|
||||
9 => StyleFontStretch::UltraExpanded,
|
||||
_ => return Err(()),
|
||||
};
|
||||
|
||||
|
@ -188,7 +191,7 @@ impl FontInfo {
|
|||
|
||||
fn new_from_font(font: &Font) -> Result<FontInfo, ()> {
|
||||
let style = font.style();
|
||||
let weight = font_weight::T(match font.weight() {
|
||||
let weight = StyleFontWeight(match font.weight() {
|
||||
FontWeight::Thin => 100,
|
||||
FontWeight::ExtraLight => 200,
|
||||
FontWeight::Light => 300,
|
||||
|
@ -204,16 +207,16 @@ impl FontInfo {
|
|||
FontWeight::ExtraBlack => 900,
|
||||
});
|
||||
let stretch = match font.stretch() {
|
||||
FontStretch::Undefined => font_stretch::T::normal,
|
||||
FontStretch::UltraCondensed => font_stretch::T::ultra_condensed,
|
||||
FontStretch::ExtraCondensed => font_stretch::T::extra_condensed,
|
||||
FontStretch::Condensed => font_stretch::T::condensed,
|
||||
FontStretch::SemiCondensed => font_stretch::T::semi_condensed,
|
||||
FontStretch::Normal => font_stretch::T::normal,
|
||||
FontStretch::SemiExpanded => font_stretch::T::semi_expanded,
|
||||
FontStretch::Expanded => font_stretch::T::expanded,
|
||||
FontStretch::ExtraExpanded => font_stretch::T::extra_expanded,
|
||||
FontStretch::UltraExpanded => font_stretch::T::ultra_expanded,
|
||||
FontStretch::Undefined => StyleFontStretch::Normal,
|
||||
FontStretch::UltraCondensed => StyleFontStretch::UltraCondensed,
|
||||
FontStretch::ExtraCondensed => StyleFontStretch::ExtraCondensed,
|
||||
FontStretch::Condensed => StyleFontStretch::Condensed,
|
||||
FontStretch::SemiCondensed => StyleFontStretch::SemiCondensed,
|
||||
FontStretch::Normal => StyleFontStretch::Normal,
|
||||
FontStretch::SemiExpanded => StyleFontStretch::SemiExpanded,
|
||||
FontStretch::Expanded => StyleFontStretch::Expanded,
|
||||
FontStretch::ExtraExpanded => StyleFontStretch::ExtraExpanded,
|
||||
FontStretch::UltraExpanded => StyleFontStretch::UltraExpanded,
|
||||
};
|
||||
|
||||
Ok(FontInfo {
|
||||
|
@ -300,11 +303,11 @@ impl FontHandleMethods for FontHandle {
|
|||
}
|
||||
}
|
||||
|
||||
fn boldness(&self) -> font_weight::T {
|
||||
fn boldness(&self) -> StyleFontWeight {
|
||||
self.info.weight
|
||||
}
|
||||
|
||||
fn stretchiness(&self) -> font_stretch::T {
|
||||
fn stretchiness(&self) -> StyleFontStretch {
|
||||
self.info.stretch
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue