Skip to content

Commit

Permalink
fix display of non-ascii glyphs in localizations
Browse files Browse the repository at this point in the history
For example, this affects ẞ in SCHLIEẞEN button.
We add the regular Noto Sans as fallback.
  • Loading branch information
mwageringel committed Aug 13, 2022
1 parent 17eb76e commit f4d93e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ icons-clean:
rm -f assets/launcher_icon.png assets/launcher_icon_adaptive.png

# fonts are downloaded and bundled into the app
fonts: fonts/NotoSansMath-Regular.ttf
fonts: fonts/NotoSansMath-Regular.ttf fonts/NotoSans-Regular.ttf
fonts/NotoSansMath-Regular.ttf: | build/upstream/Noto_Sans_Math.zip
mkdir -p fonts/
unzip -o build/upstream/Noto_Sans_Math.zip -d fonts/
build/upstream/Noto_Sans_Math.zip:
mkdir -p build/upstream/
curl --output build/upstream/Noto_Sans_Math.zip https://fonts.google.com/download?family=Noto%20Sans%20Math
.INTERMEDIATE: build/upstream/Noto_Sans_Math.zip
fonts/NotoSans-Regular.ttf: | build/upstream/Noto_Sans.zip
mkdir -p fonts/
unzip -o build/upstream/Noto_Sans.zip -d fonts/
build/upstream/Noto_Sans.zip:
mkdir -p build/upstream/
curl --output build/upstream/Noto_Sans.zip https://fonts.google.com/download?family=Noto%20Sans
.INTERMEDIATE: build/upstream/Noto_Sans_Math.zip build/upstream/Noto_Sans.zip

.PHONY: all app web gh-pages host run test assets-android assets-web fonts icons-android icons-fdroid icons-web icons-clean clean
13 changes: 7 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class QuestionsWidget extends StatelessWidget {
if (j != -1) {
t = Text.rich(TextSpan(
text: q.substring(0, j),
style: _biggerFont,
style: _biggerFontMath,
children: [
// TextSpan(text: q.substring(j, j+1), style: TextStyle(backgroundColor: Theme.of(context).focusColor)),
WidgetSpan( // with padding
Expand All @@ -170,15 +170,15 @@ class QuestionsWidget extends StatelessWidget {
color: Theme.of(context).focusColor,
borderRadius: const BorderRadius.all(Radius.circular(3.0)),
),
child: Text(q.substring(j, j+1), style: _biggerFont),
child: Text(q.substring(j, j+1), style: _biggerFontMath),
),
),
TextSpan(text: q.substring(j+1)),
],
));
}
}
t ??= Text(q, style: _biggerFont);
t ??= Text(q, style: _biggerFontMath);
return ListTile(
title: t,
trailing: (i == questions.length - 1) ? StatusIcon(status, animateStatusWrong: animateStatusWrong) : null,
Expand Down Expand Up @@ -266,6 +266,7 @@ Iterable<A> interleave<A>(Iterable<A> it, A separator) {

const listPadding = EdgeInsets.all(8.0);
const _biggerFont = TextStyle(fontSize: 18.0);
final _biggerFontMath = _biggerFont.copyWith(fontFamily: 'NotoSansMath', fontFamilyFallback: ['NotoSans']);

class KeyboardButton extends StatelessWidget {
static const _keyIcons = {
Expand Down Expand Up @@ -644,7 +645,7 @@ class MyApp extends StatelessWidget {
title: appName,
themeMode: world.themeMode,
theme: FlexThemeData.light(
fontFamily: 'NotoSansMath',
fontFamily: 'NotoSans',
scheme: FlexScheme.materialBaseline,
primary: Colors.indigo,
surfaceMode: FlexSurfaceMode.highScaffoldLowSurface,
Expand All @@ -657,7 +658,7 @@ class MyApp extends StatelessWidget {
visualDensity: FlexColorScheme.comfortablePlatformDensity,
),
darkTheme: FlexThemeData.dark(
fontFamily: 'NotoSansMath',
fontFamily: 'NotoSans',
scheme: FlexScheme.materialBaseline,
primary: Colors.indigoAccent, // better contrast against dark background
surfaceMode: FlexSurfaceMode.highScaffoldLowSurface,
Expand Down Expand Up @@ -728,7 +729,7 @@ void main() async {

LicenseRegistry.addLicense(() async* {
final license = await rootBundle.loadString('fonts/OFL.txt');
yield LicenseEntryWithLineBreaks(['NotoSansMath'], license);
yield LicenseEntryWithLineBreaks(['NotoSansMath', 'NotoSans'], license);
});

Future<void> loadGameState(Game game) async {
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ flutter:
- family: NotoSansMath
fonts:
- asset: fonts/NotoSansMath-Regular.ttf
- family: NotoSans
fonts:
- asset: fonts/NotoSans-Regular.ttf

assets:
# license for NotoSansMath
# license for Noto fonts
- fonts/OFL.txt

flutter_icons:
Expand Down

0 comments on commit f4d93e0

Please sign in to comment.