mirror of https://github.com/aseprite/aseprite.git
Fix caret position when a line has multiple runs (e.g. there's an emoji present)
This commit is contained in:
parent
c1327bf798
commit
73fbf16d31
|
|
@ -829,16 +829,14 @@ void TextEdit::Line::insertText(int pos, const std::string& str)
|
||||||
text.insert(utfSize[pos - 1].end, str);
|
text.insert(utfSize[pos - 1].end, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect TextEdit::Line::getBounds(int glyph) const
|
gfx::Rect TextEdit::Line::getBounds(const int glyph) const
|
||||||
{
|
{
|
||||||
int advance = 0;
|
int advance = 0;
|
||||||
gfx::Rect result;
|
gfx::Rect result;
|
||||||
blob->visitRuns([&](const text::TextBlob::RunInfo& run) {
|
blob->visitRuns([&advance, &result, glyph](const text::TextBlob::RunInfo& run) {
|
||||||
for (int i = 0; i < run.glyphCount; ++i) {
|
for (int i = 0; i < run.glyphCount; ++i) {
|
||||||
if (advance == glyph) {
|
if (advance == glyph)
|
||||||
result = run.getGlyphBounds(i);
|
result = run.getGlyphBounds(i);
|
||||||
return;
|
|
||||||
}
|
|
||||||
++advance;
|
++advance;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue