From 086195d2cfb4c1e8a048098394e3d27a5b9743d4 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 30 Nov 2022 16:32:43 +0800 Subject: [PATCH] fix: inconsistent font weight in Chinese #1488 --- .../lib/startup/tasks/app_widget.dart | 2 +- .../packages/flowy_infra/lib/theme.dart | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/app_flowy/lib/startup/tasks/app_widget.dart b/frontend/app_flowy/lib/startup/tasks/app_widget.dart index 8ec181d9e3..bacb38f7aa 100644 --- a/frontend/app_flowy/lib/startup/tasks/app_widget.dart +++ b/frontend/app_flowy/lib/startup/tasks/app_widget.dart @@ -82,7 +82,7 @@ class ApplicationWidget extends StatelessWidget { builder: (context, state) => MaterialApp( builder: overlayManagerBuilder(), debugShowCheckedModeBanner: false, - theme: state.theme.themeData, + theme: state.theme.getThemeData(state.locale), localizationsDelegates: context.localizationDelegates + [AppFlowyEditorLocalizations.delegate], supportedLocales: context.supportedLocales, diff --git a/frontend/app_flowy/packages/flowy_infra/lib/theme.dart b/frontend/app_flowy/packages/flowy_infra/lib/theme.dart index fcd7ef95e5..77ecc18e20 100644 --- a/frontend/app_flowy/packages/flowy_infra/lib/theme.dart +++ b/frontend/app_flowy/packages/flowy_infra/lib/theme.dart @@ -155,13 +155,26 @@ class AppTheme { } } - ThemeData get themeData { - final textTheme = TextStyles(font: font, color: shader1); + ThemeData getThemeData(Locale locale) { + // Poppins and SF Mono are not well supported in some languages, so use the + // built-in font for the following languages. + final useBuiltInFontLanguages = [ + const Locale('zh', 'CN'), + const Locale('zh', 'TW'), + ]; + TextStyles textTheme; + if (useBuiltInFontLanguages.contains(locale)) { + textTheme = TextStyles(font: '', color: shader1); + } else { + textTheme = TextStyles(font: font, color: shader1); + } return ThemeData( brightness: brightness, textTheme: textTheme.generateTextTheme(), textSelectionTheme: TextSelectionThemeData( - cursorColor: main2, selectionHandleColor: main2), + cursorColor: main2, + selectionHandleColor: main2, + ), primaryIconTheme: IconThemeData(color: hover), iconTheme: IconThemeData(color: shader1), scrollbarTheme: ScrollbarThemeData(