mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 10:55:07 +00:00
GTextEditor: Allow setting a custom font for each span
This commit is contained in:
parent
5e5a7fbd40
commit
59107a7cfe
2 changed files with 5 additions and 1 deletions
|
@ -371,6 +371,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
int advance = font().glyph_width(' ') + font().glyph_spacing();
|
||||
Rect character_rect = { visual_line_rect.location(), { font().glyph_width(' '), line_height() } };
|
||||
for (int i = 0; i < visual_line_text.length(); ++i) {
|
||||
const Font* font = &this->font();
|
||||
Color color;
|
||||
int physical_line = line_index;
|
||||
int physical_column = start_of_visual_line + i;
|
||||
|
@ -379,9 +380,11 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
if (!span.contains(GTextPosition(physical_line, physical_column)))
|
||||
continue;
|
||||
color = span.color;
|
||||
if (span.font)
|
||||
font = span.font;
|
||||
break;
|
||||
}
|
||||
painter.draw_text(character_rect, visual_line_text.substring_view(i, 1), m_text_alignment, color);
|
||||
painter.draw_text(character_rect, visual_line_text.substring_view(i, 1), *font, m_text_alignment, color);
|
||||
character_rect.move_by(advance, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue