summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Painter.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-09-04 14:06:25 +0300
committerAndreas Kling <kling@serenityos.org>2021-09-04 16:13:30 +0200
commit72b21343ad9cfb2f55c7ea533fb3f3ef6d0adbec (patch)
tree445627f10c78dd91fd892ad9ad9a4f59c85fbde9 /Userland/Libraries/LibGfx/Painter.cpp
parent5d732711a210584d5e0c63b7a99b5a9d8b17aede (diff)
downloadserenity-72b21343ad9cfb2f55c7ea533fb3f3ef6d0adbec.zip
LibGfx: Convert line text into a Utf8View before finding its direction
We were accidentally calling TextDirection::get_text_direction with a String instead of a UtfView, which meant each byte was treated as a codepoint, resulting in incorrect identification of text direction.
Diffstat (limited to 'Userland/Libraries/LibGfx/Painter.cpp')
-rw-r--r--Userland/Libraries/LibGfx/Painter.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp
index 1a63448764..039553331c 100644
--- a/Userland/Libraries/LibGfx/Painter.cpp
+++ b/Userland/Libraries/LibGfx/Painter.cpp
@@ -1472,14 +1472,14 @@ void Painter::do_draw_text(IntRect const& rect, Utf8View const& text, Font const
}
for (size_t i = 0; i < lines.size(); ++i) {
- auto& line = lines[i];
+ auto line = Utf8View { lines[i] };
IntRect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
line_rect.intersect(rect);
TextDirection line_direction = get_text_direction(line);
- if (text_contains_bidirectional_text(Utf8View { line }, line_direction)) { // Slow Path: The line contains mixed BiDi classes
- auto directional_runs = split_text_into_directional_runs(Utf8View { line }, line_direction);
+ if (text_contains_bidirectional_text(line, line_direction)) { // Slow Path: The line contains mixed BiDi classes
+ auto directional_runs = split_text_into_directional_runs(line, line_direction);
auto current_dx = line_direction == TextDirection::LTR ? 0 : line_rect.width();
for (auto& directional_run : directional_runs) {
auto run_width = font.width(directional_run.text());
@@ -1492,14 +1492,14 @@ void Painter::do_draw_text(IntRect const& rect, Utf8View const& text, Font const
// compatible with draw_text_line.
StringBuilder builder;
builder.append(directional_run.text());
- auto text = Utf8View { builder.to_string() };
+ auto line_text = Utf8View { builder.to_string() };
- draw_text_line(run_rect, text, font, alignment, directional_run.direction(), draw_glyph);
+ draw_text_line(run_rect, line_text, font, alignment, directional_run.direction(), draw_glyph);
if (line_direction == TextDirection::LTR)
current_dx += run_width;
}
} else {
- draw_text_line(line_rect, Utf8View { line }, font, alignment, line_direction, draw_glyph);
+ draw_text_line(line_rect, line, font, alignment, line_direction, draw_glyph);
}
}
}