Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for fill, weight, grade, and optical size to Icon #106896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jul 20, 2022
Merged

Add support for fill, weight, grade, and optical size to Icon #106896

merged 18 commits into from
Jul 20, 2022

Conversation

guidezpl
Copy link
Member

@guidezpl guidezpl commented Jun 30, 2022

This PR adds framework support required for Material Symbols (design doc, #102560).

Add 4 members to Icon: fill, weight, grade, and opticalSize. Under the hood, pass these to the engine using the FontVariation API. No guarantees are provided:

  • If used with a font which does not support these axes => no effect
  • No bounds checking for values against the font ⇒ no effect outside variable font's supported range

Add 4 corresponding members to IconThemeData to customize all icons in a given widget subtree.

Also:

  • debugFillProperties is completed
  • properties are reordered for consistency
  • documentation is improved

Tests

  • Basic bounds checking
  • Instantiation
  • Fallbacks

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 30, 2022
@guidezpl guidezpl changed the title Material Symbols support Add support for fill, weight, grade, and optical size to Icon Jun 30, 2022
@flutter-dashboard flutter-dashboard bot added the f: cupertino flutter/packages/flutter/cupertino repository label Jul 11, 2022
@guidezpl guidezpl marked this pull request as ready for review July 11, 2022 13:41
///
/// Defaults to the current [IconTheme] color, if any.
/// Requires the underlying icon font to support the `FILL` [FontVariation]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a little bit confusing because the developer may not know anything about the default icon font. Can we help them out a little? Here and elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Answered elsewhere. I can point out that font file names often include the supported axes

/// The color (whether specified explicitly here or obtained from the
/// [IconTheme]) will be further adjusted by the opacity of the current
/// [IconTheme], if any.
/// Can be used to convey a state transition for animation or interaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what this means. We support animating an icon's fill property?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Material Symbols does it starting from the middle, going in/out a square shape.

/// Grade and [weight] both affect a symbol's stroke weight (thickness), but
/// grade has a smaller impact on the size of the symbol.
///
/// Grade is also available in some text fonts. One can match grade levels
Copy link
Contributor

Choose a reason for hiding this comment

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

How does one know if a font supports grade? Similarly, can we make any guarantees about the default text styles (the default Material TextTheme?)

Making sense of this seems particularly difficult for someone who's just reading this bit of API doc. Maybe we could include a link to something that covers the topic in depth?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a convention Google Fonts uses to put the axes in the font file name, it's not obligatory but can help, e.g. MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf. I can't find any docs about it right now.

No guarantees for text yet since this PR concerns only icons. Roboto ⇒ Roboto flex is something to do in the future.

Copy link

Choose a reason for hiding this comment

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

@guidezpl guidezpl requested a review from HansMuller July 15, 2022 22:00
Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

Looks good. Just a question and request for defaults to be documented.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

LGTM. Thx.

@guidezpl guidezpl merged commit be3802c into flutter:master Jul 20, 2022
@guidezpl guidezpl deleted the material-symbols-support branch July 20, 2022 01:27
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jul 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 23, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 23, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2022
camsim99 pushed a commit to camsim99/flutter that referenced this pull request Aug 10, 2022
…ter#106896)

* wip

* update documentation

* x

* remove trailing spaces

* x

* remove useless CupertinoIconThemeData copyWith override

* add tests

* remove trailing spaces

* fix isConcrete

* x

* x

* x

* remove trailing spaces

* tweak docs

* mention that font filenames often indicate the supported axes

* add back cupertino IconThemeData copyWith

* update copyWith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants