Add font fallback for Linux and Windows platforms

This commit is contained in:
2025-06-28 10:27:18 +08:00
parent e86f8b7f51
commit 3d49bebc44

View File

@@ -134,12 +134,29 @@ class MyApp extends StatelessWidget {
throw "widget is null"; throw "widget is null";
} }
String? font;
List<String>? fallback;
if (App.isLinux || App.isWindows) {
font = 'Noto Sans CJK';
fallback = [
'Segoe UI',
'Noto Sans SC',
'Noto Sans TC',
'Noto Sans',
'Microsoft YaHei',
'PingFang SC',
'Arial',
'sans-serif'
];
}
Widget widget = MdTheme( Widget widget = MdTheme(
data: MdThemeData.from( data: MdThemeData.from(
colorScheme: colorScheme, useMaterial3: true), colorScheme: colorScheme, useMaterial3: true),
child: DefaultTextStyle.merge( child: DefaultTextStyle.merge(
style: TextStyle( style: TextStyle(
fontFamily: App.isWindows ? "Microsoft YaHei UI" : null, fontFamily: font,
fontFamilyFallback: fallback,
), ),
child: OverlayWidget(child), child: OverlayWidget(child),
), ),