@@ -159,12 +159,11 @@ impl NetHandler for FontFaceHandler {
159159 self . 0 = match bytes. as_ref ( ) {
160160 // WOFF (v1) files begin with 0x774F4646 ('wOFF' in ascii)
161161 // 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" ) ) ]
164163 [ b'w' , b'O' , b'F' , b'F' , ..] => FontFaceSourceFormatKeyword :: Woff ,
165164 // WOFF2 files begin with 0x774F4632 ('wOF2' in ascii)
166165 // See: <https://w3c.github.io/woff/woff2/#woff20Header>
167- #[ cfg( any( feature = "woff" , feature = "woff2 " ) ) ]
166+ #[ cfg( any( feature = "woff-c " , feature = "woff-rust " ) ) ]
168167 [ b'w' , b'O' , b'F' , b'2' , ..] => FontFaceSourceFormatKeyword :: Woff2 ,
169168 // Opentype fonts with CFF data begin with 0x4F54544F ('OTTO' in ascii)
170169 // See: <https://learn.microsoft.com/en-us/typography/opentype/spec/otff#organization-of-an-opentype-font>
@@ -180,21 +179,36 @@ impl NetHandler for FontFaceHandler {
180179 }
181180
182181 // 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 " ) ) ]
184183 let mut bytes = bytes;
185184
186185 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" ) ) ]
188202 FontFaceSourceFormatKeyword :: Woff2 => {
189203 #[ cfg( feature = "tracing" ) ]
190204 tracing:: info!( "Decompressing woff2 font" ) ;
191205
192206 // Use woff crate to decompress font
193- #[ cfg( feature = "woff" ) ]
207+ #[ cfg( feature = "woff-c " ) ]
194208 let decompressed = woff:: version2:: decompress ( & bytes) ;
195209
196210 // Use woff2 crate to decompress font
197- #[ cfg( feature = "woff2 " ) ]
211+ #[ cfg( feature = "woff-rust " ) ]
198212 let decompressed = woff2:: decode:: convert_woff2_to_ttf ( & mut bytes) . ok ( ) ;
199213
200214 if let Some ( decompressed) = decompressed {
0 commit comments