mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibGfx: Implement font kerning for Painter::draw_text_run
This commit is contained in:
parent
ae2ec45e78
commit
ee9a2e0715
Notes:
sideshowbarker
2024-07-17 16:42:19 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/ee9a2e0715 Pull-request: https://github.com/SerenityOS/serenity/pull/13401
1 changed files with 6 additions and 3 deletions
|
@ -2322,14 +2322,17 @@ void Painter::draw_text_run(FloatPoint const& baseline_start, Utf8View const& st
|
|||
int y = baseline_start.y() - pixel_metrics.ascent;
|
||||
float space_width = font.glyph_or_emoji_width(' ');
|
||||
|
||||
u32 last_code_point = 0;
|
||||
for (auto code_point : string) {
|
||||
if (code_point == ' ') {
|
||||
x += space_width;
|
||||
last_code_point = code_point;
|
||||
continue;
|
||||
}
|
||||
float advance = font.glyph_or_emoji_width(code_point) + font.glyph_spacing();
|
||||
draw_glyph_or_emoji({ (int)roundf(x), y }, code_point, font, color);
|
||||
x += advance;
|
||||
x += font.glyphs_horizontal_kerning(last_code_point, code_point);
|
||||
draw_glyph_or_emoji({ static_cast<int>(lroundf(x)), y }, code_point, font, color);
|
||||
x += font.glyph_or_emoji_width(code_point) + font.glyph_spacing();
|
||||
last_code_point = code_point;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue