import { FontCatalogConfig } from "@here/harp-datasource-protocol" ; import { FontCatalog } from "@here/harp-text-canvas" ; import { LoggerManager } from "@here/harp-utils" ; const logger = LoggerManager . instance . create ( "FontCatalogLoader" ) ; type FontCatalogCallback = ( name : string , catalog : FontCatalog ) => void ; export async function loadFontCatalog ( fontCatalogConfig , onSuccess , onError ? ) { return await FontCatalog . load ( fontCatalogConfig . url , 1024 ) . then < void > ( onSuccess . bind ( undefined , fontCatalogConfig . name ) ) . catch ( ( error ) => { logger . error ( "Failed to load FontCatalog: " , fontCatalogConfig . name , error ) ; if ( onError ) { onError ( error ) ; } } ) ; }