Skip to content

Commit 2ed5940

Browse files
authored
[web] (#40428)
1 parent 25a58de commit 2ed5940

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

lib/web_ui/lib/src/engine/dom.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ DomFontFace createDomFontFace(String family, Object source,
18891889
return DomFontFace._args2(family.toJS, source.toJSAnyShallow);
18901890
} else {
18911891
return DomFontFace._args3(
1892-
family.toJS, source.toJSAnyShallow, descriptors.toJSAnyShallow);
1892+
family.toJS, source.toJSAnyShallow, descriptors.toJSAnyDeep);
18931893
}
18941894
}
18951895

@@ -1901,6 +1901,10 @@ extension DomFontFaceExtension on DomFontFace {
19011901
@JS('family')
19021902
external JSString? get _family;
19031903
String? get family => _family?.toDart;
1904+
1905+
@JS('weight')
1906+
external JSString? get _weight;
1907+
String? get weight => _weight?.toDart;
19041908
}
19051909

19061910
@JS()

lib/web_ui/test/text/font_collection_test.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@ void testMain() {
7777
expect(fontFamilyList.length, equals(1));
7878
expect(fontFamilyList.first, 'AhEm');
7979
});
80+
81+
test('Register Asset with descriptor', () async {
82+
const String testFontFamily = 'Ahem';
83+
final List<String> fontFamilyList = <String>[];
84+
85+
fontManager.downloadAsset(
86+
testFontFamily, 'url($testFontUrl)', const <String, String>{
87+
'weight': 'bold',
88+
});
89+
await fontManager.downloadAllFonts();
90+
fontManager.registerDownloadedFonts();
91+
domDocument.fonts!
92+
.forEach((DomFontFace f, DomFontFace f2, DomFontFaceSet s) {
93+
expect(f.weight, 'bold');
94+
expect(f2.weight, 'bold');
95+
fontFamilyList.add(f.family!);
96+
});
97+
98+
expect(fontFamilyList.length, equals(1));
99+
expect(fontFamilyList.first, 'Ahem');
100+
});
80101
});
81102

82103
group('fonts with special characters', () {

0 commit comments

Comments
 (0)