lewp_css/domain/at_rules/font_face/
font_face.rs1use {
5 super::{
6 FamilyName,
7 FontDisplay,
8 FontFaceAtRule,
9 FontFeatureSettings,
10 FontLanguageOverride,
11 FontStretch,
12 FontStyle,
13 FontWeight,
14 Source,
15 },
16 cssparser::UnicodeRange,
17};
18
19pub struct FontFace<'a>(pub &'a FontFaceAtRule);
21
22impl<'a> FontFace<'a> {
23 pub fn family(&self) -> &FamilyName {
25 self.0.family.as_ref().unwrap()
26 }
27
28 pub fn sources(&self) -> &Vec<Source> {
30 self.0.sources.as_ref().unwrap()
31 }
32
33 pub fn style(&self) -> FontStyle {
35 if let Some(ref value) = self.0.style {
36 *value
37 } else {
38 FontStyle::normal
39 }
40 }
41
42 pub fn weight(&self) -> FontWeight {
44 if let Some(ref value) = self.0.weight {
45 *value
46 } else {
47 FontWeight::normal
48 }
49 }
50
51 pub fn stretch(&self) -> FontStretch {
53 if let Some(ref value) = self.0.stretch {
54 *value
55 } else {
56 FontStretch::normal
57 }
58 }
59
60 pub fn display(&self) -> FontDisplay {
62 if let Some(ref value) = self.0.display {
63 *value
64 } else {
65 FontDisplay::auto
66 }
67 }
68
69 pub fn unicode_range(&self) -> Vec<UnicodeRange> {
71 if let Some(ref value) = self.0.unicode_range {
72 value.clone()
73 } else {
74 vec![UnicodeRange {
75 start: 0,
76 end: 0x10FFFF,
77 }]
78 }
79 }
80
81 pub fn feature_settings(&self) -> FontFeatureSettings {
83 if let Some(ref value) = self.0.feature_settings {
84 value.clone()
85 } else {
86 FontFeatureSettings::normal()
87 }
88 }
89
90 pub fn language_override(&self) -> FontLanguageOverride {
92 if let Some(ref value) = self.0.language_override {
93 *value
94 } else {
95 FontLanguageOverride::normal
96 }
97 }
98}