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:
@@ -6,3 +6,22 @@ Christian Robertson, licensed under the Apache License, Version 2.0
|
|||||||
from the Flutter SDK's DevTools assets. They give monospace text (artifact text
|
from the Flutter SDK's DevTools assets. They give monospace text (artifact text
|
||||||
previews, background task output) a real fixed-width face on every platform:
|
previews, background task output) a real fixed-width face on every platform:
|
||||||
Flutter web does not resolve the generic `monospace` family.
|
Flutter web does not resolve the generic `monospace` family.
|
||||||
|
|
||||||
|
## Optional interface fonts
|
||||||
|
|
||||||
|
Chosen per device in Settings > Font (`lib/ui/theme/app_font.dart`). They are
|
||||||
|
declared as plain `assets:`, not `fonts:`, so Flutter web does not download them
|
||||||
|
at startup; the chosen family is registered on demand with a `FontLoader`. Each
|
||||||
|
directory holds the unmodified Regular (400), Medium (500), SemiBold (600) and
|
||||||
|
Bold (700) static TTFs and the family's SIL Open Font License 1.1 as `OFL.txt`,
|
||||||
|
which is also registered with `LicenseRegistry`.
|
||||||
|
|
||||||
|
| Directory | Family | Source | Licence |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `inter/` | Inter 4.1 | github.com/rsms/inter release v4.1, `Inter-4.1.zip`, `extras/ttf/` | OFL 1.1, (c) The Inter Project Authors |
|
||||||
|
| `ibm-plex-sans/` | IBM Plex Sans 1.1.0 | github.com/IBM/plex release `@ibm/plex-sans@1.1.0`, `ibm-plex-sans.zip`, `fonts/complete/ttf/` | OFL 1.1, (c) IBM Corp., Reserved Font Name "Plex" |
|
||||||
|
| `source-sans-3/` | Source Sans 3.052 | github.com/adobe-fonts/source-sans release 3.052R, `TTF-source-sans-3.052R.zip`; licence text from `LICENSE.md` at that tag | OFL 1.1, (c) Adobe, Reserved Font Name "Source" |
|
||||||
|
| `atkinson-hyperlegible-next/` | Atkinson Hyperlegible Next | github.com/googlefonts/atkinson-hyperlegible-next (no releases) at commit 7925f50f, `fonts/ttf/` and `OFL.txt` | OFL 1.1, (c) The Atkinson Hyperlegible Next Project Authors |
|
||||||
|
|
||||||
|
The files are unmodified (no subsetting), so the Reserved Font Names stay
|
||||||
|
usable.
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2020-2024 The Atkinson Hyperlegible Next Project Authors (https://github.com/googlefonts/atkinson-hyperlegible-next)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
|
||||||
|
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,92 @@
|
|||||||
|
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION AND CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2010-2022 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
|
||||||
|
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
import '../ui/adaptive/platform.dart';
|
import '../ui/adaptive/platform.dart';
|
||||||
|
import '../ui/theme/app_font_controller.dart';
|
||||||
import '../ui/theme/app_theme.dart';
|
import '../ui/theme/app_theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -16,6 +17,7 @@ class MyApp extends StatelessWidget {
|
|||||||
this.cupertino,
|
this.cupertino,
|
||||||
this.destination,
|
this.destination,
|
||||||
this.onDestinationSelected,
|
this.onDestinationSelected,
|
||||||
|
this.fonts,
|
||||||
}) : routerConfig = null;
|
}) : routerConfig = null;
|
||||||
|
|
||||||
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
||||||
@@ -25,6 +27,7 @@ class MyApp extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required RouterConfig<Object> this.routerConfig,
|
required RouterConfig<Object> this.routerConfig,
|
||||||
this.cupertino,
|
this.cupertino,
|
||||||
|
this.fonts,
|
||||||
}) : destinationBodies = const {},
|
}) : destinationBodies = const {},
|
||||||
destination = null,
|
destination = null,
|
||||||
onDestinationSelected = null;
|
onDestinationSelected = null;
|
||||||
@@ -35,20 +38,33 @@ class MyApp extends StatelessWidget {
|
|||||||
final ValueChanged<AppDestination>? onDestinationSelected;
|
final ValueChanged<AppDestination>? onDestinationSelected;
|
||||||
final RouterConfig<Object>? routerConfig;
|
final RouterConfig<Object>? routerConfig;
|
||||||
|
|
||||||
|
/// The device's interface font; defaults to the app's shared controller.
|
||||||
|
/// A change rebuilds the themes in place, without a restart.
|
||||||
|
final AppFontController? fonts;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final fonts = this.fonts ?? AppFontController.instance;
|
||||||
|
return ListenableBuilder(
|
||||||
|
listenable: fonts,
|
||||||
|
builder: (context, _) => _host(fonts.family),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _host(String? fontFamily) {
|
||||||
final router = routerConfig;
|
final router = routerConfig;
|
||||||
if (cupertino ?? _platformIsCupertino) {
|
if (cupertino ?? _platformIsCupertino) {
|
||||||
|
final theme = appCupertinoThemeWith(fontFamily: fontFamily);
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
return CupertinoApp.router(
|
return CupertinoApp.router(
|
||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
theme: appCupertinoTheme,
|
theme: theme,
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return CupertinoApp(
|
return CupertinoApp(
|
||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
theme: appCupertinoTheme,
|
theme: theme,
|
||||||
home: AdaptiveShell(
|
home: AdaptiveShell(
|
||||||
destinationBodies: destinationBodies,
|
destinationBodies: destinationBodies,
|
||||||
cupertino: true,
|
cupertino: true,
|
||||||
@@ -60,16 +76,16 @@ class MyApp extends StatelessWidget {
|
|||||||
if (router != null) {
|
if (router != null) {
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
theme: appLightTheme(),
|
theme: appLightTheme(fontFamily: fontFamily),
|
||||||
darkTheme: appDarkTheme(),
|
darkTheme: appDarkTheme(fontFamily: fontFamily),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
theme: appLightTheme(),
|
theme: appLightTheme(fontFamily: fontFamily),
|
||||||
darkTheme: appDarkTheme(),
|
darkTheme: appDarkTheme(fontFamily: fontFamily),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: AdaptiveShell(
|
home: AdaptiveShell(
|
||||||
destinationBodies: destinationBodies,
|
destinationBodies: destinationBodies,
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import 'app_url_strategy.dart';
|
|||||||
import 'pipelines_root.dart';
|
import 'pipelines_root.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
import '../features/settings/settings_store.dart';
|
import '../features/settings/settings_store.dart';
|
||||||
|
import '../ui/theme/app_font_controller.dart';
|
||||||
|
import '../ui/theme/app_font_licenses.dart';
|
||||||
|
|
||||||
/// Native builds must supply their server explicitly; there is no baked host.
|
/// Native builds must supply their server explicitly; there is no baked host.
|
||||||
const configuredServerUrl = String.fromEnvironment('PIPELINES_SERVER_URL');
|
const configuredServerUrl = String.fromEnvironment('PIPELINES_SERVER_URL');
|
||||||
@@ -38,6 +40,10 @@ Future<ServerEndpoint> resolveLaunchServer({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// How long the first frame waits for a stored font before drawing in the
|
||||||
|
/// system font.
|
||||||
|
const appFontStartupWait = Duration(milliseconds: 1500);
|
||||||
|
|
||||||
/// Resolves the endpoint for this launch and starts the normal composition.
|
/// Resolves the endpoint for this launch and starts the normal composition.
|
||||||
Future<void> runPipelinesApp({
|
Future<void> runPipelinesApp({
|
||||||
Uri? base,
|
Uri? base,
|
||||||
@@ -46,8 +52,13 @@ Future<void> runPipelinesApp({
|
|||||||
}) async {
|
}) async {
|
||||||
useAppUrlStrategy();
|
useAppUrlStrategy();
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
registerAppFontLicenses();
|
||||||
|
// The device's chosen font loads beside the session; a slow download does
|
||||||
|
// not hold the first frame, and applies when it lands.
|
||||||
|
final font = AppFontController.instance.restore(wait: appFontStartupWait);
|
||||||
// A phone behind the web login reconnects with its kept session.
|
// A phone behind the web login reconnects with its kept session.
|
||||||
await ServerSession.load();
|
await ServerSession.load();
|
||||||
|
await font;
|
||||||
final server = await resolveLaunchServer(
|
final server = await resolveLaunchServer(
|
||||||
base: base,
|
base: base,
|
||||||
configured: configured,
|
configured: configured,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import '../features/onboarding/onboarding_flow.dart';
|
|||||||
import '../features/settings/server_connections.dart';
|
import '../features/settings/server_connections.dart';
|
||||||
import '../features/settings/saved_servers_section.dart';
|
import '../features/settings/saved_servers_section.dart';
|
||||||
import '../features/settings/settings_store.dart';
|
import '../features/settings/settings_store.dart';
|
||||||
|
import '../ui/theme/app_font_controller.dart';
|
||||||
import '../ui/theme/app_theme.dart';
|
import '../ui/theme/app_theme.dart';
|
||||||
import 'pipelines_app.dart';
|
import 'pipelines_app.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
@@ -294,19 +295,23 @@ class _PipelinesRootState extends State<PipelinesRoot> {
|
|||||||
_servers.catalog.active?.endpoints.map(Uri.parse).toList() ??
|
_servers.catalog.active?.endpoints.map(Uri.parse).toList() ??
|
||||||
const [],
|
const [],
|
||||||
);
|
);
|
||||||
return _cupertino
|
final fonts = AppFontController.instance;
|
||||||
? CupertinoApp(
|
return ListenableBuilder(
|
||||||
title: 'Pipelines',
|
listenable: fonts,
|
||||||
theme: appCupertinoTheme,
|
builder: (context, _) => _cupertino
|
||||||
debugShowCheckedModeBanner: false,
|
? CupertinoApp(
|
||||||
home: flow,
|
title: 'Pipelines',
|
||||||
)
|
theme: appCupertinoThemeWith(fontFamily: fonts.family),
|
||||||
: MaterialApp(
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'Pipelines',
|
home: flow,
|
||||||
theme: appLightTheme(),
|
)
|
||||||
darkTheme: appDarkTheme(),
|
: MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
title: 'Pipelines',
|
||||||
home: flow,
|
theme: appLightTheme(fontFamily: fonts.family),
|
||||||
);
|
darkTheme: appDarkTheme(fontFamily: fonts.family),
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
home: flow,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/theme/app_font.dart';
|
||||||
|
import '../../ui/theme/app_font_controller.dart';
|
||||||
|
import 'settings_group.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
const fontSectionTitle = 'Font';
|
||||||
|
const fontSectionFooter =
|
||||||
|
'Saved on this device only. Code keeps its monospace font.';
|
||||||
|
const fontLoadingText = 'Loading…';
|
||||||
|
const fontLoadFailedText = 'Could not load this font.';
|
||||||
|
const fontSaveFailedText = 'Not saved on this device; it applies until reload.';
|
||||||
|
|
||||||
|
ValueKey<String> settingsFontKey(AppFont font) =>
|
||||||
|
ValueKey<String>('settings-font-${font.id}');
|
||||||
|
|
||||||
|
/// The device's interface font: one row per option, each named in its own
|
||||||
|
/// face. Material rows are radio tiles, Cupertino rows carry the checkmark.
|
||||||
|
/// A choice is stored locally and applies as soon as its files load.
|
||||||
|
class SettingsFontSection extends StatefulWidget {
|
||||||
|
const SettingsFontSection({super.key, required this.controller});
|
||||||
|
|
||||||
|
final AppFontController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingsFontSection> createState() => _SettingsFontSectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingsFontSectionState extends State<SettingsFontSection> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_preview();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(SettingsFontSection oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.controller != widget.controller) _preview();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Only the regular weight of each option, only once Settings is shown.
|
||||||
|
void _preview() {
|
||||||
|
for (final font in AppFont.values) {
|
||||||
|
unawaited(widget.controller.preview(font));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
|
listenable: widget.controller,
|
||||||
|
builder: (context, _) => _group(context),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget _group(BuildContext context) {
|
||||||
|
final controller = widget.controller;
|
||||||
|
final cupertino = usesCupertinoControls(context);
|
||||||
|
final group = SettingsGroup(
|
||||||
|
title: fontSectionTitle,
|
||||||
|
footer: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
const Text(fontSectionFooter),
|
||||||
|
if (controller.saveFailed)
|
||||||
|
Text(
|
||||||
|
fontSaveFailedText,
|
||||||
|
style: TextStyle(color: settingsErrorColor(context)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
children: <Widget>[
|
||||||
|
for (final font in AppFont.values)
|
||||||
|
cupertino
|
||||||
|
? _cupertinoRow(context, font)
|
||||||
|
: RadioListTile<AppFont>(
|
||||||
|
key: settingsFontKey(font),
|
||||||
|
value: font,
|
||||||
|
title: _name(context, font),
|
||||||
|
subtitle: _status(context, font),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (cupertino) return group;
|
||||||
|
return RadioGroup<AppFont>(
|
||||||
|
groupValue: controller.selected,
|
||||||
|
onChanged: (font) {
|
||||||
|
if (font != null) unawaited(controller.select(font));
|
||||||
|
},
|
||||||
|
child: group,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _cupertinoRow(BuildContext context, AppFont font) => SettingsRow(
|
||||||
|
key: settingsFontKey(font),
|
||||||
|
title: _name(context, font),
|
||||||
|
subtitle: _status(context, font),
|
||||||
|
trailing: widget.controller.selected == font
|
||||||
|
? Icon(
|
||||||
|
CupertinoIcons.check_mark,
|
||||||
|
color: CupertinoTheme.of(context).primaryColor,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
onTap: () => unawaited(widget.controller.select(font)),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// The option's name in its own face once its regular weight has loaded;
|
||||||
|
/// the system face until then (and always for the system option).
|
||||||
|
Widget _name(BuildContext context, AppFont font) {
|
||||||
|
final family = widget.controller.canPreview(font)
|
||||||
|
? font.family ?? _systemFamily(context)
|
||||||
|
: _systemFamily(context);
|
||||||
|
return Text(font.label, style: TextStyle(fontFamily: family));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _status(BuildContext context, AppFont font) {
|
||||||
|
final controller = widget.controller;
|
||||||
|
if (controller.selected != font) return null;
|
||||||
|
if (controller.loadFailed == font) {
|
||||||
|
return Text(
|
||||||
|
fontLoadFailedText,
|
||||||
|
style: TextStyle(color: settingsErrorColor(context)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return controller.loading ? const Text(fontLoadingText) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The platform's own interface family (Roboto, or the Cupertino system
|
||||||
|
/// face), independent of the font the theme currently applies.
|
||||||
|
String? _systemFamily(BuildContext context) => usesCupertinoControls(context)
|
||||||
|
? const CupertinoTextThemeData().textStyle.fontFamily
|
||||||
|
: Typography.material2021(
|
||||||
|
platform: Theme.of(context).platform,
|
||||||
|
).black.bodyLarge?.fontFamily;
|
||||||
@@ -10,6 +10,8 @@ import '../attention/notify/notification_controller.dart';
|
|||||||
import 'default_endpoint.dart';
|
import 'default_endpoint.dart';
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
import 'settings_controls.dart';
|
import 'settings_controls.dart';
|
||||||
|
import 'settings_font_section.dart';
|
||||||
|
import '../../ui/theme/app_font_controller.dart';
|
||||||
import 'settings_group.dart';
|
import 'settings_group.dart';
|
||||||
import 'settings_page_body.dart';
|
import 'settings_page_body.dart';
|
||||||
import 'settings_notifications_section.dart';
|
import 'settings_notifications_section.dart';
|
||||||
@@ -53,8 +55,12 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
this.servers,
|
this.servers,
|
||||||
this.deliveryService,
|
this.deliveryService,
|
||||||
this.deliveryServiceController,
|
this.deliveryServiceController,
|
||||||
|
this.fonts,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The device's interface font; defaults to the app's shared controller.
|
||||||
|
final AppFontController? fonts;
|
||||||
|
|
||||||
/// Android background delivery; hidden when absent or unsupported.
|
/// Android background delivery; hidden when absent or unsupported.
|
||||||
final NotificationServiceBridge? deliveryService;
|
final NotificationServiceBridge? deliveryService;
|
||||||
final NotificationServiceController? deliveryServiceController;
|
final NotificationServiceController? deliveryServiceController;
|
||||||
@@ -190,6 +196,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
controller: _controller,
|
controller: _controller,
|
||||||
workspaceField: _workspaceField,
|
workspaceField: _workspaceField,
|
||||||
),
|
),
|
||||||
|
// A device-local choice: a browser and a phone keep their own.
|
||||||
|
SettingsFontSection(
|
||||||
|
controller: widget.fonts ?? AppFontController.instance,
|
||||||
|
),
|
||||||
if (widget.notifications case final notifications?)
|
if (widget.notifications case final notifications?)
|
||||||
SettingsNotificationsSection(controller: notifications),
|
SettingsNotificationsSection(controller: notifications),
|
||||||
if (widget.deliveryService case final service? when service.supported)
|
if (widget.deliveryService case final service? when service.supported)
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/// The 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/<directory>/` as plain assets, not under pubspec `fonts:`, so a web
|
||||||
|
/// page downloads only the family it actually shows.
|
||||||
|
enum AppFont {
|
||||||
|
system('system', 'System default', null, null, <String>[]),
|
||||||
|
inter('inter', 'Inter', 'Inter', 'inter', <String>[
|
||||||
|
'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',
|
||||||
|
<String>[
|
||||||
|
'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',
|
||||||
|
<String>[
|
||||||
|
'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',
|
||||||
|
<String>[
|
||||||
|
'AtkinsonHyperlegibleNext-Regular.ttf',
|
||||||
|
'AtkinsonHyperlegibleNext-Medium.ttf',
|
||||||
|
'AtkinsonHyperlegibleNext-SemiBold.ttf',
|
||||||
|
'AtkinsonHyperlegibleNext-Bold.ttf',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
const AppFont(this.id, this.label, this.family, this._directory, this._files);
|
||||||
|
|
||||||
|
/// The stored value. Stable across releases; never the display label.
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
/// The picker's name for the option.
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
/// The registered family name; null keeps the platform typography.
|
||||||
|
final String? family;
|
||||||
|
|
||||||
|
final String? _directory;
|
||||||
|
final List<String> _files;
|
||||||
|
|
||||||
|
/// Every weight's asset (400, 500, 600 and 700, in that order).
|
||||||
|
List<String> get assets => <String>[
|
||||||
|
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;
|
||||||
|
|
||||||
|
/// 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,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import 'app_font.dart';
|
||||||
|
import 'app_font_store.dart';
|
||||||
|
|
||||||
|
/// Registers [assets] under [family]. Production reads them from the bundle;
|
||||||
|
/// tests substitute a recorder.
|
||||||
|
typedef AppFontAssetLoader =
|
||||||
|
Future<void> Function(String family, List<String> assets);
|
||||||
|
|
||||||
|
/// Loads bundled font files on demand with a [FontLoader]. On the web each
|
||||||
|
/// asset is fetched only now, when its family is first previewed or chosen.
|
||||||
|
Future<void> loadBundledFontAssets(String family, List<String> assets) async {
|
||||||
|
final loader = FontLoader(family);
|
||||||
|
for (final asset in assets) {
|
||||||
|
loader.addFont(rootBundle.load(asset));
|
||||||
|
}
|
||||||
|
await loader.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The device's interface font: the stored choice, the family the theme
|
||||||
|
/// actually uses, and the on-demand loading between the two.
|
||||||
|
///
|
||||||
|
/// The theme keeps the previous family (at first the platform's) until the
|
||||||
|
/// chosen files are registered, then switches once; text never lays out in a
|
||||||
|
/// family that has not loaded, so nothing reflows more than once.
|
||||||
|
class AppFontController extends ChangeNotifier {
|
||||||
|
AppFontController({
|
||||||
|
this._store = const SharedPreferencesAppFontStore(),
|
||||||
|
this._loader = loadBundledFontAssets,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The app's own controller: one per running app, shared by the theme
|
||||||
|
/// hosts and the Settings picker.
|
||||||
|
static final AppFontController instance = AppFontController();
|
||||||
|
|
||||||
|
final AppFontStore _store;
|
||||||
|
final AppFontAssetLoader _loader;
|
||||||
|
final Map<String, Future<void>> _assetLoads = <String, Future<void>>{};
|
||||||
|
final Set<String> _loadedAssets = <String>{};
|
||||||
|
|
||||||
|
AppFont _selected = AppFont.system;
|
||||||
|
AppFont _applied = AppFont.system;
|
||||||
|
bool _saveFailed = false;
|
||||||
|
AppFont? _loadFailed;
|
||||||
|
|
||||||
|
/// The option the picker shows as chosen.
|
||||||
|
AppFont get selected => _selected;
|
||||||
|
|
||||||
|
/// The option the theme uses now.
|
||||||
|
AppFont get applied => _applied;
|
||||||
|
|
||||||
|
/// The theme's family; null keeps the platform typography.
|
||||||
|
String? get family => _applied.family;
|
||||||
|
|
||||||
|
/// The chosen family's files are still downloading.
|
||||||
|
bool get loading => _selected != _applied && _loadFailed != _selected;
|
||||||
|
|
||||||
|
/// The last choice could not be stored on this device.
|
||||||
|
bool get saveFailed => _saveFailed;
|
||||||
|
|
||||||
|
/// The chosen family's files could not be loaded; the theme kept [applied].
|
||||||
|
AppFont? get loadFailed => _loadFailed;
|
||||||
|
|
||||||
|
/// Whether [font]'s regular weight is registered, so its name can be drawn
|
||||||
|
/// in its own face.
|
||||||
|
bool canPreview(AppFont font) =>
|
||||||
|
font.previewAsset == null || _loadedAssets.contains(font.previewAsset);
|
||||||
|
|
||||||
|
/// Reads the stored choice and starts loading it. With [wait], returns once
|
||||||
|
/// it is applied or after [wait], whichever is first; a slower load still
|
||||||
|
/// applies when it finishes.
|
||||||
|
Future<void> restore({Duration? wait}) async {
|
||||||
|
final font = await _store.load();
|
||||||
|
if (font == AppFont.system || font == _selected) return;
|
||||||
|
_selected = font;
|
||||||
|
notifyListeners();
|
||||||
|
final applying = _apply(font);
|
||||||
|
if (wait == null) return applying;
|
||||||
|
await Future.any<void>(<Future<void>>[
|
||||||
|
applying,
|
||||||
|
Future<void>.delayed(wait),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Chooses [font], stores it, and applies it once its files are loaded.
|
||||||
|
Future<void> select(AppFont font) async {
|
||||||
|
if (font == _selected && _loadFailed != font) return;
|
||||||
|
_selected = font;
|
||||||
|
_loadFailed = null;
|
||||||
|
notifyListeners();
|
||||||
|
final saved = await _store.save(font);
|
||||||
|
if (saved == _saveFailed) {
|
||||||
|
_saveFailed = !saved;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
await _apply(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loads [font]'s regular weight for its picker row. Failures are quiet: the
|
||||||
|
/// row keeps the current face and choosing it reports the problem.
|
||||||
|
Future<void> preview(AppFont font) async {
|
||||||
|
final asset = font.previewAsset;
|
||||||
|
final family = font.family;
|
||||||
|
if (asset == null || family == null || _loadedAssets.contains(asset)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await _ensure(family, <String>[asset]);
|
||||||
|
} catch (_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _apply(AppFont font) async {
|
||||||
|
final family = font.family;
|
||||||
|
if (family != null) {
|
||||||
|
try {
|
||||||
|
await _ensure(family, font.assets);
|
||||||
|
} catch (_) {
|
||||||
|
if (_selected == font) {
|
||||||
|
_loadFailed = font;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// A later choice supersedes this one.
|
||||||
|
if (_selected != font || _applied == font) return;
|
||||||
|
_applied = font;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Registers the assets not yet loaded or loading, in one [FontLoader], and
|
||||||
|
/// waits for all of [assets]. A failed asset can be retried.
|
||||||
|
Future<void> _ensure(String family, List<String> assets) {
|
||||||
|
final missing = assets.where((a) => !_assetLoads.containsKey(a)).toList();
|
||||||
|
if (missing.isNotEmpty) {
|
||||||
|
final load = _loader(family, missing);
|
||||||
|
for (final asset in missing) {
|
||||||
|
_assetLoads[asset] = load.then(
|
||||||
|
(_) => _loadedAssets.add(asset),
|
||||||
|
onError: (Object error, StackTrace stack) {
|
||||||
|
_assetLoads.remove(asset);
|
||||||
|
Error.throwWithStackTrace(error, stack);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Future.wait(assets.map((a) => _assetLoads[a]!));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'app_font.dart';
|
||||||
|
|
||||||
|
bool _registered = false;
|
||||||
|
|
||||||
|
/// Adds each bundled interface font's SIL Open Font License to the
|
||||||
|
/// [LicenseRegistry]. The texts are read from the bundle only when a licence
|
||||||
|
/// page asks for them.
|
||||||
|
void registerAppFontLicenses() {
|
||||||
|
if (_registered) return;
|
||||||
|
_registered = true;
|
||||||
|
LicenseRegistry.addLicense(() async* {
|
||||||
|
for (final font in AppFont.values) {
|
||||||
|
final asset = font.licenseAsset;
|
||||||
|
if (asset == null) continue;
|
||||||
|
yield LicenseEntryWithLineBreaks(<String>[
|
||||||
|
font.label,
|
||||||
|
], await rootBundle.loadString(asset));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'app_font.dart';
|
||||||
|
|
||||||
|
/// The device's font choice. It lives in this device's (or browser's) own
|
||||||
|
/// preferences and is never sent to a server, so a phone and a browser signed
|
||||||
|
/// in to the same server keep their own choice.
|
||||||
|
const String appFontKey = 'pipelines.next.font.v1';
|
||||||
|
|
||||||
|
/// The persistence seam for the font choice.
|
||||||
|
abstract interface class AppFontStore {
|
||||||
|
Future<AppFont> load();
|
||||||
|
|
||||||
|
/// Whether the choice is actually stored.
|
||||||
|
Future<bool> save(AppFont font);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `shared_preferences` storage. An unavailable or unreadable store means the
|
||||||
|
/// default; a failed save returns false rather than throwing.
|
||||||
|
class SharedPreferencesAppFontStore implements AppFontStore {
|
||||||
|
const SharedPreferencesAppFontStore();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<AppFont> load() async {
|
||||||
|
try {
|
||||||
|
final preferences = await SharedPreferences.getInstance();
|
||||||
|
return AppFont.fromId(preferences.getString(appFontKey));
|
||||||
|
} catch (_) {
|
||||||
|
return AppFont.system;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> save(AppFont font) async {
|
||||||
|
try {
|
||||||
|
final preferences = await SharedPreferences.getInstance();
|
||||||
|
return await preferences.setString(appFontKey, font.id);
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An in-memory store for tests and fixtures.
|
||||||
|
class MemoryAppFontStore implements AppFontStore {
|
||||||
|
MemoryAppFontStore([this.font = AppFont.system]);
|
||||||
|
|
||||||
|
AppFont font;
|
||||||
|
bool failSaves = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<AppFont> load() async => font;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> save(AppFont font) async {
|
||||||
|
if (failSaves) return false;
|
||||||
|
this.font = font;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,11 +26,20 @@ abstract final class AppColors {
|
|||||||
|
|
||||||
const _seed = Color(0xFF6750A4);
|
const _seed = Color(0xFF6750A4);
|
||||||
|
|
||||||
ThemeData appLightTheme() => ThemeData(
|
/// [fontFamily] replaces the platform family throughout the text themes
|
||||||
platform: kIsWeb ? TargetPlatform.android : null,
|
/// (Material's, and Cupertino's for Cupertino widgets on a Material host),
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: _seed),
|
/// keeping every size, weight and the text scaling; null keeps the system
|
||||||
pageTransitionsTheme: appPageTransitions,
|
/// typography.
|
||||||
);
|
ThemeData appLightTheme({String? fontFamily}) {
|
||||||
|
final scheme = ColorScheme.fromSeed(seedColor: _seed);
|
||||||
|
return ThemeData(
|
||||||
|
platform: kIsWeb ? TargetPlatform.android : null,
|
||||||
|
colorScheme: scheme,
|
||||||
|
pageTransitionsTheme: appPageTransitions,
|
||||||
|
fontFamily: fontFamily,
|
||||||
|
cupertinoOverrideTheme: _cupertinoOverride(fontFamily, scheme),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Android and iOS keep their native transitions and interactive back gestures.
|
/// Android and iOS keep their native transitions and interactive back gestures.
|
||||||
/// Desktop hosts use the short horizontal slide.
|
/// Desktop hosts use the short horizontal slide.
|
||||||
@@ -80,7 +89,7 @@ class FastSlidePageTransitionsBuilder extends PageTransitionsBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Material's dark scheme with gray surfaces stepping up from the page.
|
/// Material's dark scheme with gray surfaces stepping up from the page.
|
||||||
ThemeData appDarkTheme() {
|
ThemeData appDarkTheme({String? fontFamily}) {
|
||||||
final scheme =
|
final scheme =
|
||||||
ColorScheme.fromSeed(
|
ColorScheme.fromSeed(
|
||||||
seedColor: _seed,
|
seedColor: _seed,
|
||||||
@@ -100,6 +109,8 @@ ThemeData appDarkTheme() {
|
|||||||
colorScheme: scheme,
|
colorScheme: scheme,
|
||||||
scaffoldBackgroundColor: scheme.surface,
|
scaffoldBackgroundColor: scheme.surface,
|
||||||
pageTransitionsTheme: appPageTransitions,
|
pageTransitionsTheme: appPageTransitions,
|
||||||
|
fontFamily: fontFamily,
|
||||||
|
cupertinoOverrideTheme: _cupertinoOverride(fontFamily, scheme),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,3 +118,45 @@ const appCupertinoTheme = CupertinoThemeData(
|
|||||||
scaffoldBackgroundColor: AppColors.background,
|
scaffoldBackgroundColor: AppColors.background,
|
||||||
barBackgroundColor: AppColors.bar,
|
barBackgroundColor: AppColors.bar,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// [appCupertinoTheme] with every Cupertino text role in [fontFamily]; null
|
||||||
|
/// keeps the system typography.
|
||||||
|
CupertinoThemeData appCupertinoThemeWith({String? fontFamily}) =>
|
||||||
|
fontFamily == null
|
||||||
|
? appCupertinoTheme
|
||||||
|
: appCupertinoTheme.copyWith(textTheme: appCupertinoTextTheme(fontFamily));
|
||||||
|
|
||||||
|
/// The stock Cupertino text roles (sizes, weights, colours) in [fontFamily].
|
||||||
|
/// Action roles take [primaryColor], as the stock roles do.
|
||||||
|
CupertinoTextThemeData appCupertinoTextTheme(
|
||||||
|
String fontFamily, {
|
||||||
|
Color primaryColor = CupertinoColors.systemBlue,
|
||||||
|
}) {
|
||||||
|
final base = CupertinoTextThemeData(primaryColor: primaryColor);
|
||||||
|
TextStyle face(TextStyle style) => style.copyWith(fontFamily: fontFamily);
|
||||||
|
return CupertinoTextThemeData(
|
||||||
|
textStyle: face(base.textStyle),
|
||||||
|
actionTextStyle: face(base.actionTextStyle),
|
||||||
|
actionSmallTextStyle: face(base.actionSmallTextStyle),
|
||||||
|
tabLabelTextStyle: face(base.tabLabelTextStyle),
|
||||||
|
navTitleTextStyle: face(base.navTitleTextStyle),
|
||||||
|
navLargeTitleTextStyle: face(base.navLargeTitleTextStyle),
|
||||||
|
navActionTextStyle: face(base.navActionTextStyle),
|
||||||
|
pickerTextStyle: face(base.pickerTextStyle),
|
||||||
|
dateTimePickerTextStyle: face(base.dateTimePickerTextStyle),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cupertino widgets on a Material host derive their theme from Material's;
|
||||||
|
/// only the family is overridden, with Material's primary for actions.
|
||||||
|
NoDefaultCupertinoThemeData? _cupertinoOverride(
|
||||||
|
String? fontFamily,
|
||||||
|
ColorScheme scheme,
|
||||||
|
) => fontFamily == null
|
||||||
|
? null
|
||||||
|
: CupertinoThemeData(
|
||||||
|
textTheme: appCupertinoTextTheme(
|
||||||
|
fontFamily,
|
||||||
|
primaryColor: scheme.primary,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -75,6 +75,13 @@ flutter:
|
|||||||
assets:
|
assets:
|
||||||
- assets/harnesses/claude.png
|
- assets/harnesses/claude.png
|
||||||
- assets/harnesses/opencode.png
|
- assets/harnesses/opencode.png
|
||||||
|
# Optional interface fonts. Plain assets, not `fonts:`: the web engine
|
||||||
|
# downloads every `fonts:` family at startup, while these load on demand
|
||||||
|
# (lib/ui/theme/app_font_controller.dart). Licences: fonts/README.md.
|
||||||
|
- fonts/inter/
|
||||||
|
- fonts/ibm-plex-sans/
|
||||||
|
- fonts/source-sans-3/
|
||||||
|
- fonts/atkinson-hyperlegible-next/
|
||||||
|
|
||||||
fonts:
|
fonts:
|
||||||
- family: RobotoMono
|
- family: RobotoMono
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
class _Harness {
|
||||||
|
_Harness({this.hold = false});
|
||||||
|
|
||||||
|
final bool hold;
|
||||||
|
final store = MemoryAppFontStore();
|
||||||
|
final loads = <String>[];
|
||||||
|
final held = <Completer<void>>[];
|
||||||
|
|
||||||
|
late final fonts = AppFontController(
|
||||||
|
store: store,
|
||||||
|
loader: (family, assets) {
|
||||||
|
loads.addAll(assets);
|
||||||
|
if (!hold || assets.length == 1) return Future<void>.value();
|
||||||
|
final done = Completer<void>();
|
||||||
|
held.add(done);
|
||||||
|
return done.future;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _pump(
|
||||||
|
WidgetTester tester,
|
||||||
|
_Harness harness, {
|
||||||
|
bool cupertino = false,
|
||||||
|
}) async {
|
||||||
|
final section = SingleChildScrollView(
|
||||||
|
child: SettingsFontSection(controller: harness.fonts),
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
cupertino
|
||||||
|
? CupertinoApp(home: CupertinoPageScaffold(child: section))
|
||||||
|
: MaterialApp(home: Scaffold(body: section)),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _familyOf(WidgetTester tester, AppFont font) => tester
|
||||||
|
.widget<Text>(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byKey(settingsFontKey(font)),
|
||||||
|
matching: find.text(font.label),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.style
|
||||||
|
?.fontFamily;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Material: every option is a radio named in its own face', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final harness = _Harness();
|
||||||
|
await _pump(tester, harness);
|
||||||
|
|
||||||
|
expect(find.text(fontSectionTitle), findsOneWidget);
|
||||||
|
for (final font in AppFont.values) {
|
||||||
|
expect(find.byKey(settingsFontKey(font)), findsOneWidget);
|
||||||
|
expect(_familyOf(tester, font), font.family ?? 'Roboto');
|
||||||
|
}
|
||||||
|
// Showing the picker fetched one regular weight per option, no more.
|
||||||
|
expect(harness.loads, <String?>[
|
||||||
|
for (final font in AppFont.values)
|
||||||
|
if (font.previewAsset != null) font.previewAsset,
|
||||||
|
]);
|
||||||
|
final group = tester.widget<RadioGroup<AppFont>>(
|
||||||
|
find.byType(RadioGroup<AppFont>),
|
||||||
|
);
|
||||||
|
expect(group.groupValue, AppFont.system);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Material: choosing a font stores it and shows it loading', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final harness = _Harness(hold: true);
|
||||||
|
await _pump(tester, harness);
|
||||||
|
|
||||||
|
await tester.tap(find.text('Source Sans 3'));
|
||||||
|
await tester.pump();
|
||||||
|
expect(harness.store.font, AppFont.sourceSans3);
|
||||||
|
expect(
|
||||||
|
tester
|
||||||
|
.widget<RadioGroup<AppFont>>(find.byType(RadioGroup<AppFont>))
|
||||||
|
.groupValue,
|
||||||
|
AppFont.sourceSans3,
|
||||||
|
);
|
||||||
|
expect(find.text(fontLoadingText), findsOneWidget);
|
||||||
|
expect(harness.fonts.family, isNull);
|
||||||
|
|
||||||
|
harness.held.single.complete();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text(fontLoadingText), findsNothing);
|
||||||
|
expect(harness.fonts.family, 'Source Sans 3');
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Cupertino: the chosen row carries the checkmark', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final harness = _Harness();
|
||||||
|
await _pump(tester, harness, cupertino: true);
|
||||||
|
|
||||||
|
expect(find.byType(RadioListTile<AppFont>), findsNothing);
|
||||||
|
expect(_familyOf(tester, AppFont.system), 'CupertinoSystemText');
|
||||||
|
Finder check(AppFont font) => find.descendant(
|
||||||
|
of: find.byKey(settingsFontKey(font)),
|
||||||
|
matching: find.byIcon(CupertinoIcons.check_mark),
|
||||||
|
);
|
||||||
|
expect(check(AppFont.system), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.tap(find.text('Inter'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(check(AppFont.system), findsNothing);
|
||||||
|
expect(check(AppFont.inter), findsOneWidget);
|
||||||
|
expect(harness.store.font, AppFont.inter);
|
||||||
|
expect(harness.fonts.family, 'Inter');
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a failed save is said under the group', (tester) async {
|
||||||
|
final harness = _Harness();
|
||||||
|
harness.store.failSaves = true;
|
||||||
|
await _pump(tester, harness);
|
||||||
|
|
||||||
|
await tester.tap(find.text('Inter'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text(fontSaveFailedText), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_test/flutter_test.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';
|
||||||
|
|
||||||
|
/// Records each load and completes it when the test says so.
|
||||||
|
class _Loads {
|
||||||
|
final calls = <(String, List<String>)>[];
|
||||||
|
final pending = <Completer<void>>[];
|
||||||
|
bool immediate = true;
|
||||||
|
|
||||||
|
Future<void> call(String family, List<String> assets) {
|
||||||
|
calls.add((family, assets));
|
||||||
|
final done = Completer<void>();
|
||||||
|
pending.add(done);
|
||||||
|
if (immediate) done.complete();
|
||||||
|
return done.future;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('starts on the system default with no download', () async {
|
||||||
|
final loads = _Loads();
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(),
|
||||||
|
loader: loads.call,
|
||||||
|
);
|
||||||
|
await fonts.restore();
|
||||||
|
expect(fonts.selected, AppFont.system);
|
||||||
|
expect(fonts.family, isNull);
|
||||||
|
expect(loads.calls, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('restore loads only the stored family, then applies it', () async {
|
||||||
|
final loads = _Loads()..immediate = false;
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(AppFont.inter),
|
||||||
|
loader: loads.call,
|
||||||
|
);
|
||||||
|
final restoring = fonts.restore();
|
||||||
|
await pumpEventQueue();
|
||||||
|
expect(fonts.selected, AppFont.inter);
|
||||||
|
expect(fonts.family, isNull, reason: 'system face until loaded');
|
||||||
|
expect(fonts.loading, isTrue);
|
||||||
|
expect(loads.calls.single.$1, 'Inter');
|
||||||
|
expect(loads.calls.single.$2, AppFont.inter.assets);
|
||||||
|
loads.pending.single.complete();
|
||||||
|
await restoring;
|
||||||
|
expect(fonts.family, 'Inter');
|
||||||
|
expect(fonts.loading, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'restore with a wait returns at the deadline and applies later',
|
||||||
|
() async {
|
||||||
|
final loads = _Loads()..immediate = false;
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(AppFont.sourceSans3),
|
||||||
|
loader: loads.call,
|
||||||
|
);
|
||||||
|
await fonts.restore(wait: const Duration(milliseconds: 10));
|
||||||
|
expect(fonts.family, isNull);
|
||||||
|
loads.pending.single.complete();
|
||||||
|
await pumpEventQueue();
|
||||||
|
expect(fonts.family, 'Source Sans 3');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'select stores the choice and applies it; system needs no load',
|
||||||
|
() async {
|
||||||
|
final store = MemoryAppFontStore();
|
||||||
|
final loads = _Loads();
|
||||||
|
final fonts = AppFontController(store: store, loader: loads.call);
|
||||||
|
await fonts.select(AppFont.atkinsonHyperlegible);
|
||||||
|
expect(store.font, AppFont.atkinsonHyperlegible);
|
||||||
|
expect(fonts.family, 'Atkinson Hyperlegible Next');
|
||||||
|
await fonts.select(AppFont.system);
|
||||||
|
expect(store.font, AppFont.system);
|
||||||
|
expect(fonts.family, isNull);
|
||||||
|
expect(loads.calls, hasLength(1));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('a newer choice wins over a slower earlier load', () async {
|
||||||
|
final loads = _Loads()..immediate = false;
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(),
|
||||||
|
loader: loads.call,
|
||||||
|
);
|
||||||
|
final first = fonts.select(AppFont.inter);
|
||||||
|
await pumpEventQueue();
|
||||||
|
final second = fonts.select(AppFont.ibmPlexSans);
|
||||||
|
await pumpEventQueue();
|
||||||
|
loads.pending[1].complete();
|
||||||
|
await second;
|
||||||
|
expect(fonts.family, 'IBM Plex Sans');
|
||||||
|
loads.pending[0].complete();
|
||||||
|
await first;
|
||||||
|
expect(fonts.family, 'IBM Plex Sans');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'preview loads the regular weight once; choosing loads the rest',
|
||||||
|
() async {
|
||||||
|
final loads = _Loads();
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(),
|
||||||
|
loader: loads.call,
|
||||||
|
);
|
||||||
|
expect(fonts.canPreview(AppFont.inter), isFalse);
|
||||||
|
await fonts.preview(AppFont.inter);
|
||||||
|
await fonts.preview(AppFont.inter);
|
||||||
|
await fonts.preview(AppFont.system);
|
||||||
|
expect(fonts.canPreview(AppFont.inter), isTrue);
|
||||||
|
expect(fonts.canPreview(AppFont.system), isTrue);
|
||||||
|
expect(loads.calls.single.$1, 'Inter');
|
||||||
|
expect(loads.calls.single.$2, <String>['fonts/inter/Inter-Regular.ttf']);
|
||||||
|
await fonts.select(AppFont.inter);
|
||||||
|
expect(loads.calls.last.$2, AppFont.inter.assets.skip(1).toList());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'a failed load keeps the current face, says so, and can retry',
|
||||||
|
() async {
|
||||||
|
var fail = true;
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(),
|
||||||
|
loader: (family, assets) async {
|
||||||
|
if (fail) throw StateError('offline');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await fonts.select(AppFont.inter);
|
||||||
|
expect(fonts.family, isNull);
|
||||||
|
expect(fonts.loadFailed, AppFont.inter);
|
||||||
|
expect(fonts.loading, isFalse);
|
||||||
|
fail = false;
|
||||||
|
await fonts.select(AppFont.inter);
|
||||||
|
expect(fonts.loadFailed, isNull);
|
||||||
|
expect(fonts.family, 'Inter');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('a failed save is reported but the font still applies', () async {
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore()..failSaves = true,
|
||||||
|
loader: _Loads().call,
|
||||||
|
);
|
||||||
|
await fonts.select(AppFont.inter);
|
||||||
|
expect(fonts.saveFailed, isTrue);
|
||||||
|
expect(fonts.family, 'Inter');
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_font.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_font_store.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
setUp(() => SharedPreferences.setMockInitialValues(<String, Object>{}));
|
||||||
|
|
||||||
|
test('nothing stored is the system default', () async {
|
||||||
|
expect(await const SharedPreferencesAppFontStore().load(), AppFont.system);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'a choice round-trips under its stable id, on the device only',
|
||||||
|
() async {
|
||||||
|
const store = SharedPreferencesAppFontStore();
|
||||||
|
expect(await store.save(AppFont.ibmPlexSans), isTrue);
|
||||||
|
final preferences = await SharedPreferences.getInstance();
|
||||||
|
expect(preferences.getKeys(), <String>{appFontKey});
|
||||||
|
expect(preferences.getString(appFontKey), 'ibm-plex-sans');
|
||||||
|
expect(await store.load(), AppFont.ibmPlexSans);
|
||||||
|
|
||||||
|
expect(await store.save(AppFont.system), isTrue);
|
||||||
|
expect(await store.load(), AppFont.system);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('an unknown stored id falls back to the system default', () async {
|
||||||
|
SharedPreferences.setMockInitialValues(<String, Object>{
|
||||||
|
appFontKey: 'comic-sans',
|
||||||
|
});
|
||||||
|
expect(await const SharedPreferencesAppFontStore().load(), AppFont.system);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('every bundled option has its four weights and its licence', () {
|
||||||
|
for (final font in AppFont.values) {
|
||||||
|
if (font == AppFont.system) {
|
||||||
|
expect(font.family, isNull);
|
||||||
|
expect(font.assets, isEmpty);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
expect(font.assets, hasLength(4));
|
||||||
|
expect(font.previewAsset, font.assets.first);
|
||||||
|
for (final asset in <String>[...font.assets, font.licenseAsset!]) {
|
||||||
|
expect(File(asset).existsSync(), isTrue, reason: asset);
|
||||||
|
}
|
||||||
|
expect(
|
||||||
|
File(font.licenseAsset!).readAsStringSync(),
|
||||||
|
contains('SIL OPEN FONT LICENSE Version 1.1'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the optional fonts are assets, not startup fonts', () {
|
||||||
|
final pubspec = File('pubspec.yaml').readAsStringSync();
|
||||||
|
final fonts = pubspec.substring(pubspec.indexOf('\n fonts:'));
|
||||||
|
for (final font in AppFont.values.where((f) => f.family != null)) {
|
||||||
|
expect(fonts, isNot(contains('family: ${font.family}')));
|
||||||
|
expect(
|
||||||
|
pubspec,
|
||||||
|
contains(' - ${font.licenseAsset!.replaceAll('OFL.txt', '')}\n'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/application/app.dart';
|
||||||
|
import 'package:pipelines_app/shell/destination.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/app_theme.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Material themes take the family and keep sizes and weights', () {
|
||||||
|
for (final build in <ThemeData Function({String? fontFamily})>[
|
||||||
|
appLightTheme,
|
||||||
|
appDarkTheme,
|
||||||
|
]) {
|
||||||
|
final system = build().textTheme;
|
||||||
|
final inter = build(fontFamily: 'Inter').textTheme;
|
||||||
|
expect(build().textTheme.bodyMedium?.fontFamily, isNot('Inter'));
|
||||||
|
for (final (a, b) in <(TextStyle?, TextStyle?)>[
|
||||||
|
(system.bodyMedium, inter.bodyMedium),
|
||||||
|
(system.titleMedium, inter.titleMedium),
|
||||||
|
(system.labelLarge, inter.labelLarge),
|
||||||
|
(system.headlineSmall, inter.headlineSmall),
|
||||||
|
]) {
|
||||||
|
expect(b?.fontFamily, 'Inter');
|
||||||
|
expect(b?.fontSize, a?.fontSize);
|
||||||
|
expect(b?.fontWeight, a?.fontWeight);
|
||||||
|
}
|
||||||
|
expect(
|
||||||
|
build(
|
||||||
|
fontFamily: 'Inter',
|
||||||
|
).cupertinoOverrideTheme?.textTheme?.textStyle.fontFamily,
|
||||||
|
'Inter',
|
||||||
|
);
|
||||||
|
expect(build().cupertinoOverrideTheme, isNull);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the Cupertino theme takes the family in every text role', () {
|
||||||
|
expect(appCupertinoThemeWith(), same(appCupertinoTheme));
|
||||||
|
final text = appCupertinoThemeWith(fontFamily: 'Inter').textTheme;
|
||||||
|
const stock = CupertinoTextThemeData();
|
||||||
|
for (final (a, b) in <(TextStyle, TextStyle)>[
|
||||||
|
(stock.textStyle, text.textStyle),
|
||||||
|
(stock.navTitleTextStyle, text.navTitleTextStyle),
|
||||||
|
(stock.navLargeTitleTextStyle, text.navLargeTitleTextStyle),
|
||||||
|
(stock.tabLabelTextStyle, text.tabLabelTextStyle),
|
||||||
|
(stock.actionTextStyle, text.actionTextStyle),
|
||||||
|
(stock.pickerTextStyle, text.pickerTextStyle),
|
||||||
|
]) {
|
||||||
|
expect(b.fontFamily, 'Inter');
|
||||||
|
expect(b.fontSize, a.fontSize);
|
||||||
|
expect(b.fontWeight, a.fontWeight);
|
||||||
|
}
|
||||||
|
expect(
|
||||||
|
appCupertinoThemeWith(fontFamily: 'Inter').scaffoldBackgroundColor,
|
||||||
|
AppColors.background,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (final cupertino in <bool>[false, true]) {
|
||||||
|
testWidgets('the ${cupertino ? 'Cupertino' : 'Material'} host switches '
|
||||||
|
'font live, without a restart', (tester) async {
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(),
|
||||||
|
loader: (family, assets) async {},
|
||||||
|
);
|
||||||
|
String? family;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MyApp(
|
||||||
|
cupertino: cupertino,
|
||||||
|
fonts: fonts,
|
||||||
|
destination: AppDestination.settings,
|
||||||
|
destinationBodies: <AppDestination, WidgetBuilder>{
|
||||||
|
AppDestination.settings: (context) => Builder(
|
||||||
|
builder: (context) {
|
||||||
|
family = DefaultTextStyle.of(context).style.fontFamily;
|
||||||
|
return const Text('body');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final before = family;
|
||||||
|
expect(before, isNot('IBM Plex Sans'));
|
||||||
|
await fonts.select(AppFont.ibmPlexSans);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(family, 'IBM Plex Sans');
|
||||||
|
await fonts.select(AppFont.system);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(family, before);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@ import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
|||||||
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart'
|
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart'
|
||||||
show searchFieldKey;
|
show searchFieldKey;
|
||||||
import 'package:pipelines_app/ui/input/app_search_field.dart';
|
import 'package:pipelines_app/ui/input/app_search_field.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_font.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
|
|
||||||
@@ -604,6 +606,13 @@ void main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
configurePerfFixture(params);
|
configurePerfFixture(params);
|
||||||
|
// `?font=inter` chooses a font as Settings would; otherwise the stored one.
|
||||||
|
final font = params['font'];
|
||||||
|
unawaited(
|
||||||
|
font == null
|
||||||
|
? AppFontController.instance.restore()
|
||||||
|
: AppFontController.instance.select(AppFont.fromId(font)),
|
||||||
|
);
|
||||||
_fillerRunCount = int.tryParse(params['runs'] ?? '') ?? 0;
|
_fillerRunCount = int.tryParse(params['runs'] ?? '') ?? 0;
|
||||||
_fillerStepCount = int.tryParse(params['steps'] ?? '') ?? 0;
|
_fillerStepCount = int.tryParse(params['steps'] ?? '') ?? 0;
|
||||||
final cupertino = params['platform'] == 'cupertino';
|
final cupertino = params['platform'] == 'cupertino';
|
||||||
|
|||||||
Reference in New Issue
Block a user