c24e7f40b4
Add font… picks one or more files, checks them with a bounded sfnt reader (name table family, OS/2 weight), registers them with FontLoader before storing, and chooses the new family. Added fonts list below the bundled ones with Rename and Remove; removing the chosen one falls back to System default. Bytes live in the app support directory natively and in IndexedDB on the web (localStorage is too small); a shared_preferences index names them. Limits: 10 MB per file, 40 MB total. The capture kit gains a files= step.
26 lines
913 B
Dart
26 lines
913 B
Dart
/// One interface font option the device can choose: a bundled family
|
|
/// (`AppFont`) or one the user added (`CustomFont`).
|
|
abstract interface class FontChoice {
|
|
/// The stored value; stable across releases and renames.
|
|
String get id;
|
|
|
|
/// The picker's name for the option.
|
|
String get label;
|
|
|
|
/// The registered family name; null keeps the platform typography.
|
|
String? get family;
|
|
|
|
/// Every file the family needs, as loader sources: bundle asset paths, or
|
|
/// [customFontSource] keys for files the user added.
|
|
List<String> get sources;
|
|
|
|
/// The one source that previews the option's name (its regular weight).
|
|
String? get previewSource;
|
|
}
|
|
|
|
/// Loader sources naming a user-added file start with this prefix; the rest
|
|
/// is the file's key in the custom font store.
|
|
const String customFontSourcePrefix = 'custom-font:';
|
|
|
|
String customFontSource(String key) => '$customFontSourcePrefix$key';
|