mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb: Strip tabs before text shaping
Handling tabs during text shaping caused issues because we tried to index 'input_glyph_info' whilst iterating until 'glyph_count' and these can be different sizes. The difference is due to when one or more characters get merged into the same glyph when calling 'input_glyph_info' (see https://lazka.github.io/pgi-docs/HarfBuzz-0.0/classes/glyph_info_t.html). We don't want to render tabs as they come up as tofu characters so instead let's strip them out of the text chunk before starting text shaping.
This commit is contained in:
parent
77850b3540
commit
2534e7aeff
Notes:
github-actions[bot]
2024-10-22 19:43:50 +00:00
Author: https://github.com/kostyafarber Commit: https://github.com/LadybirdBrowser/ladybird/commit/2534e7aeff5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1912 Reviewed-by: https://github.com/kalenikaliaksandr
2 changed files with 2 additions and 2 deletions
|
@ -32,8 +32,6 @@ RefPtr<GlyphRun> shape_text(FloatPoint baseline_start, Utf8View string, Gfx::Fon
|
|||
Vector<Gfx::DrawGlyph> glyph_run;
|
||||
FloatPoint point = baseline_start;
|
||||
for (size_t i = 0; i < glyph_count; ++i) {
|
||||
if (input_glyph_info[i].codepoint == '\t')
|
||||
continue;
|
||||
|
||||
auto position = point
|
||||
- FloatPoint { 0, font.pixel_metrics().ascent }
|
||||
|
|
|
@ -285,6 +285,8 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next_without_lookahead(
|
|||
}
|
||||
tab_stop_dist = tab_stop_dist * num_of_tabs;
|
||||
|
||||
// remove tabs, we don't want to render them when we shape the text
|
||||
chunk.view = chunk.view.substring_view(num_of_tabs);
|
||||
x = tab_stop_dist.to_float();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue