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:
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/settings/settings_font_section.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_font.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_font_store.dart';
|
||||
import 'package:pipelines_app/ui/theme/font_choice.dart';
|
||||
|
||||
class _Harness {
|
||||
_Harness({this.hold = false});
|
||||
@@ -71,8 +72,8 @@ void main() {
|
||||
for (final font in AppFont.values)
|
||||
if (font.previewAsset != null) font.previewAsset,
|
||||
]);
|
||||
final group = tester.widget<RadioGroup<AppFont>>(
|
||||
find.byType(RadioGroup<AppFont>),
|
||||
final group = tester.widget<RadioGroup<FontChoice>>(
|
||||
find.byType(RadioGroup<FontChoice>),
|
||||
);
|
||||
expect(group.groupValue, AppFont.system);
|
||||
});
|
||||
@@ -85,10 +86,10 @@ void main() {
|
||||
|
||||
await tester.tap(find.text('Source Sans 3'));
|
||||
await tester.pump();
|
||||
expect(harness.store.font, AppFont.sourceSans3);
|
||||
expect(harness.store.id, AppFont.sourceSans3.id);
|
||||
expect(
|
||||
tester
|
||||
.widget<RadioGroup<AppFont>>(find.byType(RadioGroup<AppFont>))
|
||||
.widget<RadioGroup<FontChoice>>(find.byType(RadioGroup<FontChoice>))
|
||||
.groupValue,
|
||||
AppFont.sourceSans3,
|
||||
);
|
||||
@@ -107,7 +108,7 @@ void main() {
|
||||
final harness = _Harness();
|
||||
await _pump(tester, harness, cupertino: true);
|
||||
|
||||
expect(find.byType(RadioListTile<AppFont>), findsNothing);
|
||||
expect(find.byType(RadioListTile<FontChoice>), findsNothing);
|
||||
expect(_familyOf(tester, AppFont.system), 'CupertinoSystemText');
|
||||
Finder check(AppFont font) => find.descendant(
|
||||
of: find.byKey(settingsFontKey(font)),
|
||||
@@ -119,7 +120,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(check(AppFont.system), findsNothing);
|
||||
expect(check(AppFont.inter), findsOneWidget);
|
||||
expect(harness.store.font, AppFont.inter);
|
||||
expect(harness.store.id, AppFont.inter.id);
|
||||
expect(harness.fonts.family, 'Inter');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user