From a88cb2d14dc2ee4b3336de106a6e52834494911e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 20 Jan 2026 20:01:20 +0530 Subject: [PATCH] Fix horizontal alignment of emoji incorrect becase rendered_width was not being set after switching to using cairo to render them Fixes #9395 --- docs/changelog.rst | 3 +++ kitty/freetype.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index b0e56caf3..9da5dda8c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -197,6 +197,9 @@ Detailed list of changes - Wayland: Remove usage of the wayland color management protocol to inform compositors of the color space used by kitty +- Linux: Fix a regression in 0.40 that caused horizontal alignment for emoji to + be incorrect in some cases (:iss:`9395`) + 0.45.0 [2025-12-24] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/freetype.c b/kitty/freetype.c index 8458722eb..39f7cb045 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -858,6 +858,8 @@ render_glyph_with_cairo(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned g.y = fm.ascent; memset(self->cairo.buf, 0, self->cairo.stride * self->cairo.height); cairo_set_source_rgba(self->cairo.cr, fg.r / 255., fg.g / 255., fg.b / 255., fg.a / 255.); + cairo_text_extents_t extents; + cairo_glyph_extents(self->cairo.cr, &g, 1, &extents); cairo_show_glyphs(self->cairo.cr, &g, 1); cairo_surface_flush(self->cairo.surface); #if 0 @@ -874,6 +876,7 @@ render_glyph_with_cairo(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned ans->rows = height; ans->bitmap_left = (int)bb.x_bearing; ans->bitmap_top = -(int)bb.y_bearing; + ans->right_edge = (int)ceil(extents.x_advance); return true; }