mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +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:
parent
3782975718
commit
00302b5b1e
Notes:
github-actions[bot]
2024-12-06 01:58:28 +00:00
Author: https://github.com/AtkinsSJ
Commit: 00302b5b1e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2796
1 changed files with 2 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue