From 1e485188ebef64ba6d244122dceb6bdae613276c Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 4 Jun 2024 09:28:28 +0800 Subject: [PATCH] fix: font not found error log (#5449) * fix: font not found error log * fix: flutter analyze --- .../document/presentation/editor_style.dart | 3 +-- .../lib/shared/google_fonts_extension.dart | 1 - .../settings/appearance/appearance_cubit.dart | 6 +----- .../settings/appearance/base_appearance.dart | 5 +---- .../app_setting_test/appearance_test.dart | 1 - .../test/widget_test/direction_setting_test.dart | 15 +++++++-------- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart index 0b3aca1ce7..bc48ddf8a2 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart @@ -237,8 +237,7 @@ class EditorStyleCustomizer { try { return getGoogleFontSafely(fontFamily, fontWeight: fontWeight); } on Exception { - if ([defaultFontFamily, fallbackFontFamily, builtInCodeFontFamily] - .contains(fontFamily)) { + if ([defaultFontFamily, builtInCodeFontFamily].contains(fontFamily)) { return TextStyle(fontFamily: fontFamily, fontWeight: fontWeight); } diff --git a/frontend/appflowy_flutter/lib/shared/google_fonts_extension.dart b/frontend/appflowy_flutter/lib/shared/google_fonts_extension.dart index 287bfcbcd9..c5cb5df786 100644 --- a/frontend/appflowy_flutter/lib/shared/google_fonts_extension.dart +++ b/frontend/appflowy_flutter/lib/shared/google_fonts_extension.dart @@ -6,7 +6,6 @@ import 'package:google_fonts/google_fonts.dart'; const _defaultFontFamilies = [ defaultFontFamily, builtInCodeFontFamily, - fallbackFontFamily, ]; // if the font family is not available, google fonts packages will throw an exception diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/appearance_cubit.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/appearance_cubit.dart index fa9b571478..a034558110 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/appearance_cubit.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/appearance_cubit.dart @@ -41,7 +41,6 @@ class AppearanceSettingsCubit extends Cubit { appTheme, appearanceSettings.themeMode, appearanceSettings.font, - appearanceSettings.monospaceFont, appearanceSettings.layoutDirection, appearanceSettings.textDirection, appearanceSettings.enableRtlToolbarItems, @@ -374,7 +373,6 @@ class AppearanceSettingsState with _$AppearanceSettingsState { required AppTheme appTheme, required ThemeMode themeMode, required String font, - required String monospaceFont, required LayoutDirection layoutDirection, required AppFlowyTextDirection? textDirection, required bool enableRtlToolbarItems, @@ -393,7 +391,6 @@ class AppearanceSettingsState with _$AppearanceSettingsState { AppTheme appTheme, ThemeModePB themeModePB, String font, - String monospaceFont, LayoutDirectionPB layoutDirectionPB, TextDirectionPB? textDirectionPB, bool enableRtlToolbarItems, @@ -410,7 +407,6 @@ class AppearanceSettingsState with _$AppearanceSettingsState { return AppearanceSettingsState( appTheme: appTheme, font: font, - monospaceFont: monospaceFont, layoutDirection: LayoutDirection.fromLayoutDirectionPB(layoutDirectionPB), textDirection: AppFlowyTextDirection.fromTextDirectionPB(textDirectionPB), enableRtlToolbarItems: enableRtlToolbarItems, @@ -435,7 +431,7 @@ class AppearanceSettingsState with _$AppearanceSettingsState { appTheme, brightness, font, - monospaceFont, + builtInCodeFontFamily, ); } } diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/base_appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/base_appearance.dart index 0c6fe9aaed..952f1e18f9 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/base_appearance.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/base_appearance.dart @@ -11,9 +11,6 @@ import 'package:flutter/material.dart'; // Desktop: Based on the OS const defaultFontFamily = ''; -// the Poppins font is embedded in the app, so we can use it without GoogleFonts -// TODO(Lucas): after releasing version 0.5.6, remove it. -const fallbackFontFamily = 'Poppins'; const builtInCodeFontFamily = 'RobotoMono'; abstract class BaseAppearance { @@ -47,7 +44,7 @@ abstract class BaseAppearance { height: lineHeight, ); - if (fontFamily == defaultFontFamily || fontFamily == fallbackFontFamily) { + if (fontFamily == defaultFontFamily) { return textStyle; } diff --git a/frontend/appflowy_flutter/test/bloc_test/app_setting_test/appearance_test.dart b/frontend/appflowy_flutter/test/bloc_test/app_setting_test/appearance_test.dart index 4f8f4b786a..d9cd57757e 100644 --- a/frontend/appflowy_flutter/test/bloc_test/app_setting_test/appearance_test.dart +++ b/frontend/appflowy_flutter/test/bloc_test/app_setting_test/appearance_test.dart @@ -37,7 +37,6 @@ void main() { ), verify: (bloc) { expect(bloc.state.font, defaultFontFamily); - expect(bloc.state.monospaceFont, 'SF Mono'); expect(bloc.state.themeMode, ThemeMode.system); }, ); diff --git a/frontend/appflowy_flutter/test/widget_test/direction_setting_test.dart b/frontend/appflowy_flutter/test/widget_test/direction_setting_test.dart index 34472193f9..d83706f068 100644 --- a/frontend/appflowy_flutter/test/widget_test/direction_setting_test.dart +++ b/frontend/appflowy_flutter/test/widget_test/direction_setting_test.dart @@ -1,17 +1,17 @@ -import 'package:appflowy/workspace/presentation/settings/pages/settings_workspace_view.dart'; -import 'package:appflowy/workspace/presentation/settings/shared/settings_radio_select.dart'; -import 'package:flowy_infra/theme.dart'; -import 'package:flutter/material.dart'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart'; +import 'package:appflowy/user/application/user_settings_service.dart'; import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart'; +import 'package:appflowy/workspace/presentation/settings/pages/settings_workspace_view.dart'; +import 'package:appflowy/workspace/presentation/settings/shared/settings_radio_select.dart'; +import 'package:appflowy_backend/protobuf/flowy-user/user_setting.pb.dart'; +import 'package:bloc_test/bloc_test.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:flowy_infra/theme.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; -import 'package:bloc_test/bloc_test.dart'; -import 'package:appflowy_backend/protobuf/flowy-user/user_setting.pb.dart'; -import 'package:appflowy/user/application/user_settings_service.dart'; import '../util.dart'; @@ -41,7 +41,6 @@ void main() { AppTheme.fallback, appearanceSettings.themeMode, appearanceSettings.font, - appearanceSettings.monospaceFont, appearanceSettings.layoutDirection, appearanceSettings.textDirection, appearanceSettings.enableRtlToolbarItems,