Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7f25023

Browse files
Revert "Make FlutterTest the default test font (#40188)" (#40237)
This reverts commit 9270e3d.
1 parent 12f2fdf commit 7f25023

File tree

6 files changed

+20
-30
lines changed

6 files changed

+20
-30
lines changed

lib/web_ui/lib/src/engine/canvaskit/fonts.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,12 @@ class SkiaFontCollection implements FontCollection {
184184
}
185185
}
186186
final List<UnregisteredFont?> completedPendingFonts = await Future.wait(pendingFonts);
187-
final List<UnregisteredFont> fonts = <UnregisteredFont>[
188-
UnregisteredFont(
187+
completedPendingFonts.add(UnregisteredFont(
189188
EmbeddedTestFont.flutterTest.data.buffer,
190189
'<embedded>',
191190
EmbeddedTestFont.flutterTest.fontFamily,
192-
),
193-
...completedPendingFonts.whereType<UnregisteredFont>(),
194-
];
195-
_unregisteredFonts.addAll(fonts);
191+
));
192+
_unregisteredFonts.addAll(completedPendingFonts.whereType<UnregisteredFont>());
196193

197194
// Ahem must be added to font fallbacks list regardless of where it was
198195
// downloaded from.

lib/web_ui/lib/src/engine/text/font_collection.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ class HtmlFontCollection implements FontCollection {
7676
@override
7777
Future<void> debugDownloadTestFonts() async {
7878
final FontManager fontManager = _testFontManager = FontManager();
79+
for (final MapEntry<String, String> fontEntry in testFontUrls.entries) {
80+
fontManager.downloadAsset(fontEntry.key, 'url(${fontEntry.value})', const <String, String>{});
81+
}
7982
fontManager._downloadedFonts.add(createDomFontFace(
8083
EmbeddedTestFont.flutterTest.fontFamily,
8184
EmbeddedTestFont.flutterTest.data,
8285
));
83-
for (final MapEntry<String, String> fontEntry in testFontUrls.entries) {
84-
fontManager.downloadAsset(fontEntry.key, 'url(${fontEntry.value})', const <String, String>{});
85-
}
8686
await fontManager.downloadAllFonts();
8787
}
8888

lib/web_ui/test/canvaskit/skia_font_collection_test.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,5 @@ void testMain() {
181181
expect(fontCollection.debugRegisteredFonts, isNotEmpty);
182182
expect(warnings, isEmpty);
183183
});
184-
185-
test('FlutterTest is the default test font', () async {
186-
final SkiaFontCollection fontCollection = SkiaFontCollection();
187-
188-
await fontCollection.debugDownloadTestFonts();
189-
fontCollection.registerDownloadedFonts();
190-
expect(fontCollection.debugRegisteredFonts, isNotEmpty);
191-
expect(fontCollection.debugRegisteredFonts!.first.family, 'FlutterTest');
192-
});
193184
});
194185
}

runtime/test_font_data.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,19 +1621,19 @@ namespace flutter {
16211621
std::vector<sk_sp<SkTypeface>> GetTestFontData() {
16221622
std::vector<sk_sp<SkTypeface>> typefaces;
16231623
#if EMBED_TEST_FONT_DATA
1624-
typefaces.push_back(SkTypeface::MakeFromStream(
1625-
SkMemoryStream::MakeDirect(kFlutterTestFont, kFlutterTestFontLength)));
16261624
typefaces.push_back(SkTypeface::MakeFromStream(
16271625
SkMemoryStream::MakeDirect(kAhemFont, kAhemFontLength)));
16281626
typefaces.push_back(SkTypeface::MakeFromStream(
16291627
SkMemoryStream::MakeDirect(kCoughFont, kCoughFontLength)));
1628+
typefaces.push_back(SkTypeface::MakeFromStream(
1629+
SkMemoryStream::MakeDirect(kFlutterTestFont, kFlutterTestFontLength)));
16301630
#endif // EMBED_TEST_FONT_DATA
16311631
return typefaces;
16321632
}
16331633

16341634
std::vector<std::string> GetTestFontFamilyNames() {
16351635
#if EMBED_TEST_FONT_DATA
1636-
std::vector<std::string> names = {"FlutterTest", "Ahem", "Cough"};
1636+
std::vector<std::string> names = {"Ahem", "Cough", "FlutterTest"};
16371637
#else // EMBED_TEST_FONT_DATA
16381638
std::vector<std::string> names;
16391639
#endif // EMBED_TEST_FONT_DATA

testing/dart/canvas_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ void main() {
331331
builder.pushStyle(TextStyle(
332332
decoration: TextDecoration.underline,
333333
decorationColor: const Color(0xFF0000FF),
334-
fontFamily: 'Ahem',
335334
fontSize: 10,
336335
color: const Color(0xFF000000),
337336
decorationStyle: style,

testing/dart/paragraph_builder_test.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import 'dart:ui';
77
import 'package:litetest/litetest.dart';
88

99
void main() {
10+
// The actual values for font measurements will vary by platform slightly.
11+
const double epsillon = 0.0001;
12+
1013
test('Should be able to build and layout a paragraph', () {
1114
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle());
1215
builder.addText('Hello');
@@ -37,10 +40,10 @@ void main() {
3740

3841
final List<TextBox> boxes = paragraph.getBoxesForRange(0, 3);
3942
expect(boxes.length, 1);
40-
expect(boxes.first.left, 0.0);
41-
expect(boxes.first.top, 0.0);
42-
expect(boxes.first.right, 42.0);
43-
expect(boxes.first.bottom, 14.0);
43+
expect(boxes.first.left, 0);
44+
expect(boxes.first.top, closeTo(0, epsillon));
45+
expect(boxes.first.right, closeTo(42, epsillon));
46+
expect(boxes.first.bottom, closeTo(14, epsillon));
4447
expect(boxes.first.direction, TextDirection.ltr);
4548
});
4649

@@ -57,13 +60,13 @@ void main() {
5760
final List<LineMetrics> metrics = paragraph.computeLineMetrics();
5861
expect(metrics.length, 1);
5962
expect(metrics.first.hardBreak, true);
60-
expect(metrics.first.ascent, 10.5);
61-
expect(metrics.first.descent, 3.5);
62-
expect(metrics.first.unscaledAscent, 10.5);
63+
expect(metrics.first.ascent, closeTo(11.200042724609375, epsillon));
64+
expect(metrics.first.descent, closeTo(2.799957275390625, epsillon));
65+
expect(metrics.first.unscaledAscent, closeTo(11.200042724609375, epsillon));
6366
expect(metrics.first.height, 14.0);
6467
expect(metrics.first.width, 70.0);
6568
expect(metrics.first.left, 0.0);
66-
expect(metrics.first.baseline, 10.5);
69+
expect(metrics.first.baseline, closeTo(11.200042724609375, epsillon));
6770
expect(metrics.first.lineNumber, 0);
6871
});
6972
}

0 commit comments

Comments
 (0)