mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: font family warning (#5329)
This commit is contained in:
@ -1,7 +1,14 @@
|
|||||||
|
import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
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
|
// if the font family is not available, google fonts packages will throw an exception
|
||||||
// this method will return the system font family if the font family is not available
|
// this method will return the system font family if the font family is not available
|
||||||
TextStyle getGoogleFontSafely(
|
TextStyle getGoogleFontSafely(
|
||||||
@ -12,19 +19,31 @@ TextStyle getGoogleFontSafely(
|
|||||||
double? letterSpacing,
|
double? letterSpacing,
|
||||||
double? lineHeight,
|
double? lineHeight,
|
||||||
}) {
|
}) {
|
||||||
try {
|
// if the font family is the built-in font family, we can use it directly
|
||||||
return GoogleFonts.getFont(
|
if (_defaultFontFamilies.contains(fontFamily)) {
|
||||||
fontFamily,
|
return TextStyle(
|
||||||
|
fontFamily: fontFamily.isEmpty ? null : fontFamily,
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight,
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
color: fontColor,
|
color: fontColor,
|
||||||
letterSpacing: letterSpacing,
|
letterSpacing: letterSpacing,
|
||||||
height: lineHeight,
|
height: lineHeight,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} else {
|
||||||
Log.error(
|
try {
|
||||||
'Font family $fontFamily is not available, using default font family instead',
|
return GoogleFonts.getFont(
|
||||||
);
|
fontFamily,
|
||||||
|
fontWeight: fontWeight,
|
||||||
|
fontSize: fontSize,
|
||||||
|
color: fontColor,
|
||||||
|
letterSpacing: letterSpacing,
|
||||||
|
height: lineHeight,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
Log.error(
|
||||||
|
'Font family $fontFamily is not available, using default font family instead',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TextStyle(
|
return TextStyle(
|
||||||
|
Reference in New Issue
Block a user