[hb-subset] Speed up parsing glyphs-file
Some checks failed
arm / arm-none-eabi (push) Waiting to run
configs-ci / build (push) Waiting to run
fontations / build (push) Waiting to run
linux-ci / build (push) Waiting to run
macos-ci / build (push) Waiting to run
msvc / msvc-2019-amd64 (push) Waiting to run
msvc / msvc-2019-x86 (push) Waiting to run
msys2 / CLANG64 (push) Waiting to run
msys2 / MINGW32 (push) Waiting to run
msys2 / MINGW64 (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Failing after 1s

Cache the font used to load glyph names.
This commit is contained in:
Behdad Esfahbod 2025-04-05 15:26:07 -06:00
parent 0fecd2ecc3
commit 54295ccf45

View file

@ -50,6 +50,7 @@ struct subset_main_t : option_parser_t, face_options_t, output_options_t<false>
{}
~subset_main_t ()
{
hb_font_destroy (font);
hb_subset_input_destroy (input);
}
@ -166,6 +167,7 @@ struct subset_main_t : option_parser_t, face_options_t, output_options_t<false>
unsigned num_iterations = 1;
gboolean preprocess = false;
hb_subset_input_t *input = nullptr;
hb_font_t *font = nullptr;
};
static gboolean
@ -274,7 +276,10 @@ parse_glyphs (const char *name,
const char *p = arg;
const char *p_end = arg + strlen (arg);
hb_font_t *font = hb_font_create (subset_main->face);
if (!subset_main->font)
subset_main->font = hb_font_create (subset_main->face);
hb_font_t *font = subset_main->font;
while (p < p_end)
{
while (p < p_end && (*p == ' ' || *p == ','))