-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add colored emoji support for TextInputs #7997
Conversation
…e original color of emojis
Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines. |
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.
Looks promising! I think it creates an issue with binding, see comment, but shouldn't be too hard to check and fix.
@@ -196,7 +196,7 @@ | |||
pos: self._cursor_visual_pos | |||
size: root.cursor_width, -self._cursor_visual_height | |||
Color: | |||
rgba: self.disabled_foreground_color if self.disabled else (self.hint_text_color if not self.text else self.foreground_color) | |||
rgba: (1, 1, 1, 1) |
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.
The previous version had the advantage of automatically adjusting the rendering if any of the xxx_color
properties, or disabled
was updated, the new way means lines have to be rerendered, for it to work. so binding on these properties, probably around line 568, of textinput.py, would be necessary, otherwise these color/disabled changes won't be applied until the text (or some other property that is bound) is actually changed.
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 yes, thanks for the help!
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 look fine to you now @tshirtman?
fbind('foreground_color', refresh_line_options) | ||
fbind('disabled_foreground_color', refresh_line_options) | ||
fbind('hint_text_color', refresh_line_options) |
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.
I recommend binding to update_text_options
, binding to refresh_line_options
will move the cursor to the end of the text.
So you can move this code below, to the line below line 588
fbind('foreground_color', update_text_options)
fbind('disabled_foreground_color', update_text_options)
fbind('hint_text_color', update_text_options)
OP has declared they are not working on Kivy any more. This is an orphan PR that needs fostering. |
Superseded by #8491 |
Description
This PR aims at answering the following issue: #7995
Currently, Labels render colored emojis correctly but not TextInputs. I believe the origin of the problem is that when a TextInput creates Labels to get the textures for each line, it does not do it in the same way as if it were a standard stand-alone Label. More specifically, the Labels are created without a value for the
color
property. As a result, the texture is made of pixels in shades of grey (except for emojis). Later, when the textures are added to the Canvas of the TextInput, they are colored by a Color instruction based on the value of theforeground_color
property of TextInput. That way, the whome texture is made in shades of that given color. This is not a problem for regular text but that does not work for emojis that end being recolored monochromatically.The solution is to treat Labels used in TextInputs like regular Labels by setting a value the
color
property following the same logic that was contained in the Color instruction (the graphic provider will not apply thecolor
to emojis by itself I believe). Then, the Color instruction of the canvas is set to (1, 1, 1, 1) such that the texture's color are not modified.Testing
The tests
test_uix_textinput
are successful and the few tests I've done with the example in the issue work fineMaintainer merge checklist
Component: xxx
label.api-deprecation
orapi-break
label.release-highlight
label to be highlighted in release notes.versionadded
,versionchanged
as needed.