Settings: add your own fonts (.ttf/.otf) per device

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.
This commit is contained in:
2026-11-04 18:45:01 +00:00
parent e0d7b720f5
commit c24e7f40b4
28 changed files with 2329 additions and 122 deletions
@@ -36,7 +36,7 @@ void main() {
test('restore loads only the stored family, then applies it', () async {
final loads = _Loads()..immediate = false;
final fonts = AppFontController(
store: MemoryAppFontStore(AppFont.inter),
store: MemoryAppFontStore(AppFont.inter.id),
loader: loads.call,
);
final restoring = fonts.restore();
@@ -57,7 +57,7 @@ void main() {
() async {
final loads = _Loads()..immediate = false;
final fonts = AppFontController(
store: MemoryAppFontStore(AppFont.sourceSans3),
store: MemoryAppFontStore(AppFont.sourceSans3.id),
loader: loads.call,
);
await fonts.restore(wait: const Duration(milliseconds: 10));
@@ -75,10 +75,10 @@ void main() {
final loads = _Loads();
final fonts = AppFontController(store: store, loader: loads.call);
await fonts.select(AppFont.atkinsonHyperlegible);
expect(store.font, AppFont.atkinsonHyperlegible);
expect(store.id, AppFont.atkinsonHyperlegible.id);
expect(fonts.family, 'Atkinson Hyperlegible Next');
await fonts.select(AppFont.system);
expect(store.font, AppFont.system);
expect(store.id, AppFont.system.id);
expect(fonts.family, isNull);
expect(loads.calls, hasLength(1));
},