/** * Fontello icon set component. * Usage: */ import { type CreateIconSetOptions, createIconSet, type IconComponent } from '@react-native-vector-icons/common'; type FontelloConfig = { name: string; css_prefix_text: string; css_use_suffix: boolean; hinting: boolean; units_per_em: number; ascent: number; glyphs: Array<{ uid: string; css: string; code: number; src: string; }>; }; // entries are optional because they can be derived from the config type Options = Partial; export default function createIconSetFromFontello( config: FontelloConfig, postScriptName?: string, fontFileName?: string, ): IconComponent>; export default function createIconSetFromFontello( config: FontelloConfig, options: Options, ): IconComponent>; export default function createIconSetFromFontello( config: FontelloConfig, postScriptNameOrOptions?: string | Options, fontFileNameParam?: string, ): IconComponent> { const { postScriptName, fontFileName, fontSource, fontStyle } = typeof postScriptNameOrOptions === 'object' ? postScriptNameOrOptions : { postScriptName: postScriptNameOrOptions, fontFileName: fontFileNameParam, }; const glyphMap: Record = {}; config.glyphs.forEach((glyph) => { glyphMap[glyph.css] = glyph.code; }); const fontFamily = postScriptName || config.name || 'fontello'; return createIconSet>(glyphMap as Record, { postScriptName: fontFamily, fontFileName: fontFileName || `${fontFamily}.ttf`, fontSource, fontStyle, }); }