Skip to content

[vector_graphics] Use font-family lists as a family with fallbacks - #13552

Merged
auto-submit[bot] merged 4 commits into
flutter:mainfrom
mackings:vg-font-family-fallback
Nov 11, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:mainfrom
mackings:vg-font-family-fallback

Conversation

@mackings

@mackings mackings commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

SVG font-family can be a list like "Roboto, sans-serif", but the whole string was passed to Flutter as one font name, so it never matched and you always got the default font.

Now the list is split. The first name is used as the font and the rest go into fontFamilyFallback. Quotes around names are removed too. A single name works the same as before, and since this is only in the listener, SVGs that were already compiled get the fix as well.

parseFontFamilies is tested directly in listener_test.dart, including the fallback order, so the tests also run on web.

Fixes flutter/flutter#187087

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  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. ↩ ↩2

@github-actions github-actions Bot added p: vector_graphics triage-engine Should be looked at in engine triage labels Nov 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the vector_graphics package to version 1.2.7. It introduces support for parsing a comma-separated font-family list from SVG, extracting the first family name as the primary font family and the remaining names as fallbacks. The _TextConfig class and FlutterVectorGraphicsListener have been updated to handle fontFamilyFallback. Additionally, a new test file font_family_test.dart has been added to verify this behavior. There are no review comments, and I have no feedback to provide.

@gaaclarke
gaaclarke requested a review from b-luk November 9, 2026 19:02
@b-luk b-luk added the CICD Run CI/CD label Nov 10, 2026

@b-luk b-luk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

font_family_test.dart has a few issues:

  • Relying on FLUTTER_ROOT and the test tool caching the fonts is fragile.
  • It uses dart:io and can't be run on Chrome.
  • As you mention in the description, the test does not actually test the fallback font.

What do you think about making parseFontFamilies be @visibleForTesting and testing it in listener_test.dart, and getting rid of font_family_test.dart? That lets us avoid those issues. The downside is that it doesn't test the end-to-end rendered result.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 10, 2026
@mackings

Copy link
Copy Markdown
Contributor Author

Makes sense, thanks! Made parseFontFamilies @visibleForTesting, moved the tests into listener_test.dart and removed font_family_test.dart. The tests now also cover the fallback order and run on Chrome.

@mackings
mackings requested a review from b-luk November 10, 2026 07:29
@b-luk b-luk added the CICD Run CI/CD label Nov 10, 2026
///
/// Flutter takes the first name as the family and the rest as fallbacks.
@visibleForTesting
List<String> parseFontFamilies(String? fontFamily) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a simplified parser which doesn't handle corner cases like commas inside quotes, backslash escapes, and probably other special case scenarios. I think that's okay, because these corner cases should be exceedingly rare and trying to match the full css parsing spec is a rabbit hole I don't think we need to go down. This new behavior is a strict improvement over the current behavior for the common cases, so this LGTM.

nonblocking nit: Maybe add a short one-line comment to note that this isn't a full parser and doesn't handle those corner cases.

# Conflicts:
#	packages/vector_graphics/CHANGELOG.md
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 11, 2026
@mackings

Copy link
Copy Markdown
Contributor Author

Thanks a lot for the review @b-luk! Merged in main to fix a conflict. #13545 took 1.2.7, so this is now 1.2.8.

@b-luk b-luk added the CICD Run CI/CD label Nov 11, 2026
@b-luk
b-luk requested a review from gaaclarke November 11, 2026 18:04

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More conflicts =( I thought we had tooling to handle versioning at least?

# Conflicts:
#	packages/vector_graphics/CHANGELOG.md
#	packages/vector_graphics/pubspec.yaml
#	packages/vector_graphics/test/listener_test.dart
@mackings

Copy link
Copy Markdown
Contributor Author

Sorry about that! Fixed the conflicts with the filters PR, this is now 1.3.1. As far as I can tell vector_graphics isn't set up for batch release yet (no ci_config.yaml), so the version still needs a manual bump. Also added the comment b-luk suggested about the parser not handling every edge case.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 11, 2026
@b-luk b-luk added the CICD Run CI/CD label Nov 11, 2026
@b-luk
b-luk requested a review from gaaclarke November 11, 2026 21:08

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 11, 2026
@auto-submit
auto-submit Bot merged commit 832d5f2 into flutter:main Nov 11, 2026
7 checks passed
b-luk pushed a commit to b-luk/flutter that referenced this pull request Nov 12, 2026
…r#196450)

flutter/packages@653628e...14f9933

2026-11-12 [email protected] [material_ui]
Fix SnackBarThemeData.lerp dropping showCloseIcon
(flutter/packages#13449)
2026-11-11 [email protected] [ci] Update repo
for 3.50 stable release (flutter/packages#13628)
2026-11-11 [email protected] [vector_graphics]
Use font-family lists as a family with fallbacks
(flutter/packages#13552)
2026-11-11 [email protected] Roll Flutter (stable) from
c197ca5 to ab29120 (1647 revisions) (flutter/packages#13625)
2026-11-11 [email protected] [shared_prferences] Adopts
mockito-kotlin in tests (flutter/packages#13624)
2026-11-11 [email protected] [cupertino_ui] Dim disabled
CupertinoSlider controls (flutter/packages#13419)
2026-11-11 [email protected] [flutter_svg] Invalidate pending cache
entries on clear and evict (flutter/packages#13595)
2026-11-11 [email protected] [cupertino_ui] Fix the tinted
button's fill opacity (flutter/packages#13436)
2026-11-11 [email protected] [various]
Support SVG filters (blur, offset, feMerge) (flutter/packages#11909)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: vector_graphics triage-engine Should be looked at in engine triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flutter_svg] Does not support fallback font-famillies

3 participants