[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
This commit is contained in:
Behdad Esfahbod authored and GitHub committed 2026-11-04 17:32:09 -06:00
1 parent 2823aad36c
commit fcebeeba60
1 file changed
+4 -4
+4 -4
View File
@@ -119,22 +119,22 @@ struct subset_main_t : option_parser_t, face_options_t, output_options_t<false>
}
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;