opt.: handle situation that font file not existing

This commit is contained in:
lollipopkit
2023-08-30 17:15:36 +08:00
parent 2f4b522189
commit be62767d45
2 changed files with 6 additions and 3 deletions

View File

@@ -119,8 +119,10 @@ Future<void> loadFontFile(String localPath) async {
if (localPath.isEmpty) return;
final name = getFileName(localPath);
if (name == null) return;
final file = File(localPath);
if (!await file.exists()) return;
var fontLoader = FontLoader(name);
fontLoader.addFont(File(localPath).readAsBytes().byteData);
fontLoader.addFont(file.readAsBytes().byteData);
await fontLoader.load();
}