Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Use a Japanese font so Japanese text stops showing Chinese character shapes

Barnabas77d2c87abb0b
diff --git a/assets/fonts/NotoSansJP-Regular.otf b/assets/fonts/NotoSansJP-Regular.otf
new file mode 100644
index 00000000..4af556ab
Binary files /dev/null and b/assets/fonts/NotoSansJP-Regular.otf differ
diff --git a/lib/main.dart b/lib/main.dart
index 52ba1434..60093b1d 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -298,6 +298,15 @@ class AbsorbApp extends StatelessWidget {
final currentMode = themeNotifier.value;
final isFlat = flatNotifier.value;
final overrideLocale = localeNotifier.value;
+ // Japanese shares many codepoints with Chinese (Han unification) but
+ // draws some kanji differently. Flutter on Android doesn't hint the
+ // text engine per locale, so it falls back to Chinese glyph shapes.
+ // When the app is running in Japanese, prepend a bundled Japanese font
+ // so kanji render with the right shapes. Other languages are untouched.
+ final isJapanese =
+ (overrideLocale ?? WidgetsBinding.instance.platformDispatcher.locale)
+ .languageCode == 'ja';
+ final cjkFallback = isJapanese ? const ['NotoSansJP'] : null;
final coverScheme = coverSchemeNotifier.value;
final isManual = colorSourceNotifier.value == 'manual';
@@ -397,6 +406,7 @@ class AbsorbApp extends StatelessWidget {
theme: ThemeData(
useMaterial3: true,
colorScheme: lightScheme,
+ fontFamilyFallback: cjkFallback,
scaffoldBackgroundColor: lightScheme.surface,
cardTheme: CardThemeData(
color: lightScheme.surfaceContainerHigh,
@@ -452,6 +462,7 @@ class AbsorbApp extends StatelessWidget {
darkTheme: ThemeData(
useMaterial3: true,
colorScheme: darkScheme,
+ fontFamilyFallback: cjkFallback,
scaffoldBackgroundColor: isFlat ? Colors.black : const Color(0xFF0E0E0E),
cardTheme: CardThemeData(
color: darkScheme.surfaceContainerHigh,
diff --git a/pubspec.yaml b/pubspec.yaml
index 1a8c7754..08660222 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -109,6 +109,10 @@ flutter:
assets:
- assets/icon/
- assets/audio/
+ fonts:
+ - family: NotoSansJP
+ fonts:
+ - asset: assets/fonts/NotoSansJP-Regular.otf
flutter_launcher_icons:
android: true