-
Notifications
You must be signed in to change notification settings - Fork 82
Allow drawing the selected text background earlier #163
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 drawing the selected text background earlier #163
Conversation
f374506 to
6db938c
Compare
dacap
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.
I didn't test this yet, so here are some minor changes.
The DrawTextDelegate is deprecated and we'd like to remove it in the future, but it's still used in ui::Entry so it's fine to fix bugs on it 👍
6db938c to
08332c8
Compare
dacap
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.
A minor change, I've tested on Linux and macOS with "Apple Chancery" and it works great 👍
text/draw_text_shaper.cpp
Outdated
| std::vector<gfx::RectF> glyphsBounds; | ||
| for (int i = 0; i < info.glyphCount; ++i) { | ||
| auto bounds = info.getGlyphBounds(i); | ||
| glyphsBounds.push_back(bounds); |
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.
We can prealloc the expected size of glyphsBounds:
| std::vector<gfx::RectF> glyphsBounds; | |
| for (int i = 0; i < info.glyphCount; ++i) { | |
| auto bounds = info.getGlyphBounds(i); | |
| glyphsBounds.push_back(bounds); | |
| std::vector<gfx::RectF> glyphsBounds(info.glyphCount); | |
| for (int i = 0; i < info.glyphCount; ++i) { | |
| auto bounds = info.getGlyphBounds(i); | |
| glyphsBounds[i] = bounds; |
08332c8 to
822afab
Compare
Add new methods to DrawTextDelegate to allow drawing the background of the selected text before drawing each character. This fixes an issue when the glyphs used by a TTF were overlapped.
822afab to
866cf6e
Compare
This PR modifies the order in which some things are done when each run of text is processed when the shaping function is executed:
Both of the above things are possible because now we first calculate the union of all glyphs bounds.