Description
When the use_swt_fonts flag is enabled, the computed sizes (computeSize) of some widgets (e.g., Button and Link) are incorrect.
The use_swt_fonts flag determines whether the widget uses:
- The font and foreground color provided by Java (SWT), or
- The font rendered by Flutter
In the reported case (use_swt_fonts = true), the size calculation does not match the expected values.
Technical Context
Sizes are calculated in Sizes.java.
For Button and Link, the computeSize() method is auto-generated.
The generation flow is the following:
- Classes to be generated are added in
measure.dart.
- The
GenerateAll task is executed. This generates:
WidgetSizeTest.java
measure_widget.dart
- Other supporting files.
- The following command is executed:
flutter run -d windows -t tool/measure_widget.dart
NOTE: (Replace windows with the corresponding OS.)
This generates the constants used to approximate computeSize(). Although the measurement is performed using Flutter code, additional heuristics are applied to estimate the final size.
- Finally,
widgetSizes.java is generated.
Validation
WidgetSizeTest.java contains the tests that validate whether widgetSizes.java was generated correctly.
These tests:
- Measure the widget in Java
- Measure the widget in Flutter
- Compare both results across different scenarios
Covered scenarios include:
- Minimum size (widget occupies the smallest possible space)
- Respecting bounds
- Bold/italic font cases
flutter_should_equal_java comparison cases
All these tests must pass, as they ensure widgetSizes.java is correctly aligned with both Java and Flutter measurements.
Expected Behavior
- When
use_swt_fonts = true, computeSize() should:
- Correctly reflect Java (SWT) font metrics.
- Pass all
WidgetSizeTest tests.
- Maintain consistency between Java and Flutter measurements in the flutter_should_equal_java scenarios.
Description
When the
use_swt_fontsflag is enabled, the computed sizes (computeSize) of some widgets (e.g.,ButtonandLink) are incorrect.The
use_swt_fontsflag determines whether the widget uses:In the reported case (
use_swt_fonts = true), the size calculation does not match the expected values.Technical Context
Sizes are calculated in
Sizes.java.For
ButtonandLink, thecomputeSize()method is auto-generated.The generation flow is the following:
measure.dart.GenerateAlltask is executed. This generates:WidgetSizeTest.javameasure_widget.dartflutter run -d windows -t tool/measure_widget.dartNOTE: (Replace windows with the corresponding OS.)
This generates the constants used to approximate
computeSize(). Although the measurement is performed using Flutter code, additional heuristics are applied to estimate the final size.widgetSizes.javais generated.Validation
WidgetSizeTest.javacontains the tests that validate whetherwidgetSizes.javawas generated correctly.These tests:
Covered scenarios include:
flutter_should_equal_javacomparison casesAll these tests must pass, as they ensure
widgetSizes.javais correctly aligned with both Java and Flutter measurements.Expected Behavior
use_swt_fonts = true,computeSize()should:WidgetSizeTesttests.