feat: Support text align on new text rendering pipeline #3147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Support text align on new text rendering pipeline.
Notes
I am re-using Flutter's
TextAlign
enum for simplicity; however, it has extra constants we don't quite need. It hasstart
andend
that for us are synonyms ofleft
andright
because the text rendering pipeline does not support rtl text directions. It also hasjustify
which this PR does not support as it is much more involved (though we could support later).The other options were to either make a new enum, use a double from 0 to 1, or use the anchor class (but only take the horizontal component - vertically it doesn't make sense as it is always exactly line height). Of those options, I believe re-using the enum is cleaner.
That being said, this does touch on a crucial point that I am noticing: it seems we are rebuilding a lot of what Flutter already gives us for free. There is a whole
TextPainter
based rendering pipeline available in Flutter is decomposed from flutter components and could be leverage more directly leverage by Flame. It includes layouting, line breaking, text metrics, handles rtl text, etc etc. I have some doubts about our current structure, even though it was vastly simplified with this series of PRs, we still have two minorly overlapping systems that both also have varying degrees of overlap with inherited Flutter abstractions, with often less powerful features.Results
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?