Commit Graph
8 Commits
Author SHA1 Message Date
Behdad Esfahbod 6e45962326 [raster] Guard direct SVG paint callbacks
The raster SVG image callback assumes hb_raster_paint_glyph()
seeded svg_font/svg_glyph state before the paint protocol
reaches HB_PAINT_IMAGE_FORMAT_SVG. Clients can also call
hb_font_paint_glyph_or_fail() directly with
hb_raster_paint_get_funcs(), which leaves svg_font unset and
crashes in hb_raster_svg_render().

Return false when the callback is reached without that
wrapper-only state, and cover the direct API path with a
regression test.

Testing: CCACHE_DISABLE=1 meson test -C build
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-ggh9-cgg2-r4vr
Assisted-by: OpenAI Codex <codex@openai.com>
2026-03-26 14:41:14 -06:00
Khaled Hosny b327f0c672 [tests] Fix warning when building without zlib
../test/api/test-raster.cc:67:1: warning: unused function 'render_svg_glyph' [-Wunused-function]
   67 | render_svg_glyph (hb_face_t      *face,
      | ^~~~~~~~~~~~~~~~
1 warning generated.
2026-03-12 17:36:39 +02:00
Behdad Esfahbod b7e4f5fd62 [raster] Support gzip-compressed SVG documents
The raster SVG path treated hb_ot_color_glyph_reference_svg()
blobs as plain XML, even though SVG table documents may
legally be gzip encoded. That caused hb-raster to reject
fonts that store compressed SVG documents.

Detect gzip payloads in the raster SVG renderer, reject
documents whose advertised uncompressed size exceeds
HB_SVG_MAX_DOCUMENT_SIZE, and inflate the rest through
zlib while keeping the same size cap enforced during
decompression. Plain SVG documents are also bounded by the
same 16 MiB limit.

Add a raster API regression that renders the existing
plain and compressed noto_handwriting SVG fixtures and
verifies identical output.

Testing:
- meson test -C build

Assisted-by: OpenAI Codex
2026-03-11 14:18:31 -03:00
Behdad Esfahbod 5ea04afcda raster: adopt create_or_fail and strict render semantics 2026-02-24 04:46:51 -03:00
Behdad Esfahbod 742f79da08 raster: remove extents_from_glyph_extents API
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.
2026-02-23 12:10:41 -03:00
Behdad EsfahbodandKhaled Hosny 99a84d7f02 Update src/hb-raster.h
Co-authored-by: Khaled Hosny <khaled@aliftype.com>
2026-02-21 17:29:05 -03:00
Behdad EsfahbodandClaude Sonnet 4.6 35ba082aa2 hb-raster: add test_glyph to test-raster
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>
2026-02-21 17:29:05 -03:00
Behdad EsfahbodandClaude Sonnet 4.6 c9d459b8e9 hb-raster: fix tile bounds clipping; move test to test/api/
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>
2026-02-21 17:29:05 -03:00