@@ -2798,7 +2798,7 @@ abstract class Paragraph {
27982798 /// This only returns a valid value if asserts are enabled, and must not be
27992799 /// used otherwise.
28002800 bool get debugDisposed;
2801- }
2801+ }
28022802
28032803@pragma ('vm:entry-point' )
28042804base class _NativeParagraph extends NativeFieldWrapperClass1 implements Paragraph {
@@ -3015,6 +3015,28 @@ abstract class ParagraphBuilder {
30153015 /// [Paragraph] .
30163016 factory ParagraphBuilder (ParagraphStyle style) = _NativeParagraphBuilder ;
30173017
3018+ /// Whether the rounding hack enabled by default in SkParagraph and TextPainter
3019+ /// is disabled.
3020+ ///
3021+ /// Do not rely on this getter as it exists for migration purposes only and
3022+ /// will soon be removed.
3023+ static bool get shouldDisableRoundingHack {
3024+ return const bool .hasEnvironment ('SKPARAGRAPH_REMOVE_ROUNDING_HACK' )
3025+ || _roundingHackDisabledInDebugMode;
3026+ }
3027+ static bool _roundingHackDisabledInDebugMode = false ;
3028+
3029+ /// Only works in debug mode. Do not call this method as it is for migration
3030+ /// purposes only and will soon be removed.
3031+ static void setDisableRoundingHack (bool disableRoundingHack) {
3032+ // bool.hasEnvironment does not work in internal tests so an additional flag
3033+ // is needed for tests.
3034+ assert (() {
3035+ _roundingHackDisabledInDebugMode = disableRoundingHack;
3036+ return true ;
3037+ }());
3038+ }
3039+
30183040 /// The number of placeholders currently in the paragraph.
30193041 int get placeholderCount;
30203042
@@ -3132,11 +3154,12 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P
31323154 style._fontSize ?? 0 ,
31333155 style._height ?? 0 ,
31343156 style._ellipsis ?? '' ,
3135- _encodeLocale (style._locale)
3157+ _encodeLocale (style._locale),
3158+ ! ParagraphBuilder .shouldDisableRoundingHack,
31363159 );
31373160 }
31383161
3139- @Native < Void Function (Handle , Handle , Handle , Handle , Handle , Double , Double , Handle , Handle )> (symbol: 'ParagraphBuilder::Create' )
3162+ @Native < Void Function (Handle , Handle , Handle , Handle , Handle , Double , Double , Handle , Handle , Bool )> (symbol: 'ParagraphBuilder::Create' )
31403163 external void _constructor (
31413164 Int32List encoded,
31423165 ByteData ? strutData,
@@ -3145,7 +3168,8 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P
31453168 double fontSize,
31463169 double height,
31473170 String ellipsis,
3148- String locale);
3171+ String locale,
3172+ bool applyRoundingHack);
31493173
31503174 @override
31513175 int get placeholderCount => _placeholderCount;
0 commit comments