reinterpret_cast<const instructions_t &>(data) reads the bytes of the
pointer variable itself (stack address, determined by ASLR), not the
fuzzer input buffer. This makes operation and first_set_size effectively
uncontrollable by the fuzzer.
Fix by dereferencing: reinterpret_cast<const instructions_t &>(*data)
This also removes the #pragma suppressing -Wstrict-aliasing, which was
warning about exactly this problem.
Coverage comparison (10-min libFuzzer run):
- Original: 15 lines (0.05%), 2 functions
- Fixed: 486 lines (1.47%), 144 functions (29x improvement)
Remove hb_raster_extents_from_glyph_extents and switch callers to the new transform-aware set_glyph_extents APIs on raster draw/paint. Also add test coverage for transformed glyph extents and update section symbol listings.
Move perf tools from perf/ and test/raster/ to util/ alongside the
other uninstalled utilities. Remove the now-empty test/raster/ directory.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add API to recycle a rendered image back to the rasterizer. The draw
object keeps the image and its buffer for reuse by the next render()
call. After the first render+recycle cycle, render() does zero
mallocs (the image struct and pixel buffer are both reused).
Also switch hb_raster_image_t to use hb_vector_t<uint8_t> for its
pixel buffer so resize tracking is automatic.
Update hb-raster-all benchmark to use recycling.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Renders every glyph in a font through the rasterizer.
Args: font-file [font-size-px] [output-dir]
font-size defaults to upem; output-dir writes per-glyph PGMs when given.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Renders glyph IDs 2-5 from fonts/adwaita.ttf at upem scale, writes
PGMs to /tmp/ for visual inspection, and asserts non-zero coverage.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix out-of-bounds pixel write in rasterize_tile: border tiles that
extend past the image edge were writing px-x_origin beyond the row
stride, wrapping into the start of the next row and overwriting
correctly-rasterized pixels with zero. Pass px1/py1 (exclusive
bounds) to rasterize_tile and clip the pixel loops accordingly.
Also: drop unused ex0 in pass 2 of tile assignment; move test-raster
from src/ to test/api/ and convert it to the GLib g_assert/hb_test_add
framework.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* [buffer] Fix a typo and doc string
* [buffer] Add merge_grapheme_clusters / merge_out_grapheme_clusters
Cluster merges serve two distinct purposes that require different level
gates:
- Grapheme grouping: combining marks merged into their base cluster.
Correct gate: IS_GRAPHEMES (levels 0 and 3).
New functions: merge_grapheme_clusters / merge_out_grapheme_clusters.
- Monotonicity maintenance: clusters merged to prevent non-monotone
output after ligature formation, reordering, etc.
Correct gate: IS_MONOTONE (levels 0 and 1).
Existing functions: merge_clusters / merge_out_clusters.
Previously both paths shared merge_clusters_impl's single IS_MONOTONE
gate, so GRAPHEMES (level 3) was incorrectly blocked from merging
grapheme clusters. This also caused a regression in the Thai and
Hangul shapers for MONOTONE_CHARACTERS (level 1): when their explicit
== MONOTONE_GRAPHEMES call-site guards were removed in #5069, the
impls' IS_MONOTONE gate no longer protected them.
Gates are now in the inline wrappers in hb-buffer.hh; the _impl
functions are gate-free. hb_form_clusters, CoreText grapheme
detection, and the Thai/Hangul shapers are updated to call the
grapheme-semantic variants. Fixes#5750.
Fixes https://github.com/harfbuzz/harfbuzz/issues/5751
Fixes https://github.com/harfbuzz/harfbuzz/issues/5750
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* [thai] Adjust grapheme merging logic
* [hangul] Tweak grapheme merging
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1. If smaller set has empty pages the subset checking logic was incorrectly incrementing the larger page index after skipping the empty smaller page index.
2. The logic for is_subset() on mixed inverted/not inverted sets was wrong.
Creating upem_font as a sub-font of the main font (which has scale =
upem * 64 due to subpixel bits) caused the paint API to emit spurious
parent→child scale transforms. With precision=2 rounding, 1/64 rounds
to 0.02 and 0.02*64 = 1.28, destroying the mathematical cancellation
and making color glyphs ~1.6x too large.
Fix by creating upem_font directly from the face, eliminating the
parent-child relationship. Update expected test outputs accordingly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>