diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart index 24af20555e..5ee33c9824 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart @@ -180,6 +180,7 @@ class SkwasmFontCollection implements FlutterFontCollection { } else { fontCollectionRegisterTypeface(handle, typeface.handle, nullptr); } + fontCollectionClearCaches(handle); return true; } diff --git a/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart b/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart index f0d2c0acad..2b7f736761 100644 --- a/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/ui/text_golden_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:math' as math; +import 'dart:typed_data'; import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; @@ -183,6 +184,19 @@ Future testMain() async { await testTextStyle('non-existent font family', fontFamily: 'DoesNotExist'); }); + test('text styles - changes font after font manually loaded', () async { + await testTextStyle('before font load', fontFamily: 'Roboto Slab'); + final FlutterFontCollection collection = renderer.fontCollection; + final ByteBuffer robotoSlabData = await httpFetchByteBuffer( + '/assets/fonts/RobotoSlab-VariableFont_wght.ttf', + ); + expect( + await collection.loadFontFromList(robotoSlabData.asUint8List(), fontFamily: 'Roboto Slab'), + true, + ); + await testTextStyle('after font load', fontFamily: 'Roboto Slab'); + }); + test('text styles - family fallback', () async { await testTextStyle( 'family fallback',