@@ -258,49 +258,33 @@ fn svg_to_bytes(
258258 log:: set_max_level ( log:: LevelFilter :: Warn ) ;
259259 }
260260 }
261- let os = std:: env:: consts:: OS ;
262- match os {
263- "windows" | "macos" => {
264- if font_family. is_none ( ) {
265- font_family = Some ( "Times New Roman" . to_owned ( ) ) ;
266- }
267- if serif_family. is_none ( ) {
268- serif_family = Some ( "Times New Roman" . to_owned ( ) ) ;
269- }
270- if sans_serif_family. is_none ( ) {
271- sans_serif_family = Some ( "Arial" . to_owned ( ) ) ;
272- }
273- if cursive_family. is_none ( ) {
274- cursive_family = Some ( "Comic Sans MS" . to_owned ( ) ) ;
275- }
276- if fantasy_family. is_none ( ) {
277- fantasy_family = Some ( "Impact" . to_owned ( ) ) ;
278- }
279- if monospace_family. is_none ( ) {
280- monospace_family = Some ( "Courier New" . to_owned ( ) ) ;
281- }
282- }
283- "linux" => {
284- if font_family. is_none ( ) {
285- font_family = Some ( "Liberation Serif" . to_owned ( ) ) ;
286- }
287- if serif_family. is_none ( ) {
288- serif_family = Some ( "Liberation Serif" . to_owned ( ) ) ;
289- }
290- if sans_serif_family. is_none ( ) {
291- sans_serif_family = Some ( "Liberation Sans" . to_owned ( ) ) ;
292- }
293- if cursive_family. is_none ( ) {
294- cursive_family = Some ( "Comic Neue" . to_owned ( ) ) ;
295- }
296- if fantasy_family. is_none ( ) {
297- fantasy_family = Some ( "Anton" . to_owned ( ) ) ;
298- }
299- if monospace_family. is_none ( ) {
300- monospace_family = Some ( "Liberation Mono" . to_owned ( ) ) ;
301- }
261+
262+ let none_or_take = |item : Option < String > , otherwise : & str |{
263+ if item. is_none ( ) {
264+ Some ( otherwise. to_owned ( ) )
265+ } else {
266+ item
302267 }
303- _ => panic ! ( "Unsupported operating system: {}" , os) ,
268+ } ;
269+
270+ #[ cfg( any( target_os = "windows" , target_os = "macos" ) ) ]
271+ {
272+ font_family = none_or_take ( font_family, "Times New Roman" ) ;
273+ serif_family = none_or_take ( serif_family, "Times New Roman" ) ;
274+ sans_serif_family = none_or_take ( sans_serif_family, "Arial" ) ;
275+ cursive_family = none_or_take ( cursive_family, "Comic Sans MS" ) ;
276+ fantasy_family = none_or_take ( fantasy_family, "Impact" ) ;
277+ monospace_family = none_or_take ( monospace_family, "Courier New" ) ;
278+ }
279+
280+ #[ cfg( target_os="linux" ) ]
281+ {
282+ font_family = none_or_take ( font_family, "Liberation Serif" ) ;
283+ serif_family = none_or_take ( serif_family, "Liberation Serif" ) ;
284+ sans_serif_family = none_or_take ( sans_serif_family, "Liberation Sans" ) ;
285+ cursive_family = none_or_take ( cursive_family, "Comic Neue" ) ;
286+ fantasy_family = none_or_take ( fantasy_family, "Anton" ) ;
287+ monospace_family = none_or_take ( monospace_family, "Liberation Mono" ) ;
304288 }
305289
306290 let mut _svg_string = String :: new ( ) ;
0 commit comments