Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class SkwasmFontCollection implements FlutterFontCollection {
@override
Future<AssetFontsResult> loadAssetFonts(FontManifest manifest) async {
final List<Future<void>> fontFutures = <Future<void>>[];
final List<String> loadedFonts = <String>[];
final Map<String, FontLoadError> fontFailures = <String, FontLoadError>{};

/// We need a default fallback font for Skwasm, in order to avoid crashing
Expand All @@ -81,20 +80,22 @@ class SkwasmFontCollection implements FlutterFontCollection {
);
}

final List<String> loadedFonts = <String>[];
for (final FontFamily family in manifest.families) {
for (final FontAsset fontAsset in family.fontAssets) {
loadedFonts.add(fontAsset.asset);
fontFutures.add(() async {
final FontLoadError? error = await _downloadFontAsset(fontAsset, family.name);
if (error == null) {
loadedFonts.add(fontAsset.asset);
} else {
if (error != null) {
fontFailures[fontAsset.asset] = error;
}
}());
}
}

await Future.wait(fontFutures);

loadedFonts.removeWhere((String assetName) => fontFailures.containsKey(assetName));
return AssetFontsResult(loadedFonts, fontFailures);
}

Expand Down