mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibTTF+LibGfx: Improve vertical alignment of glyphs
Before this patch, some glyphs had a weird off-by-1 vertical position which looked really jarring at small font sizes. This was caused by glyph bitmaps having different heights from each other. (Each glyph bitmap was minimally sized to fit only the glyph itself, and then vertically positioned during the paint phase. Since this vertical positioning was integer based, subpixel precision was lost and things ended up looking wonky.) Fix this by making all glyph bitmaps be the same height so we can blit them at the same integer y position. We use the typographic ascent from the OS/2 table to transform the glyph coordinates. The end result is a huge improvement visually. :^)
This commit is contained in:
parent
e984200206
commit
9f601fcbcf
4 changed files with 12 additions and 12 deletions
|
@ -1160,7 +1160,7 @@ FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 code_point, Color co
|
|||
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 code_point, const Font& font, Color color)
|
||||
{
|
||||
auto glyph = font.glyph(code_point);
|
||||
auto top_left = point + IntPoint(glyph.left_bearing(), font.glyph_height() - glyph.ascent());
|
||||
auto top_left = point + IntPoint(glyph.left_bearing(), 0);
|
||||
|
||||
if (glyph.is_glyph_bitmap()) {
|
||||
draw_bitmap(top_left, glyph.glyph_bitmap(), color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue