@@ -597,39 +597,57 @@ export class InnerPlayer {
597
597
builder . setVolume ( this . volumeSettings . get_volume ( ) ) ;
598
598
599
599
if ( this . loadedConfig ?. fontSources ) {
600
- for ( const key in this . loadedConfig . fontSources ) {
601
- const fontSource = this . loadedConfig . fontSources [ key ] ;
602
- if ( typeof fontSource === "string" ) {
603
- // Handle old format (array of strings)
604
- try {
605
- const response = await fetch ( fontSource ) ;
606
- builder . addFont (
607
- fontSource ,
608
- null , // No custom name
609
- null , // No bold override
610
- null , // No italic override
611
- new Uint8Array ( await response . arrayBuffer ( ) ) ,
612
- ) ;
613
- } catch ( error ) {
614
- console . warn ( `Couldn't download font source from ${ fontSource } ` , error ) ;
615
- }
616
- } else if ( typeof fontSource === "object" ) {
617
- // Handle new format (object with additional properties)
618
- for ( const [ url , fontInfo ] of Object . entries ( fontSource ) ) {
600
+ const fontSources = this . loadedConfig . fontSources ;
601
+ if ( Array . isArray ( fontSources ) ) {
602
+ for ( const fontSource of fontSources ) {
603
+ if ( typeof fontSource === "string" ) {
604
+ // Handle old format (array of strings)
619
605
try {
620
- const response = await fetch ( url ) ;
606
+ const response = await fetch ( fontSource ) ;
621
607
builder . addFont (
622
- url ,
623
- fontInfo ?. [ 'name' ] || null ,
624
- fontInfo ?. [ 'bold' ] ?? null ,
625
- fontInfo ?. [ 'italics' ] ?? null ,
608
+ fontSource ,
609
+ null , // No custom name
610
+ null , // No bold override
611
+ null , // No italic override
626
612
new Uint8Array ( await response . arrayBuffer ( ) ) ,
627
613
) ;
628
614
} catch ( error ) {
629
- console . warn ( `Couldn't download font source from ${ key } ` , error ) ;
615
+ console . warn ( `Couldn't download font source from ${ fontSource } ` , error ) ;
616
+ }
617
+ } else if ( typeof fontSource === "object" ) {
618
+ // Handle new format (object with additional properties)
619
+ for ( const [ url , fontInfo ] of Object . entries ( fontSource ) ) {
620
+ try {
621
+ const response = await fetch ( url ) ;
622
+ builder . addFont (
623
+ url ,
624
+ fontInfo ?. [ 'name' ] || null ,
625
+ fontInfo ?. [ 'bold' ] ?? null ,
626
+ fontInfo ?. [ 'italics' ] ?? null ,
627
+ new Uint8Array ( await response . arrayBuffer ( ) ) ,
628
+ ) ;
629
+ } catch ( error ) {
630
+ console . warn ( `Couldn't download font source from ${ url } ` , error ) ;
631
+ }
630
632
}
631
633
}
632
634
}
635
+ } else if ( typeof fontSources === "object" ) {
636
+ // Handle the case where fontSources is a plain object
637
+ for ( const [ url , fontInfo ] of Object . entries ( fontSources ) ) {
638
+ try {
639
+ const response = await fetch ( url ) ;
640
+ builder . addFont (
641
+ url ,
642
+ fontInfo ?. [ 'name' ] || null ,
643
+ fontInfo ?. [ 'bold' ] ?? null ,
644
+ fontInfo ?. [ 'italics' ] ?? null ,
645
+ new Uint8Array ( await response . arrayBuffer ( ) ) ,
646
+ ) ;
647
+ } catch ( error ) {
648
+ console . warn ( `Couldn't download font source from ${ url } ` , error ) ;
649
+ }
650
+ }
633
651
}
634
652
}
635
653
0 commit comments