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

Commit 935817b

Browse files
disable text rounding hack by default
1 parent a9cd8a3 commit 935817b

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lib/ui/text.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,11 +3026,14 @@ abstract class ParagraphBuilder {
30263026
///
30273027
/// Do not rely on this getter as it exists for migration purposes only and
30283028
/// will soon be removed.
3029+
@Deprecated('''
3030+
The shouldDisableRoundingHack flag is for internal migration purposes only and should not be used.
3031+
''')
30293032
static bool get shouldDisableRoundingHack {
3030-
return const bool.hasEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK')
3033+
return const bool.fromEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK', defaultValue: true)
30313034
|| _roundingHackDisabledInDebugMode;
30323035
}
3033-
static bool _roundingHackDisabledInDebugMode = false;
3036+
static bool _roundingHackDisabledInDebugMode = true;
30343037

30353038
/// Only works in debug mode. Do not call this method as it is for migration
30363039
/// purposes only and will soon be removed.

lib/web_ui/test/canvaskit/text_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ void testMain() {
156156
ui.ParagraphBuilder.setDisableRoundingHack(roundingHackWasDisabled);
157157
});
158158

159-
test('rounding hack applied by default', () {
159+
test('rounding hack disabled by default', () {
160160
const double fontSize = 1.25;
161161
const String text = '12345';
162162
assert((fontSize * text.length).truncate() != fontSize * text.length);
163-
expect(ui.ParagraphBuilder.shouldDisableRoundingHack, isFalse);
163+
expect(ui.ParagraphBuilder.shouldDisableRoundingHack, isTrue);
164164
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(fontSize: fontSize, fontFamily: 'FlutterTest'));
165165
builder.addText(text);
166166
final ui.Paragraph paragraph = builder.build()
167167
..layout(const ui.ParagraphConstraints(width: text.length * fontSize));
168-
expect(paragraph.computeLineMetrics().length, greaterThan(1));
168+
expect(paragraph.computeLineMetrics().length, 1);
169169
});
170170

171171
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/71520

testing/dart/paragraph_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ void main() {
263263
ParagraphBuilder.setDisableRoundingHack(roundingHackWasDisabled);
264264
});
265265

266-
test('rounding hack applied by default', () {
266+
test('rounding hack disabled by default', () {
267267
const double fontSize = 1.25;
268268
const String text = '12345';
269269
assert((fontSize * text.length).truncate() != fontSize * text.length);
270-
expect(ParagraphBuilder.shouldDisableRoundingHack, isFalse);
270+
expect(ParagraphBuilder.shouldDisableRoundingHack, isTrue);
271271
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(fontSize: fontSize));
272272
builder.addText(text);
273273
final Paragraph paragraph = builder.build()
274274
..layout(const ParagraphConstraints(width: text.length * fontSize));
275-
expect(paragraph.computeLineMetrics().length, greaterThan(1));
275+
expect(paragraph.computeLineMetrics().length, 1);
276276
});
277277
}

0 commit comments

Comments
 (0)