import 'font_choice.dart'; /// The bundled interface typefaces a device can choose. [AppFont.system] keeps the /// platform's own typography (Roboto on Android and the web, SF on iOS); every /// other option is an open-licence (SIL OFL 1.1) family bundled under /// `fonts//` as plain assets, not under pubspec `fonts:`, so a web /// page downloads only the family it actually shows. enum AppFont implements FontChoice { system('system', 'System default', null, null, []), inter('inter', 'Inter', 'Inter', 'inter', [ 'Inter-Regular.ttf', 'Inter-Medium.ttf', 'Inter-SemiBold.ttf', 'Inter-Bold.ttf', ]), ibmPlexSans( 'ibm-plex-sans', 'IBM Plex Sans', 'IBM Plex Sans', 'ibm-plex-sans', [ 'IBMPlexSans-Regular.ttf', 'IBMPlexSans-Medium.ttf', 'IBMPlexSans-SemiBold.ttf', 'IBMPlexSans-Bold.ttf', ], ), sourceSans3( 'source-sans-3', 'Source Sans 3', 'Source Sans 3', 'source-sans-3', [ 'SourceSans3-Regular.ttf', 'SourceSans3-Medium.ttf', 'SourceSans3-Semibold.ttf', 'SourceSans3-Bold.ttf', ], ), atkinsonHyperlegible( 'atkinson-hyperlegible-next', 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible Next', 'atkinson-hyperlegible-next', [ 'AtkinsonHyperlegibleNext-Regular.ttf', 'AtkinsonHyperlegibleNext-Medium.ttf', 'AtkinsonHyperlegibleNext-SemiBold.ttf', 'AtkinsonHyperlegibleNext-Bold.ttf', ], ); const AppFont(this.id, this.label, this.family, this._directory, this._files); @override final String id; @override final String label; @override final String? family; final String? _directory; final List _files; /// Every weight's asset (400, 500, 600 and 700, in that order). List get assets => [ for (final file in _files) 'fonts/$_directory/$file', ]; /// The regular weight alone: enough to preview the option's name. String? get previewAsset => _files.isEmpty ? null : assets.first; @override List get sources => assets; @override String? get previewSource => previewAsset; /// The licence shipped beside the files. String? get licenseAsset => _directory == null ? null : 'fonts/$_directory/OFL.txt'; /// The option a stored id names; an unknown or missing id is the default. static AppFont fromId(String? id) => AppFont.values.firstWhere( (font) => font.id == id, orElse: () => AppFont.system, ); }