From cb53f4b5aa145ccd8965faa4b5fb3cbf48120853 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 23 May 2025 17:52:57 +0000 Subject: [PATCH] [instancer] fix tsb calculation for CFF2 fonts. tsb was being set equal to the y max of each glyph, which is not correct. Instead calculate tsb as vorg.y - ymax. --- src/hb-subset-plan-var.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hb-subset-plan-var.cc b/src/hb-subset-plan-var.cc index c917d8af2..525ff473d 100644 --- a/src/hb-subset-plan-var.cc +++ b/src/hb-subset-plan-var.cc @@ -292,13 +292,18 @@ update_instance_metrics_map_from_cff2 (hb_subset_plan_t *plan) if (_vmtx.var_table.get_length ()) vert_aw += (int) roundf (_vmtx.var_table->get_advance_delta_unscaled (old_gid, font->coords, font->num_coords, vvar_store_cache)); - - int tsb = extents.y_bearing; - if (!has_bounds_info) + hb_position_t vorg_x = 0; + hb_position_t vorg_y = 0; + int tsb = 0; + if (has_bounds_info && + hb_font_get_glyph_v_origin (font, old_gid, &vorg_x, &vorg_y)) { + tsb = vorg_y - extents.y_bearing; + } else { if (!_vmtx.get_leading_bearing_without_var_unscaled (old_gid, &tsb)) continue; } + plan->vmtx_map.set (new_gid, hb_pair ((unsigned) vert_aw, tsb)); plan->bounds_height_vec[new_gid] = extents.height; }