From f7ebd549edd7ff306aa040e1f8cbcd0b1f59de2e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 16 Apr 2026 14:17:10 -0600 Subject: [PATCH] [util/hb-view] --show-extents: foreground color, no per-color split Drop the bespoke red pen dot + magenta extents rectangle in favor of a single foreground-color overlay that matches the look raster, vector, and gpu now produce after their port to the shared helper: stroked rect around each glyph's ink box, plus a filled dot at the pen origin. Cairo's annotation pass stays native (post-glyph drawing through cairo, not via hb_paint funcs); only the colors and the dot rendering changed. Co-Authored-By: Claude Opus 4.6 (1M context) --- util/view-cairo.hh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/util/view-cairo.hh b/util/view-cairo.hh index fd407165a..7766e19b7 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh @@ -108,20 +108,16 @@ view_cairo_t::draw_lines (cairo_t *cr, hb_font_t *font, double leading, int vert { cairo_save (cr); - cairo_set_source_rgba (cr, 1., 0., 0., .5); - cairo_set_line_width (cr, 10); - cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); - for (unsigned i = 0; i < l.num_glyphs; i++) { - cairo_move_to (cr, l.glyphs[i].x, l.glyphs[i].y); - cairo_rel_line_to (cr, 0, 0); - } - cairo_stroke (cr); - - cairo_restore (cr); - cairo_save (cr); - - cairo_set_source_rgba (cr, 1., 0., 1., .5); - cairo_set_line_width (cr, 3); + /* Foreground for parity with the other utils' --show- + * extents overlay (raster, vector, gpu). Stroked rect + * around each glyph's ink box, plus a filled dot at the + * pen origin. */ + cairo_set_source_rgba (cr, + foreground_color.r / 255., + foreground_color.g / 255., + foreground_color.b / 255., + foreground_color.a / 255.); + cairo_set_line_width (cr, 1); for (unsigned i = 0; i < l.num_glyphs; i++) { hb_glyph_extents_t hb_extents; @@ -137,6 +133,13 @@ view_cairo_t::draw_lines (cairo_t *cr, hb_font_t *font, double leading, int vert } cairo_stroke (cr); + /* Filled origin dot. */ + for (unsigned i = 0; i < l.num_glyphs; i++) + { + cairo_arc (cr, l.glyphs[i].x, l.glyphs[i].y, 2., 0., 2 * G_PI); + cairo_fill (cr); + } + cairo_restore (cr); }