This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -3024,7 +3024,7 @@ abstract class ParagraphBuilder {
3024
3024
return const bool .hasEnvironment ('SKPARAGRAPH_REMOVE_ROUNDING_HACK' )
3025
3025
|| _roundingHackDisabledInDebugMode;
3026
3026
}
3027
- static bool _roundingHackDisabledInDebugMode = true ;
3027
+ static bool _roundingHackDisabledInDebugMode = false ;
3028
3028
3029
3029
/// Only works in debug mode. Do not call this method as it is for migration
3030
3030
/// purposes only and will soon be removed.
Original file line number Diff line number Diff line change @@ -690,7 +690,7 @@ abstract class ParagraphBuilder {
690
690
return const bool .hasEnvironment ('SKPARAGRAPH_REMOVE_ROUNDING_HACK' )
691
691
|| _roundingHackDisabledInDebugMode;
692
692
}
693
- static bool _roundingHackDisabledInDebugMode = true ;
693
+ static bool _roundingHackDisabledInDebugMode = false ;
694
694
static void setDisableRoundingHack (bool disableRoundingHack) {
695
695
assert (() {
696
696
_roundingHackDisabledInDebugMode = disableRoundingHack;
Original file line number Diff line number Diff line change @@ -146,6 +146,19 @@ void testMain() {
146
146
}
147
147
ui.ParagraphBuilder .setDisableRoundingHack (roundingHackWasDisabled);
148
148
});
149
+
150
+ test ('rounding hack applied by default' , () {
151
+ const double fontSize = 1.25 ;
152
+ const String text = '12345' ;
153
+ assert ((fontSize * text.length).truncate () != fontSize * text.length);
154
+ expect (ui.ParagraphBuilder .shouldDisableRoundingHack, isFalse);
155
+ final ui.ParagraphBuilder builder = ui.ParagraphBuilder (ui.ParagraphStyle (fontSize: fontSize));
156
+ builder.addText (text);
157
+ final ui.Paragraph paragraph = builder.build ()
158
+ ..layout (const ui.ParagraphConstraints (width: text.length * fontSize));
159
+ expect (paragraph.maxIntrinsicWidth, greaterThan (text.length * fontSize));
160
+ });
161
+
149
162
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/71520
150
163
}, skip: isSafari || isFirefox);
151
164
}
Original file line number Diff line number Diff line change @@ -254,4 +254,16 @@ void main() {
254
254
}
255
255
ParagraphBuilder .setDisableRoundingHack (roundingHackWasDisabled);
256
256
});
257
+
258
+ test ('rounding hack applied by default' , () {
259
+ const double fontSize = 1.25 ;
260
+ const String text = '12345' ;
261
+ assert ((fontSize * text.length).truncate () != fontSize * text.length);
262
+ expect (ParagraphBuilder .shouldDisableRoundingHack, isFalse);
263
+ final ParagraphBuilder builder = ParagraphBuilder (ParagraphStyle (fontSize: fontSize));
264
+ builder.addText (text);
265
+ final Paragraph paragraph = builder.build ()
266
+ ..layout (const ParagraphConstraints (width: text.length * fontSize));
267
+ expect (paragraph.maxIntrinsicWidth, greaterThan (text.length * fontSize));
268
+ });
257
269
}
You can’t perform that action at this time.
0 commit comments