mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibGfx: Ensure capacity for glyph runs in TextLayout
We can reserve the capacity for new glyph runs since we already know the glyph count.
This commit is contained in:
parent
911ea2b379
commit
dd4d7d0939
Notes:
github-actions[bot]
2025-06-13 15:32:24 +00:00
Author: https://github.com/gmta
Commit: dd4d7d0939
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5077
1 changed files with 3 additions and 4 deletions
|
@ -84,9 +84,9 @@ RefPtr<GlyphRun> shape_text(FloatPoint baseline_start, float letter_spacing, Utf
|
|||
auto* positions = hb_buffer_get_glyph_positions(buffer, &glyph_count);
|
||||
|
||||
Vector<Gfx::DrawGlyph> glyph_run;
|
||||
glyph_run.ensure_capacity(glyph_count);
|
||||
FloatPoint point = baseline_start;
|
||||
for (size_t i = 0; i < glyph_count; ++i) {
|
||||
|
||||
auto position = point
|
||||
- FloatPoint { 0, font.pixel_metrics().ascent }
|
||||
+ FloatPoint { positions[i].x_offset, positions[i].y_offset } / text_shaping_resolution;
|
||||
|
@ -98,10 +98,9 @@ RefPtr<GlyphRun> shape_text(FloatPoint baseline_start, float letter_spacing, Utf
|
|||
if (i != (glyph_count - 1))
|
||||
point.translate_by(letter_spacing, 0);
|
||||
}
|
||||
|
||||
auto run = adopt_ref(*new Gfx::GlyphRun(move(glyph_run), font, text_type, point.x() - baseline_start.x()));
|
||||
hb_buffer_reset(buffer);
|
||||
return run;
|
||||
|
||||
return adopt_ref(*new Gfx::GlyphRun(move(glyph_run), font, text_type, point.x() - baseline_start.x()));
|
||||
}
|
||||
|
||||
float measure_text_width(Utf8View const& string, Gfx::Font const& font, ShapeFeatures const& features)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue