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

Commit ddad6f1

Browse files
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
1 parent b896066 commit ddad6f1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/flutter/lib/src/painting/text_style.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ class TextStyle with Diagnosticable {
897897
decorationThickness: decorationThickness ?? this.decorationThickness,
898898
debugLabel: newDebugLabel,
899899
fontFamily: fontFamily ?? _fontFamily,
900-
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
900+
fontFamilyFallback: fontFamilyFallback ?? _fontFamilyFallback,
901901
package: package ?? _package,
902902
overflow: overflow ?? this.overflow,
903903
);
@@ -991,7 +991,7 @@ class TextStyle with Diagnosticable {
991991
color: foreground == null ? color ?? this.color : null,
992992
backgroundColor: background == null ? backgroundColor ?? this.backgroundColor : null,
993993
fontFamily: fontFamily ?? _fontFamily,
994-
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
994+
fontFamilyFallback: fontFamilyFallback ?? _fontFamilyFallback,
995995
fontSize: fontSize == null ? null : fontSize! * fontSizeFactor + fontSizeDelta,
996996
fontWeight: fontWeight == null ? null : FontWeight.values[(fontWeight!.index + fontWeightDelta).clamp(0, FontWeight.values.length - 1)], // ignore_clamp_double_lint
997997
fontStyle: fontStyle ?? this.fontStyle,

packages/flutter/test/painting/text_style_test.dart

+14
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ void main() {
302302

303303
const TextStyle s10 = TextStyle(fontFamilyFallback: <String>[], package: 'p');
304304
expect(s10.fontFamilyFallback, <String>[]);
305+
306+
// Ensure that package prefix is not duplicated after copying.
307+
final TextStyle s11 = s8.copyWith();
308+
expect(s11.fontFamilyFallback![0], 'packages/p/test');
309+
expect(s11.fontFamilyFallback![1], 'packages/p/test2');
310+
expect(s11.fontFamilyFallback!.length, 2);
311+
expect(s8, s11);
312+
313+
// Ensure that package prefix is not duplicated after applying.
314+
final TextStyle s12 = s8.apply();
315+
expect(s12.fontFamilyFallback![0], 'packages/p/test');
316+
expect(s12.fontFamilyFallback![1], 'packages/p/test2');
317+
expect(s12.fontFamilyFallback!.length, 2);
318+
expect(s8, s12);
305319
});
306320

307321
test('TextStyle package font merge', () {

0 commit comments

Comments
 (0)