Skip to content

Commit

Permalink
Add "sans-serif" as the first fontFamilyFallback
Browse files Browse the repository at this point in the history
  • Loading branch information
LastMonopoly committed Feb 4, 2023
1 parent 6cdb0cc commit b93b21f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ return MaterialApp(
| :---: | :------: | :-------: | :---: | :-----: | :---: | :---: | :---: | :---: | :---: |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |

## Reference

[Flutter 小技巧之玩转字体渲染和问题修复](https://juejin.cn/post/7108463516952035365)

## Contributions
[LiTang0908](https://github.com/litang0908)
File renamed without changes.
11 changes: 10 additions & 1 deletion example/lib/text_theme_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ class TextThemeDemo extends StatelessWidget {
if (useSystemChineseFont) {
return Theme(
data: ThemeData(
textTheme: SystemChineseFont.textTheme.apply(fontFamily: 'LatoLato'),
textTheme: SystemChineseFont.textTheme
.merge(
// Custom text theme
const TextTheme(
displaySmall: TextStyle(fontStyle: FontStyle.italic),
displayMedium: TextStyle(fontStyle: FontStyle.italic),
displayLarge: TextStyle(fontStyle: FontStyle.italic),
),
) // Apply change to the entire fontTheme
.apply(fontFamily: 'LatoLato'),
),
child: const ThemedTextList(),
);
Expand Down
1 change: 1 addition & 0 deletions lib/src/system_chinese_font.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SystemChineseFont {

/// Chinese font family fallback, for most platforms
static const List<String> fontFamilyFallback = [
"sans-serif",
...appleFontFamily,
...xiaomiFontFamily,
...windowsFontFamily,
Expand Down

0 comments on commit b93b21f

Please sign in to comment.