[web] Migrate Flutter Web to JS static interop - 9. (flutter/engine#32564)

This commit is contained in:
joshualitt 2022-04-20 16:01:12 -07:00 committed by GitHub
parent aa81a6bf83
commit 7bdc84940d
2 changed files with 7 additions and 3 deletions

View File

@ -2071,9 +2071,13 @@ extension SkFontFeatureExtension on SkFontFeature {
class SkTypeface {}
@JS('window.flutterCanvasKit.Font')
@staticInterop
class SkFont {
external factory SkFont(SkTypeface typeface);
external Uint8List getGlyphIDs(String text);
}
extension SkFontExtension on SkFont {
external Uint16List getGlyphIDs(String text);
external void getGlyphBounds(
List<int> glyphs, SkPaint? paint, Uint8List? output);
}

View File

@ -131,7 +131,7 @@ class FontFallbackData {
List<bool>.filled(codeUnits.length, false);
final String testString = String.fromCharCodes(codeUnits);
for (final SkFont font in fonts) {
final Uint8List glyphs = font.getGlyphIDs(testString);
final Uint16List glyphs = font.getGlyphIDs(testString);
assert(glyphs.length == codeUnitsSupported.length);
for (int i = 0; i < glyphs.length; i++) {
codeUnitsSupported[i] |= glyphs[i] != 0 || _isControlCode(codeUnits[i]);
@ -182,7 +182,7 @@ class FontFallbackData {
continue;
}
for (final SkFont font in fontsForFamily) {
final Uint8List glyphs = font.getGlyphIDs(testString);
final Uint16List glyphs = font.getGlyphIDs(testString);
assert(glyphs.length == codeUnitsSupported.length);
for (int i = 0; i < glyphs.length; i++) {
final bool codeUnitSupported = glyphs[i] != 0;