From fcebeeba60f9e92c8b0e02c145420d74bc66229a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 4 Nov 2026 17:32:09 -0600 Subject: [PATCH] [util] Include serialization in hb-subset iterations (#6580) hb-subset serialized only the final face, leaving serialization out of the repeated work measured by --num-iterations. Reference each subset face's blob inside the loop, releasing the previous blob on the next iteration and writing the final blob once. Tested with meson test -C build: 299 passed, 1 skipped. Also checked identical output for one and three iterations with and without preprocessing, plus zero iterations and invalid-font handling. Assisted-by: Codex --- util/hb-subset.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/hb-subset.cc b/util/hb-subset.cc index f2f41fdf4..a626e87c5 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -119,22 +119,22 @@ struct subset_main_t : option_parser_t, face_options_t, output_options_t } hb_face_t *new_face = nullptr; + hb_blob_t *result = nullptr; for (unsigned i = 0; i < num_iterations; i++) { + hb_blob_destroy (result); hb_face_destroy (new_face); new_face = hb_subset_or_fail (orig_face, input); + result = new_face ? hb_face_reference_blob (new_face) : nullptr; } bool success = new_face; if (success) - { - hb_blob_t *result = hb_face_reference_blob (new_face); write_file (output_file, result); - hb_blob_destroy (result); - } else if (hb_face_get_glyph_count (orig_face) == 0) fail (false, "Invalid font file."); + hb_blob_destroy (result); hb_face_destroy (new_face); return success ? 0 : 1;