-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Animate TextStyle.fontVariations #138881
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
Animate TextStyle.fontVariations #138881
Conversation
|
flutter/packages#5471 should address the flutter_plugins issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"that have discrete values"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, good catch. fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a legitimate use case to allow duplicates? If not I think we should assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to assert on duplicates, that's probably something for the engine side. It would be weird to assert here, since there's nothing about the API today that disallows asserts.
I don't have a strong opinion on whether duplicates should be allowed or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok TextStyle's constructor is const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's probably the reason we went with this design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the spec it looks like currently there're only 5 registered axes. Wouldn't it be faster to use regular element look up in a nested loop (or even sort the 2 lists), than doing the allocations ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocations are very cheap in Dart (it just bumps a pointer on the new generation heap).
I think if we expect this codepath to be used frequently enough that we care about performance, we should probably benchmark the various options, though. I don't know what the optimal path is. (I spent some time trying to figure it out, but nothing obvious came to mind.) In practice, I expect most cases will be either empty on one side and not the other (which has a fast path already), or the same order on both sides (which also has a fast path). There's not much benefit to lerping between two different lists (they would just step-function at t=0.5), and if the lists are the same, then it'd be much better for the values to be sorted by the developer than here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocations are very cheap in Dart (it just bumps a pointer on the new generation heap).
Ah TIL but surely setting up the HashSet/Map isn't going to be as trivial right?
I think if we expect this codepath to be used frequently enough that we care about performance, we should probably benchmark the various options
My question was mostly prompted by the O(N) claim in the documentation and the following paragraphs that describe the performance characteristics, and the fast path in the implementation, all that seem to indicate this is performance critical.
If most common cases take the fast path then sgtm (but I found the use of O(N) here a bit misleading since that shows how well the algorithm scales with a large N but in practice the number of font variations in each list <= 5).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's not trivial (hence the paragraph in the documentation about it). I agree that the constant factors are probably much more important here than the scaling factor. I'll add some more text to that effect to the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have a default value for each axis then? Like the weight defaults to 400 if one side is null? Or the developer should always make sure the axis pairs match if the lerp function is used for an animated transition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fonts have a default value, but we have no way to find out what it is (because, for one, we don't know what font is going to be used, and it could be a different font for each character in the string, due to font fallbacks).
If the developer wants to animate something, they'll specify both ends, in practice.
LongCatIsLooong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok TextStyle's constructor is const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocations are very cheap in Dart (it just bumps a pointer on the new generation heap).
Ah TIL but surely setting up the HashSet/Map isn't going to be as trivial right?
I think if we expect this codepath to be used frequently enough that we care about performance, we should probably benchmark the various options
My question was mostly prompted by the O(N) claim in the documentation and the following paragraphs that describe the performance characteristics, and the fast path in the implementation, all that seem to indicate this is performance critical.
If most common cases take the fast path then sgtm (but I found the use of O(N) here a bit misleading since that shows how well the algorithm scales with a large N but in practice the number of font variations in each list <= 5).
|
auto label is removed for flutter/flutter/138881, due to - The status or check suite Linux framework_tests_misc has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Fixes flutter#105120 I also exposed the relevant dart:ui types which had the effect of removing a large number of dart:ui imports from examples.
Fixes #105120
I also exposed the relevant dart:ui types which had the effect of removing a large number of dart:ui imports from examples.