@@ -15,13 +15,52 @@ pub struct FontFace {
1515 pub font_display : Option < FontDisplay > ,
1616}
1717
18+ impl core:: fmt:: Display for FontFace {
19+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
20+ write ! ( f, "@font-face {{" ) ?;
21+ write ! ( f, " font-family: {};" , self . font_family) ?;
22+ write ! ( f, " src: " ) ?;
23+ for src in & self . src {
24+ write ! ( f, "{}, " , src) ?;
25+ }
26+ write ! ( f, ";" ) ?;
27+ if let Some ( fs) = & self . font_style {
28+ write ! ( f, " font-style: {};" , fs) ?;
29+ }
30+ if let Some ( fw) = & self . font_weight {
31+ write ! ( f, " font-weight: {};" , fw) ?;
32+ }
33+ if let Some ( fd) = & self . font_display {
34+ write ! ( f, " font-display: {};" , fd) ?;
35+ }
36+ write ! ( f, "}}" )
37+ }
38+ }
39+
1840#[ allow( missing_docs) ]
1941#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , PartialEq ) ]
2042pub enum FontSrc {
2143 Local ( FontFamilyName ) ,
2244 Url ( FontUrl ) ,
2345}
2446
47+ impl core:: fmt:: Display for FontSrc {
48+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
49+ match self {
50+ Self :: Local ( ff) => write ! ( f, r#"local("{}")"# , ff) ,
51+ Self :: Url ( url) => {
52+ write ! ( f, r#"url("{}")"# , url. url) ?;
53+ if let Some ( formats) = & url. format {
54+ for format in formats {
55+ write ! ( f, r#" format("{}")"# , format) ?;
56+ }
57+ }
58+ Ok ( ( ) )
59+ }
60+ }
61+ }
62+ }
63+
2564#[ allow( missing_docs) ]
2665#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , PartialEq , Eq ) ]
2766pub struct FontUrl {
@@ -41,6 +80,18 @@ pub enum FontDisplay {
4180 Optional ,
4281}
4382
83+ impl core:: fmt:: Display for FontDisplay {
84+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
85+ match self {
86+ Self :: Auto => write ! ( f, "auto" ) ,
87+ Self :: Block => write ! ( f, "block" ) ,
88+ Self :: Swap => write ! ( f, "swap" ) ,
89+ Self :: Fallback => write ! ( f, "fallback" ) ,
90+ Self :: Optional => write ! ( f, "optional" ) ,
91+ }
92+ }
93+ }
94+
4495impl Default for FontFace {
4596 fn default ( ) -> Self {
4697 Self {
0 commit comments