Settings: per-device interface font choice
System default plus Inter, IBM Plex Sans, Source Sans 3 and Atkinson Hyperlegible Next (OFL 1.1, bundled as on-demand assets and loaded with FontLoader, so the web fetches only the previewed/chosen files). Stored in shared_preferences, applied live to Material and Cupertino text themes; RobotoMono styles unchanged. Licences registered with LicenseRegistry.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Interface font choice (per device)
|
||||
|
||||
Settings > Font offers System default (the default everywhere: Roboto on
|
||||
Android and the web, SF in the iOS app), Inter, IBM Plex Sans, Source Sans 3
|
||||
and Atkinson Hyperlegible Next. Each option is named in its own face.
|
||||
|
||||
- `lib/ui/theme/app_font.dart`: the options, stable stored ids and assets.
|
||||
- `lib/ui/theme/app_font_store.dart`: `shared_preferences` key
|
||||
`pipelines.next.font.v1`, so the choice belongs to this device or browser
|
||||
and is never sent to the server.
|
||||
- `lib/ui/theme/app_font_controller.dart`: `AppFontController.instance`
|
||||
loads the chosen family with a `FontLoader` and only then switches the
|
||||
theme (one switch, no reflow loop). Startup waits up to 1.5 s for a stored
|
||||
font beside the session load, then draws in the system font and applies
|
||||
the font when it lands. A failed load keeps the current face and says so.
|
||||
- `lib/ui/theme/app_theme.dart`: `appLightTheme`/`appDarkTheme({fontFamily})`
|
||||
and `appCupertinoThemeWith({fontFamily})` replace only the family in every
|
||||
text role; sizes, weights and text scaling are unchanged. Explicit
|
||||
`appMonospaceFamily` (RobotoMono) styles are untouched.
|
||||
- `MyApp` and the onboarding host rebuild from the controller, so a choice
|
||||
applies immediately on Material and Cupertino hosts.
|
||||
- `lib/ui/theme/app_font_licenses.dart`: each `fonts/<family>/OFL.txt` is
|
||||
registered with `LicenseRegistry`. The app has no licence page of its own
|
||||
yet, so nothing shows them in the UI.
|
||||
|
||||
## Web download cost
|
||||
|
||||
The families are plain `assets:`, not pubspec `fonts:` (the web engine fetches
|
||||
every `fonts:` family at boot). Browser resource log on the fixture build:
|
||||
startup fetches no optional font; opening Settings fetches each family's
|
||||
Regular weight for the previews (65–431 KB each); choosing one fetches its
|
||||
other three weights. A stored choice fetches only its four files at startup.
|
||||
|
||||
Build size (release web): `main.dart.js` 4,214,247 -> 4,232,251 bytes (+18 KB,
|
||||
+5 KB gzip); `build/web` 43.6 -> 48.0 MB because the four families' 16 TTFs
|
||||
(4.45 MB, 2.09 MB gzip) ship as on-demand assets. The APK grows by about the
|
||||
same compressed amount (not measured).
|
||||
|
||||
## Known gaps
|
||||
|
||||
- Chat markdown code blocks were already in the proportional UI face, not
|
||||
RobotoMono; they now follow the chosen font too.
|
||||
- On the web Cupertino fixture, "System default" names an unregistered
|
||||
`CupertinoSystemText` family, which the browser engine substitutes.
|
||||
Reference in New Issue
Block a user