[Fonts] Improve update_icons script#76532
Conversation
|
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. |
Introduce fullFlutterId and fix a small dartdoc bug
| int compareTo(_Icon b) { | ||
| // Sort regular icons before their variants. | ||
| if (flutterId == b.flutterId && style == IconStyle.regular) | ||
| return -1; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I should clarify that this only sorts for a particular icon, of which there can be at most 3 variants + 1 regular.
| if (flutterId == b.flutterId && style == IconStyle.regular) | ||
| return -1; | ||
| return flutterId.compareTo(b.flutterId); | ||
| } |
There was a problem hiding this comment.
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.
| } else if (id.endsWith('_sharp')) { | ||
| style = IconStyle.sharp; | ||
| shortId = id.replaceAll('_sharp', ''); | ||
| shortId = id.replaceFirst('_sharp', ''); |
There was a problem hiding this comment.
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?
| @@ -352,65 +362,57 @@ class _Icon { | |||
|
|
|||
| if (id.endsWith('_outlined') && id!='insert_chart_outlined') { | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
There was a problem hiding this comment.
Is there a difference between "insert_chart_outlined e248" and "insert_chart_outlined_outlined e249"?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Is there a difference between "insert_chart_outlined e248" and "insert_chart_outlined_outlined e249"?
Not that I can tell
There was a problem hiding this comment.
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
- Dartdoc
style.htmlSuffix - Determining the
shortId(e.g. 5g) Determining theI simplified and removed this.fullFlutterId(five_g, five_g_outlined, five_g_rounded, five_g_sharp)
So, cleaner still to figure out the style in the constructor.
There was a problem hiding this comment.
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

insert_chart_outlined_outlinedused the wrong iconNo-ops to
icons.dart:part of go/effortless-flutter-font-updates
Followup in #76691