This commit addresses multiple code review comments: 1. Switch RNG to std::mt19937 for deterministic tests - Replace std::rand/srand with std::mt19937 in parity checker - Use std::uniform_int_distribution for all random number generation - Ensures test determinism across platforms for non-error-injection tests 2. Convert debug fprintf to DEBUG_MSG_LEVEL - Convert GSUB lookup processing prints to DEBUG_MSG_LEVEL(DEPEND, nullptr, 1, 0, ...) - Visible at HB_DEBUG_DEPEND=2 or higher for detailed per-lookup debugging 3. Rename function for consistency - hb_depend_from_face → hb_depend_from_face_or_fail - Follows HarfBuzz convention for functions returning nullptr on failure - Update all call sites, documentation, and code comments 4. Adopt established set deduplication pattern - Change from hb_vector_t<hb_set_t> to hb_vector_t<hb::unique_ptr<hb_set_t>> - Use pointer-based hashmap: hb_hashmap_t<const hb_set_t*, hb_codepoint_t> - Leverages hb_hash's content-based deduplication via pointer dereferencing - Follows pattern established elsewhere in HarfBuzz codebase 5. Separate ligature and context set semantics - Rename free_set → free_ligature_set (no hashmap manipulation) - Rename new_set → new_ligature_set (no hashmap manipulation) - Rename find_or_create_set → find_or_create_context_set (only function using hashmap) - Makes it explicit which sets are deduplicated (context) vs unique (ligature) - Update all call sites in Ligature.hh, ReverseChainSingleSubstFormat1.hh, hb-ot-layout-gsubgpos.hh 6. Code cleanup - Remove unused add_to_ligature_set function (dead code) - Refactor new_ligature_set(cp) to delegate to new_ligature_set(set) - Move set_to_index declaration near sets/free_set_list for better organization All tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Security Fuzzers
To build the fuzzers with libFuzzer to perform actual fuzzing, build with:
CXX=clang++ CXXFLAGS="-fsanitize=address,fuzzer-no-link" meson fuzzbuild --default-library=static -Dfuzzer_ldflags="-fsanitize=address,fuzzer"
ninja -Cfuzzbuild
Then, run the fuzzer like this:
fuzzbuild/test/fuzzing/hb-{shape,raster,vector,subset,repacker,depend}-fuzzer [-max_len=2048] [CORPUS_DIR]
Where max_len specifies the maximal length of font files to handle. The smaller the faster.
Note: The depend fuzzer requires -Ddepend_api=true meson option.
For more details consult the following locations:
Depend Closure Parity Test
The hb-depend-closure-parity test is distinct from the security fuzzers.
While security fuzzers test robustness against malformed input, the closure
parity test validates correctness by emulating the glyph closure calculation
used for subsetting with one generated from the dependency graph to avoid
implementation divergence. It should only be run on valid fonts.