-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Allow custom foreground paint to be used for drawing text #5395
Conversation
lib/ui/text.dart
Outdated
}) : _encoded = _encodeTextStyle( | ||
Paint foreground, | ||
}) : assert(color == null || foreground == null, | ||
'Cannot provide both a color and a foreground\m' |
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.
Shouldn't that be \n
?
This breaks flutter tests here: and at least a few other places in that file because of changes in |
This is great! |
lib/ui/text.dart
Outdated
return result; | ||
} | ||
|
||
/// An opaque object that determines the size, position, and rendering of text. | ||
class TextStyle { | ||
/// Creates a new TextStyle object. | ||
/// | ||
/// * `color`: The color to use when painting the text. | ||
/// * `color`: The color to use when painting the text. If this is specified, `foreground` should be null. |
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.
should -> must
We fix the test when we roll this into the framework. You should get a patch ready for the framework so that you can roll as soon as the engine bots finish building artifacts. |
third_party/txt/src/txt/paragraph.cc
Outdated
if (record.style().has_foreground) { | ||
paint = record.style().foreground; | ||
} else { | ||
paint.setColor(record.style().color); |
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.
Call paint.reset() before paint.setColor() to clear any attributes besides the color that might have been set by a previous style with a foreground paint
@jason-simmons, @Hixie: Can we land this? |
As far as I'm aware, but be careful that this will require framework changes also. (the framework TextStyle needs updating, as well as some tests) |
There's a PR for the framework here: flutter/flutter#17982 which fixes the unit tests and updates the commit hash for Engine (although I believe that will have to be updated once this is actually merged in with the correct merge hash). I'm traveling for the next couple days and won't be able to do much with this myself until Friday or early next week. The framework should get more updates to TextStyle, but I figured it'd be more straightforward to just land this stuff first and then better expose it in the framework in a subsequent PR. |
@chinmaygarde If you don't mind doing the engine roll as well (using flutter/flutter#17982) then please don't hesitate to land this if you need it. Otherwise it's fine to wait until @dnfield is around. |
Hmm. I foolishly did not check to see that the build was clean before merging this. It looks like it's still failing from #5443
|
Use case(s): I want to draw text painted with a gradient, I want to draw stroked text
Today, libtxt specifies its own Paint and just uses the
color
property to fill in a paint color when drawing text. It's not possible to tell it what painting style or shader to use, etc. This enables support for that at the engine level - upstream changes could further enable it in the Flutter SDK.