Unverified Commit ddad6f16 authored by Dennis Kugelmann's avatar Dennis Kugelmann Committed by GitHub

Fix copying/applying font fallback with package (#118393)

* Add test to check that package prefix of font fallback is not duplicated

* Fix duplicate package prefix of font family fallback

* Add test to check that package prefix of font fallback is not duplicated

* Fix duplicate package prefix of font family fallback
parent b8960660
......@@ -897,7 +897,7 @@ class TextStyle with Diagnosticable {
decorationThickness: decorationThickness ?? this.decorationThickness,
debugLabel: newDebugLabel,
fontFamily: fontFamily ?? _fontFamily,
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
fontFamilyFallback: fontFamilyFallback ?? _fontFamilyFallback,
package: package ?? _package,
overflow: overflow ?? this.overflow,
);
......@@ -991,7 +991,7 @@ class TextStyle with Diagnosticable {
color: foreground == null ? color ?? this.color : null,
backgroundColor: background == null ? backgroundColor ?? this.backgroundColor : null,
fontFamily: fontFamily ?? _fontFamily,
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
fontFamilyFallback: fontFamilyFallback ?? _fontFamilyFallback,
fontSize: fontSize == null ? null : fontSize! * fontSizeFactor + fontSizeDelta,
fontWeight: fontWeight == null ? null : FontWeight.values[(fontWeight!.index + fontWeightDelta).clamp(0, FontWeight.values.length - 1)], // ignore_clamp_double_lint
fontStyle: fontStyle ?? this.fontStyle,
......
......@@ -302,6 +302,20 @@ void main() {
const TextStyle s10 = TextStyle(fontFamilyFallback: <String>[], package: 'p');
expect(s10.fontFamilyFallback, <String>[]);
// Ensure that package prefix is not duplicated after copying.
final TextStyle s11 = s8.copyWith();
expect(s11.fontFamilyFallback![0], 'packages/p/test');
expect(s11.fontFamilyFallback![1], 'packages/p/test2');
expect(s11.fontFamilyFallback!.length, 2);
expect(s8, s11);
// Ensure that package prefix is not duplicated after applying.
final TextStyle s12 = s8.apply();
expect(s12.fontFamilyFallback![0], 'packages/p/test');
expect(s12.fontFamilyFallback![1], 'packages/p/test2');
expect(s12.fontFamilyFallback!.length, 2);
expect(s8, s12);
});
test('TextStyle package font merge', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment