@@ -159,12 +159,11 @@ impl NetHandler for FontFaceHandler {
159
159
self . 0 = match bytes. as_ref ( ) {
160
160
// WOFF (v1) files begin with 0x774F4646 ('wOFF' in ascii)
161
161
// See: <https://w3c.github.io/woff/woff1/spec/Overview.html#WOFFHeader>
162
- #[ cfg( any( feature = "woff" , feature = "woff2" ) ) ]
163
- [ b'w' , b'O' , b'F' , b'F' , ..] => FontFaceSourceFormatKeyword :: Woff
162
+ #[ cfg( any( feature = "woff-c" , feature = "woff-rust" ) ) ]
164
163
[ b'w' , b'O' , b'F' , b'F' , ..] => FontFaceSourceFormatKeyword :: Woff ,
165
164
// WOFF2 files begin with 0x774F4632 ('wOF2' in ascii)
166
165
// See: <https://w3c.github.io/woff/woff2/#woff20Header>
167
- #[ cfg( any( feature = "woff" , feature = "woff2 " ) ) ]
166
+ #[ cfg( any( feature = "woff-c " , feature = "woff-rust " ) ) ]
168
167
[ b'w' , b'O' , b'F' , b'2' , ..] => FontFaceSourceFormatKeyword :: Woff2 ,
169
168
// Opentype fonts with CFF data begin with 0x4F54544F ('OTTO' in ascii)
170
169
// See: <https://learn.microsoft.com/en-us/typography/opentype/spec/otff#organization-of-an-opentype-font>
@@ -180,21 +179,36 @@ impl NetHandler for FontFaceHandler {
180
179
}
181
180
182
181
// Satisfy rustc's mutability linting with woff feature both enabled/disabled
183
- #[ cfg( any( feature = "woff" , feature = "woff2 " ) ) ]
182
+ #[ cfg( any( feature = "woff-c " , feature = "woff-rust " ) ) ]
184
183
let mut bytes = bytes;
185
184
186
185
match self . 0 {
187
- #[ cfg( any( feature = "woff" , feature = "woff2" ) ) ]
186
+ #[ cfg( feature = "woff-c" ) ]
187
+ FontFaceSourceFormatKeyword :: Woff => {
188
+ #[ cfg( feature = "tracing" ) ]
189
+ tracing:: info!( "Decompressing woff1 font" ) ;
190
+
191
+ // Use woff crate to decompress font
192
+ let decompressed = woff:: version1:: decompress ( & bytes) ;
193
+
194
+ if let Some ( decompressed) = decompressed {
195
+ bytes = Bytes :: from ( decompressed) ;
196
+ } else {
197
+ #[ cfg( feature = "tracing" ) ]
198
+ tracing:: warn!( "Failed to decompress woff1 font" ) ;
199
+ }
200
+ }
201
+ #[ cfg( any( feature = "woff-c" , feature = "woff-rust" ) ) ]
188
202
FontFaceSourceFormatKeyword :: Woff2 => {
189
203
#[ cfg( feature = "tracing" ) ]
190
204
tracing:: info!( "Decompressing woff2 font" ) ;
191
205
192
206
// Use woff crate to decompress font
193
- #[ cfg( feature = "woff" ) ]
207
+ #[ cfg( feature = "woff-c " ) ]
194
208
let decompressed = woff:: version2:: decompress ( & bytes) ;
195
209
196
210
// Use woff2 crate to decompress font
197
- #[ cfg( feature = "woff2 " ) ]
211
+ #[ cfg( feature = "woff-rust " ) ]
198
212
let decompressed = woff2:: decode:: convert_woff2_to_ttf ( & mut bytes) . ok ( ) ;
199
213
200
214
if let Some ( decompressed) = decompressed {
0 commit comments