mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/Painting: Place text cursor using GlyphRun font
This makes the cursor appear in the correct place when the text makes use of multiple different fonts.
This commit is contained in:
committed by
Alexander Kalenik
parent
3782975718
commit
00302b5b1e
@@ -570,8 +570,9 @@ void paint_cursor_if_needed(PaintContext& context, TextPaintable const& paintabl
|
||||
auto fragment_rect = fragment.absolute_rect();
|
||||
|
||||
auto text = fragment.string_view();
|
||||
auto const& font = fragment.glyph_run() ? fragment.glyph_run()->font() : fragment.layout_node().first_available_font();
|
||||
CSSPixelRect cursor_rect {
|
||||
fragment_rect.x() + CSSPixels::nearest_value_for(paintable.layout_node().first_available_font().width(text.substring_view(0, document.cursor_position()->offset() - fragment.start()))),
|
||||
fragment_rect.x() + CSSPixels::nearest_value_for(font.width(text.substring_view(0, document.cursor_position()->offset() - fragment.start()))),
|
||||
fragment_rect.top(),
|
||||
1,
|
||||
fragment_rect.height()
|
||||
|
||||
Reference in New Issue
Block a user