@@ -359,10 +359,8 @@ fn open_file(open: Option<&str>, path: &Path) -> StrResult<()> {
359359/// Execute a font listing command.
360360fn fonts ( command : FontsSettings ) -> StrResult < ( ) > {
361361 let mut searcher = FontSearcher :: new ( ) ;
362- searcher. search_system ( ) ;
363- for path in & command. font_paths {
364- searcher. search_dir ( path)
365- }
362+ searcher. search ( & command. font_paths ) ;
363+
366364 for ( name, infos) in searcher. book . families ( ) {
367365 println ! ( "{name}" ) ;
368366 if command. variants {
@@ -405,14 +403,7 @@ struct PathSlot {
405403impl SystemWorld {
406404 fn new ( root : PathBuf , font_paths : & [ PathBuf ] ) -> Self {
407405 let mut searcher = FontSearcher :: new ( ) ;
408- searcher. search_system ( ) ;
409-
410- #[ cfg( feature = "embed-fonts" ) ]
411- searcher. add_embedded ( ) ;
412-
413- for path in font_paths {
414- searcher. search_dir ( path)
415- }
406+ searcher. search ( font_paths) ;
416407
417408 Self {
418409 root,
@@ -624,10 +615,22 @@ impl FontSearcher {
624615 Self { book : FontBook :: new ( ) , fonts : vec ! [ ] }
625616 }
626617
618+ /// Search everything that is available.
619+ fn search ( & mut self , font_paths : & [ PathBuf ] ) {
620+ self . search_system ( ) ;
621+
622+ #[ cfg( feature = "embed-fonts" ) ]
623+ self . search_embedded ( ) ;
624+
625+ for path in font_paths {
626+ self . search_dir ( path)
627+ }
628+ }
629+
627630 /// Add fonts that are embedded in the binary.
628631 #[ cfg( feature = "embed-fonts" ) ]
629- fn add_embedded ( & mut self ) {
630- let mut add = |bytes : & ' static [ u8 ] | {
632+ fn search_embedded ( & mut self ) {
633+ let mut search = |bytes : & ' static [ u8 ] | {
631634 let buffer = Buffer :: from_static ( bytes) ;
632635 for ( i, font) in Font :: iter ( buffer) . enumerate ( ) {
633636 self . book . push ( font. info ( ) . clone ( ) ) ;
@@ -640,20 +643,20 @@ impl FontSearcher {
640643 } ;
641644
642645 // Embed default fonts.
643- add ( include_bytes ! ( "../../assets/fonts/LinLibertine_R.ttf" ) ) ;
644- add ( include_bytes ! ( "../../assets/fonts/LinLibertine_RB.ttf" ) ) ;
645- add ( include_bytes ! ( "../../assets/fonts/LinLibertine_RBI.ttf" ) ) ;
646- add ( include_bytes ! ( "../../assets/fonts/LinLibertine_RI.ttf" ) ) ;
647- add ( include_bytes ! ( "../../assets/fonts/NewCMMath-Book.otf" ) ) ;
648- add ( include_bytes ! ( "../../assets/fonts/NewCMMath-Regular.otf" ) ) ;
649- add ( include_bytes ! ( "../../assets/fonts/NewCM10-Regular.otf" ) ) ;
650- add ( include_bytes ! ( "../../assets/fonts/NewCM10-Bold.otf" ) ) ;
651- add ( include_bytes ! ( "../../assets/fonts/NewCM10-Italic.otf" ) ) ;
652- add ( include_bytes ! ( "../../assets/fonts/NewCM10-BoldItalic.otf" ) ) ;
653- add ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono.ttf" ) ) ;
654- add ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono-Bold.ttf" ) ) ;
655- add ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono-Oblique.ttf" ) ) ;
656- add ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono-BoldOblique.ttf" ) ) ;
646+ search ( include_bytes ! ( "../../assets/fonts/LinLibertine_R.ttf" ) ) ;
647+ search ( include_bytes ! ( "../../assets/fonts/LinLibertine_RB.ttf" ) ) ;
648+ search ( include_bytes ! ( "../../assets/fonts/LinLibertine_RBI.ttf" ) ) ;
649+ search ( include_bytes ! ( "../../assets/fonts/LinLibertine_RI.ttf" ) ) ;
650+ search ( include_bytes ! ( "../../assets/fonts/NewCMMath-Book.otf" ) ) ;
651+ search ( include_bytes ! ( "../../assets/fonts/NewCMMath-Regular.otf" ) ) ;
652+ search ( include_bytes ! ( "../../assets/fonts/NewCM10-Regular.otf" ) ) ;
653+ search ( include_bytes ! ( "../../assets/fonts/NewCM10-Bold.otf" ) ) ;
654+ search ( include_bytes ! ( "../../assets/fonts/NewCM10-Italic.otf" ) ) ;
655+ search ( include_bytes ! ( "../../assets/fonts/NewCM10-BoldItalic.otf" ) ) ;
656+ search ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono.ttf" ) ) ;
657+ search ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono-Bold.ttf" ) ) ;
658+ search ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono-Oblique.ttf" ) ) ;
659+ search ( include_bytes ! ( "../../assets/fonts/DejaVuSansMono-BoldOblique.ttf" ) ) ;
657660 }
658661
659662 /// Search for fonts in the linux system font directories.
0 commit comments