mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
LibGfx: Enable subpixel accurate text rendering in Painter::draw_text()
This improves kerning and alignment jittering quite a bit :^)
This commit is contained in:
parent
ada48a1daf
commit
6632023498
1 changed files with 4 additions and 3 deletions
|
@ -1382,13 +1382,14 @@ FLATTEN void Painter::draw_glyph(FloatPoint point, u32 code_point, Color color)
|
|||
|
||||
FLATTEN void Painter::draw_glyph(FloatPoint point, u32 code_point, Font const& font, Color color)
|
||||
{
|
||||
auto glyph = font.glyph(code_point);
|
||||
auto top_left = point + IntPoint(glyph.left_bearing(), 0);
|
||||
auto top_left = point + FloatPoint(font.glyph_left_bearing(code_point), 0);
|
||||
auto glyph_position = Gfx::GlyphRasterPosition::get_nearest_fit_for(top_left);
|
||||
auto glyph = font.glyph(code_point, glyph_position.subpixel_offset);
|
||||
|
||||
if (glyph.is_glyph_bitmap()) {
|
||||
draw_bitmap(top_left.to_type<int>(), glyph.glyph_bitmap(), color);
|
||||
} else {
|
||||
blit_filtered(top_left.to_type<int>(), *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color {
|
||||
blit_filtered(glyph_position.blit_position, *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color {
|
||||
return pixel.multiply(color);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue