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

Skip to content

[Fonts] Improve update_icons script#76532

Merged
guidezpl merged 25 commits into
flutter:masterfrom
guidezpl:update-fonts
Mar 9, 2021
Merged

[Fonts] Improve update_icons script#76532
guidezpl merged 25 commits into
flutter:masterfrom
guidezpl:update-fonts

Conversation

@guidezpl

@guidezpl guidezpl commented Feb 22, 2021

Copy link
Copy Markdown
Member
  • Fix a bug where the dartdoc for insert_chart_outlined_outlined used the wrong icon

No-ops to icons.dart:

  • Copy new codepoints instead of moving it
  • Print useful info when new codepoints is a subset of the existing codepoints
  • Merge and simplifies identifier rewrites from g3
  • Refactoring to remove icon style from intermediate data model
  • Reordering properties

part of go/effortless-flutter-font-updates

Followup in #76691

@flutter-dashboard flutter-dashboard Bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Feb 22, 2021
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla Bot added the cla: yes label Feb 22, 2021
@guidezpl guidezpl changed the title [Fonts] [Fonts] Improve update_icons script Feb 22, 2021
@flutter-dashboard flutter-dashboard Bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Feb 22, 2021

@willlarche willlarche 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.

LGTM

@guidezpl guidezpl requested a review from xster February 22, 2021 17:55
@guidezpl guidezpl requested a review from Hixie February 23, 2021 15:57
Comment thread dev/tools/update_icons.dart
Comment thread dev/tools/update_icons.dart Outdated
Comment thread dev/tools/update_icons.dart Outdated
int compareTo(_Icon b) {
// Sort regular icons before their variants.
if (flutterId == b.flutterId && style == IconStyle.regular)
return -1;

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.

that doesn't seem right. What if the other one's style is IconStyle.regular and ours isn't? or what if they both are?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I should clarify that this only sorts for a particular icon, of which there can be at most 3 variants + 1 regular.

Comment thread dev/tools/update_icons.dart Outdated
if (flutterId == b.flutterId && style == IconStyle.regular)
return -1;
return flutterId.compareTo(b.flutterId);
}

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.

would it be possible to change the ordering in a separate PR? That way reviewing the PR would be much easier since we could be sure that we were only seeing reorders or only seeing new icons, not a combination.

@guidezpl guidezpl Feb 24, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sure! #76691

@guidezpl guidezpl requested a review from Hixie February 25, 2021 07:44
Comment thread dev/tools/update_icons.dart Outdated
} else if (id.endsWith('_sharp')) {
style = IconStyle.sharp;
shortId = id.replaceAll('_sharp', '');
shortId = id.replaceFirst('_sharp', '');

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.

The "replaceFirst" change is an improvement for sure, but it would still get it wrong e.g. if we have something like "foo_outlined_bar_outlined". Can we just do a substring so that we are definitely stripping the end?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@@ -352,65 +362,57 @@ class _Icon {

if (id.endsWith('_outlined') && id!='insert_chart_outlined') {

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.

I'm really confused about the insert_chart icons. The complete list today seems to be:

insert_chart e7dc
insert_chart_outlined e248
insert_chart_outlined_outlined e249
insert_chart_outlined_rounded f278
insert_chart_outlined_sharp ed4a
insert_chart_rounded f279
insert_chart_sharp ed4b

Are those two sets of icons? One set of icons with many variants? Seven icons?

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.

It looks like all of this is actually only done so that we can do the ios/android specialization. Maybe there's a better way to do this that allows us to totally ignore the icon type? Just look for icons that startsWith() the icon types we want to specialise?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, it's two sets insert_chart + 3 variants (top), and insert_chart_outlined + 2 variants (bottom).

Screenshot 2021-02-26 at 09 06 00

I think it's still needed, at the very least, for the css class to display the correct icon in dartdoc. Otherwise, yeah doing this in a style agnostic way would be simpler

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.

Is there a difference between "insert_chart_outlined e248" and "insert_chart_outlined_outlined e249"?

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.

Can we maybe just have the bit where we decide how to style it for CSS look to see if there's a trailing suffix and apply the style appropriately there, rather than actually tracking the style across the whole data model and so on? Seems like this would save us a lot of code and get rid of the bug we're dealing with here at the same time.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is there a difference between "insert_chart_outlined e248" and "insert_chart_outlined_outlined e249"?

Not that I can tell

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I get what you're saying but I think you end up with messier code because there are 3 2 places that depends on the style-related logic

  1. Dartdoc style.htmlSuffix
  2. Determining the shortId (e.g. 5g)
  3. Determining thefullFlutterId (five_g, five_g_outlined, five_g_rounded, five_g_sharp) I simplified and removed this.

So, cleaner still to figure out the style in the constructor.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As I reread this I realized I was wrong and could simplify again :) I reordered _Icon to make it more readable. Lmk if this LGTY

Comment thread dev/tools/update_icons.dart
@guidezpl guidezpl requested a review from Hixie February 27, 2021 09:32

@Hixie Hixie 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.

LGTM

@guidezpl guidezpl merged commit 698d438 into flutter:master Mar 9, 2021
@guidezpl guidezpl deleted the update-fonts branch March 9, 2021 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants