Repository navigation
Commit d01e5bc
authored
[material_ui] Add fontFeatures and fontVariations to TextTheme.apply() (flutter#12879)
## Description
This PR ports flutter#192730 to flutter/packages.
Adds `List<FontFeature>?` and `List<FontVariation>?` parameters to `TextTheme.apply()`, passing them through to each `TextStyle.apply()` call. This allows developers to apply font features and variations consistently across an entire text theme without modifying each `TextStyle` individually.
## Related Issue
Fixes flutter#192692
Ports flutter#192730
## Proposed Change
- Added `List<FontFeature>?` and `List<FontVariation>?` parameters to `TextTheme.apply()`
- Both default to `null`, preserving backward compatibility
- Each of the 15 `TextStyle.apply()` calls within `TextTheme.apply()` now passes these parameters through
## Technical Details
The `TextStyle` class already supports `fontFeatures` and `fontVariations` in its own `apply()` method. The `TextTheme.apply()` method was missing the ability to pass these through. This is a purely additive change - no existing behavior is modified.
### Use Case: Persian Digits
```dart
final theme = Theme.of(context).textTheme.apply(
fontFeatures: const [FontFeature("ss01")],
);
```
### Use Case: Variable Font Grade
```dart
final theme = Theme.of(context).textTheme.apply(
fontVariations: const [FontVariation('GRAD', 40.0)],
);
```
## Testing
Added 2 new tests to text_theme_test.dart:
1. `TextTheme apply fontFeatures fontVariations` - verifies all 15 styles receive the parameters
2. `TextTheme apply null fontFeatures fontVariations preserves original` - verifies null defaults don't overwrite existing values (fixes incomplete test from original PR)
All 18 tests pass (including existing tests).
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
## Note
This PR ports the original flutter/flutter PR flutter#192730. The original PR should be closed with a reference to this new PR.
The original PR had a test that claimed to verify both `fontFeatures` and `fontVariations` preservation, but only checked `fontFeatures`. This has been fixed in this ported version to properly verify both properties.1 parent 04c946c commit d01e5bc
3 files changed
Lines changed: 85 additions & 0 deletions
File tree
- packages/material_ui
- lib/src
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| |||
433 | 435 | | |
434 | 436 | | |
435 | 437 | | |
| 438 | + | |
| 439 | + | |
436 | 440 | | |
437 | 441 | | |
438 | 442 | | |
| |||
450 | 454 | | |
451 | 455 | | |
452 | 456 | | |
| 457 | + | |
| 458 | + | |
453 | 459 | | |
454 | 460 | | |
455 | 461 | | |
| |||
467 | 473 | | |
468 | 474 | | |
469 | 475 | | |
| 476 | + | |
| 477 | + | |
470 | 478 | | |
471 | 479 | | |
472 | 480 | | |
| |||
484 | 492 | | |
485 | 493 | | |
486 | 494 | | |
| 495 | + | |
| 496 | + | |
487 | 497 | | |
488 | 498 | | |
489 | 499 | | |
| |||
501 | 511 | | |
502 | 512 | | |
503 | 513 | | |
| 514 | + | |
| 515 | + | |
504 | 516 | | |
505 | 517 | | |
506 | 518 | | |
| |||
518 | 530 | | |
519 | 531 | | |
520 | 532 | | |
| 533 | + | |
| 534 | + | |
521 | 535 | | |
522 | 536 | | |
523 | 537 | | |
| |||
535 | 549 | | |
536 | 550 | | |
537 | 551 | | |
| 552 | + | |
| 553 | + | |
538 | 554 | | |
539 | 555 | | |
540 | 556 | | |
| |||
552 | 568 | | |
553 | 569 | | |
554 | 570 | | |
| 571 | + | |
| 572 | + | |
555 | 573 | | |
556 | 574 | | |
557 | 575 | | |
| |||
569 | 587 | | |
570 | 588 | | |
571 | 589 | | |
| 590 | + | |
| 591 | + | |
572 | 592 | | |
573 | 593 | | |
574 | 594 | | |
| |||
586 | 606 | | |
587 | 607 | | |
588 | 608 | | |
| 609 | + | |
| 610 | + | |
589 | 611 | | |
590 | 612 | | |
591 | 613 | | |
| |||
603 | 625 | | |
604 | 626 | | |
605 | 627 | | |
| 628 | + | |
| 629 | + | |
606 | 630 | | |
607 | 631 | | |
608 | 632 | | |
| |||
620 | 644 | | |
621 | 645 | | |
622 | 646 | | |
| 647 | + | |
| 648 | + | |
623 | 649 | | |
624 | 650 | | |
625 | 651 | | |
| |||
637 | 663 | | |
638 | 664 | | |
639 | 665 | | |
| 666 | + | |
| 667 | + | |
640 | 668 | | |
641 | 669 | | |
642 | 670 | | |
| |||
654 | 682 | | |
655 | 683 | | |
656 | 684 | | |
| 685 | + | |
| 686 | + | |
657 | 687 | | |
658 | 688 | | |
659 | 689 | | |
| |||
671 | 701 | | |
672 | 702 | | |
673 | 703 | | |
| 704 | + | |
| 705 | + | |
674 | 706 | | |
675 | 707 | | |
676 | 708 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
152 | 202 | | |
153 | 203 | | |
154 | 204 | | |
| |||
0 commit comments