Commit Graph
21471 Commits
Author SHA1 Message Date
Hanyu Wang d65aa90ea6 [buffer] Set content_type only for the format actually being parsed (#6092)
hb_buffer_deserialize_unicode() and hb_buffer_deserialize_glyphs() each
mutated the buffer's content_type unconditionally before checking
whether the caller-supplied format was recognized, then returned false
without rolling that back for an invalid format. A buffer left with
content_type set but len == 0 fails the assert_glyphs() /
assert_unicode() invariant on a later, independent call that expects
a clean buffer, aborting the process:

  - deserialize_unicode(INVALID) -> deserialize_glyphs() aborts in
    assert_glyphs().
  - deserialize_glyphs(INVALID) -> add_codepoints() aborts in
    assert_unicode().

Move each hb_buffer_set_content_type() call into the TEXT/JSON case
bodies of the existing format switch, instead of guarding it with a
separate validity check ahead of the switch. The switch's own case
list is already the single source of truth for which formats are
supported, so this avoids duplicating that knowledge in a second
condition that could drift out of sync with the switch.

Testing:
  - Built with -Db_sanitize=address,undefined.
  - Reproduced both original aborts against the unfixed code
    (SIGABRT via assert_glyphs()/assert_unicode()).
  - Rebuilt with the fix and reran both reproducers: clean exit, no
    assertion failure.
  - Ran the full test suite (meson test, sanitizer build, FreeType +
    ICU enabled) before and after: 71/75 pass in both, with the same
    4 pre-existing failures unrelated to buffer serialization
    (check-libstdc++, and the experimental vector/raster/gpu-fuzzer
    chunk 2 targets) - confirmed to fail identically on the
    unmodified baseline, so no regressions from this change.

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 15:35:58 -06:00
Sai Asish Y cce964cb4f [ot-tag] guard against NULL language in hb_ot_tags_to_script_and_language (#6085)
hb_ot_tag_to_language returns NULL for HB_OT_TAG_DEFAULT_LANGUAGE, and hb_language_to_string returns NULL for it, so the script-suffix path called strlen on a NULL pointer whenever the primary script tag did not match the input. Skip the suffix construction when there is no base language string and leave the default (NULL) language in place.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
2026-07-21 18:47:36 -06:00
nussaibah shaikh 53900fd388 [gpu] bound clip depth in push_clip_path_end (#6073)
push_clip_path_end wrote clip_stack[clip_depth] without the
HB_GPU_PAINT_MAX_CLIP_DEPTH check that push_clip_glyph and
push_clip_path_start both apply. clip_depth can be pushed past
the fixed 3-entry clip_stack, so closing a clip path while the
stack is full writes a pending_clip_t past the array. Guard it
like the sibling clip pushes.
2026-07-21 18:45:53 -06:00
nussaibah shaikh 387ab23f7f [raster] Reject non-finite texel coords in hb_raster_paint_image (#6082)
The range test guarding the bilinear sampler is comparison-based, so NaN
coordinates pass it and reach (int) floorf() in
hb_raster_sample_bilinear_premul, where only x1/y1 are clamped.  The
determinant guard has the same shape, so a transform that overflows to
infinity is accepted and 1/inf turns inf * 0 into NaN.
2026-07-21 18:40:41 -06:00
nussaibah shaikh 8b14f7b217 [colr] clamp alpha and radius deltas before unsigned conversion (#6087)
font-supplied F2DOT14 alpha and variable radius deltas can be negative,
and converting a negative float to unsigned is undefined behavior.
2026-07-21 18:38:27 -06:00
Behdad Esfahbod 38976fba5c [config] Never set HB_NO_CFF here
It was affecting subsetting library unintentionally.

https://github.com/harfbuzz/harfbuzz/pull/6009#issuecomment-4988163042
2026-07-21 14:53:15 -06:00
Qunxin Liu 2c875edbb6 [subset-repack] bug fixes (#6088)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 11:49:06 -06:00
Qunxin Liu 8207419e0a [subset-repack] increase REPACKER_MAX_VERTICES limit to 800000 2026-07-21 11:16:26 -06:00
Behdad Esfahbod fc85680fec Revert "[subset-repack] bug fixes (#6077)"
This reverts commit 0b590d6b54.
2026-07-21 10:59:48 -06:00
Qunxin Liu 0b590d6b54 [subset-repack] bug fixes (#6077)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 10:55:43 -06:00
dependabot[bot] ac9227e0a2 Bump actions/setup-python from 6.3.0 to 7.0.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6.3.0 to 7.0.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/ece7cb06caefa5fff74198d8649806c4678c61a1...5fda3b95a4ea91299a34e894583c3862153e4b97)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 13:29:56 +03:00
dependabot[bot] 3372624c66 Bump github/codeql-action/upload-sarif from 4.37.0 to 4.37.1
Bumps [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) from 4.37.0 to 4.37.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/99df26d4f13ea111d4ec1a7dddef6063f76b97e9...7188fc363630916deb702c7fdcf4e481b751f97a)

---
updated-dependencies:
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.37.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 13:27:00 +03:00
Khaled Hosny 53d292f0d1 [introspection] Fix introspection warnings
Fixes https://github.com/harfbuzz/harfbuzz/issues/4875
2026-07-20 13:26:30 +03:00
Khaled Hosny 6fa49d36f0 [docs] Fix reference to non-existent hb_face_create_from_blob_or_fail 2026-07-20 13:26:05 +03:00
Nussu06 af192b7e0f [gpu] Validate extents fit i16 before quantizing 2026-07-18 07:26:32 -06:00
Nussu06 1737bce456 [subset] bound cvar tuple data length in calculate_cvt_deltas 2026-07-18 07:25:19 -06:00
Nussu06 9de7e9d563 [paint] pass color_glyph its own user_data
The dispatch wrapper handed the callback user_data->push_clip_glyph
instead of user_data->color_glyph, so a client registering both
callbacks with different contexts got the wrong pointer on every
COLR glyph.
2026-07-17 11:43:34 -06:00
dependabot[bot] 0577ee23cf Bump meson from 1.11.1 to 1.11.2 in /.ci
Bumps [meson](https://github.com/mesonbuild/meson) from 1.11.1 to 1.11.2.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.11.1...1.11.2)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.11.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-17 11:18:22 +03:00
dependabot[bot] f2ab271c1f Bump github/codeql-action/upload-sarif from 4.36.3 to 4.37.0
Bumps [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) from 4.36.3 to 4.37.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/54f647b7e1bb85c95cddabcd46b0c578ec92bc1a...99df26d4f13ea111d4ec1a7dddef6063f76b97e9)

---
updated-dependencies:
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-17 11:17:24 +03:00
Qunxin Liu af85ffc449 [subset] increase HB_MAX_FEATURE_INDICES limit to 8000
A realistic font file reaches 1512 feature indices, so increase the max
limit
2026-07-15 11:05:53 -06:00
Garret Rieger d7861576ae More fixes for review comments. 2026-07-14 16:26:49 -06:00
Garret Rieger 2725565dab Address review comments. 2026-07-14 16:26:49 -06:00
Garret Rieger 99380f0e44 Add new hb_subset_input_to_command_line_or_fail().
This generates an equivalent hb-subset command line string for a given subset input.

Assisted by gemini.
2026-07-14 16:26:49 -06:00
Behdad Esfahbod 946901f88d [svg] Use ISALNUM, not isalnum 2026-07-14 16:00:07 -06:00
Behdad Esfahbod 4fbbe7ae4f [ot-font] Invalidate vertical origin cache on scale change
The vertical-origin cache stores scaled y-origin values, but it was
validated against serial_coords. Changing only the font scale leaves
serial_coords unchanged, so hb_font_set_scale() could keep serving stale
vertical origins.

Validate scale-dependent OT font caches against the full font serial and
check that serial before using the batched vertical-origin callback. Add
an API regression that changes y_scale on one font and verifies the
vertical origin is recomputed.

Testing:
meson compile -C build test/api/test-ot-face
meson test -C build test-ot-face --print-errorlogs
meson test -C build --suite api --print-errorlogs

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6066
Assisted-by: OpenAI Codex
2026-07-14 14:02:38 -06:00
Behdad Esfahbod 88e09bb1dc Merge pull request #4710 from harfbuzz/cff2-instancing-try2
Trying to partial-instance CFF2
2026-07-14 14:02:20 -06:00
Behdad Esfahbod 8d2d5174ea Merge pull request #6056 from harfbuzz/paint-fill-glyph
Fix hb-vector rendering of COLRv0 layers with huge font scales
2026-07-14 12:32:22 -06:00
Khaled Hosny bbcd7d6562 [doc/paint] Mention the decomposed fallback sequence for fill-glyph 2026-07-14 01:27:09 +03:00
Khaled Hosny e2588968ae [COLR] Emit fill_glyph for glyph clips with a solid paint
Detect the fill-glyph pattern in the COLRv1 graph: a PaintGlyph whose
child is a (Var)PaintSolid, and emit a single fill_glyph instead of
push_clip_glyph + color + pop_clip.
2026-07-12 22:20:21 +03:00
Khaled Hosny bc00cd8fb5 [fontations] Use fill_glyph for solid glyph fills 2026-07-12 21:16:46 +03:00
Khaled Hosny b4ed968183 [test/paint] Test the fill_path callback 2026-07-12 19:36:15 +03:00
Khaled Hosny 884a591273 [raster] Implement fill_glyph callback 2026-07-12 19:21:47 +03:00
Khaled Hosny bec75aa881 [cairo] Implement fill_glyph callback 2026-07-12 15:14:00 +03:00
Khaled Hosny afda4215dd [ft] Use fill_glyph for COLRv0 layers 2026-07-12 03:26:26 +03:00
Behdad Esfahbod 907579859f [gobject] Drop const attribute from enum get_type declarations (#6061)
GLib removed G_GNUC_CONST from generated get_type declarations because
GType registration can initialize state and the attribute can cause
miscompilations with GCC trunk.

Match that behavior for generated GObject enum declarations.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6060

Assisted-by: OpenAI Codex
2026-07-10 01:59:59 -06:00
Behdad Esfahbod 5e887d3672 Fix previous commit 2026-07-09 12:14:33 -06:00
Behdad Esfahbod b011381764 Ignore -Wunused-template
Fixes https://github.com/harfbuzz/harfbuzz/issues/6059
2026-07-09 12:09:39 -06:00
Khaled Hosny 9ab56e8678 [vector] Implement fill_glyph callback
Fill the glyph shape directly. This simplifies the SVG/PDF output and
fixes the SVG clipping issue with COLRv0 layers and large scale, as
there is no clip now at all.
2026-07-08 20:30:03 +03:00
Khaled Hosny 421cc8f5a7 [paint] Add hb_paint_fill_glyph()
Instead of painting COLRv0 and outline fallback layers with
push_clip_glyph + color + pop_clip, add a dedicated callback for this
common paint operation.

The default (*_nil) implementation uses the decomposed sequence, so
existing clients without a fill_glyph implementation continue to work as
before.
2026-07-08 20:29:31 +03:00
Khaled Hosny f7a8ef5022 [vector] Fix PDF MediaBox orientation
The MediaBox negated the y-range like SVG viewBox does, but the SVG
output is wrapped in scale(1,-1), and PDF content is emitted y-up.
2026-07-08 20:28:53 +03:00
Khaled Hosny a1b0b0046c [test/vector] Test painting a COLRv0 glyph at a large font scale
Add a test for painting a COLRv0 glyph at large scale. The output shows
the glyph clipped. We will fix this in the next commits.
2026-07-08 20:28:40 +03:00
Khaled Hosny 04f7a60bc4 [draw] Promote quadratic curves to cubics in double precision (#6057)
The fallback quadratic-to-cubic promotion works in single precision.
This results in different rounding values for different architectures.
Promote in double precision instead, which rounds deterministically.

Add a PDF test that exercises this, and make the test runner handle PDF
expectations.

This also effectively reverts d4511648db
2026-07-08 11:11:16 -06:00
dependabot[bot] eb6d2466f8 Bump setuptools from 82.0.1 to 83.0.0 in /.ci
Bumps [setuptools](https://github.com/pypa/setuptools) from 82.0.1 to 83.0.0.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](https://github.com/pypa/setuptools/compare/v82.0.1...v83.0.0)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-version: 83.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-08 15:21:26 +03:00
dependabot[bot] 6c0ec851c5 Bump github/codeql-action/upload-sarif from 4.36.2 to 4.36.3
Bumps [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) from 4.36.2 to 4.36.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/8aad20d150bbac5944a9f9d289da16a4b0d87c1e...54f647b7e1bb85c95cddabcd46b0c578ec92bc1a)

---
updated-dependencies:
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.36.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-08 15:21:06 +03:00
Behdad Esfahbod 51d8c55cde Merge pull request #6055 from harfbuzz/vector-pdf-fixes
Bunch of fixes to vector library and various list getters and one FT bugfix
2026-07-08 01:35:01 -06:00
Behdad Esfahbod dba7469762 [docs] Mark list-getter output arrays as nullable
The list-getter APIs accept a NULL output array to query just the total
count (and, since the preceding commits, do so safely).  Annotate the
output-array parameters (nullable) in the gtk-doc blocks so introspection
bindings reflect that contract, matching the already-nullable CPAL/COLR
getters.

Covers hb_ot_meta_get_entry_tags, hb_aat_layout_get_feature_types,
hb_ot_layout_feature_get_characters, hb_ot_layout_lookup_get_glyph_alternates,
hb_ot_layout_get_attach_points, hb_ot_layout_get_ligature_carets,
hb_ot_layout_table_get_script_tags / _get_feature_tags / _get_language_tags,
hb_ot_layout_language_get_feature_indexes / _get_feature_tags,
hb_ot_layout_feature_get_lookups / _with_variations_get_lookups,
hb_ot_math_get_glyph_kernings / _assembly / _variants,
hb_ot_var_get_axes / _get_axis_infos / _named_instance_get_design_coords,
and hb_face_get_table_tags.

Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 01:12:27 -06:00
Behdad Esfahbod d287ee3ee2 [ft] Fix get_table_tags returning no tags on streaming faces
_hb_ft_get_table_tags() (used for FT faces created over a custom stream,
i.e. when ft_face->stream->read is set) did

    if (!table_count) return population;
    else *table_count = 0;
    ...
    end_offset = hb_min (start_offset + *table_count, population);

zeroing *table_count before using it as the requested buffer size, so
end_offset collapsed to start_offset, the copy loop never ran, and
hb_face_get_table_tags() always reported zero tags (and wrote none).

Restructure to match the CoreText / face-builder / default backends: keep
the caller's *table_count, check the start_offset + *table_count sum for
overflow, clamp to the table population, then copy.  Also guard the copy
on table_tags so a NULL output array (count-only query) is handled.

The existing FT test used FT_New_Memory_Face, whose in-memory face routes
through the default blob table-tags path and never exercised this
callback.  Add a streaming-face variant (FT_Open_Face with a read stream)
that does; it failed (count 0 vs 3) before this fix.

Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 01:08:45 -06:00
Behdad Esfahbod 706a2ba8d3 [ot] Guard remaining list-getter output arrays against NULL
Following GHSA-v5mv-8hhw-vff8, sweep the rest of the public "list getter"
APIs for the same defect: a NULL output array passed with a non-NULL count
on a populated table wrote through the NULL pointer and crashed (SIGSEGV).
These output params are not all annotated nullable, but the crash is
reachable from public C APIs and is a straightforward DoS, so guard the
write on the output pointer consistently (matching hb_color_line_get_color_stops
and the fixes in the previous two commits).  When the output is NULL the
getter now just returns the total count.

Getters hardened:

  - MathKern::get_entries              (hb_ot_math_get_glyph_kernings)
  - MathGlyphAssembly::get_parts       (hb_ot_math_get_glyph_assembly)
  - MathGlyphConstruction::get_variants (hb_ot_math_get_glyph_variants)
  - IndexArray::get_indexes            (hb_ot_layout_language_get_feature_indexes,
                                        hb_ot_layout_feature_get_lookups, ...)
  - RecordListOf::get_tags             (hb_ot_layout_table_get_script_tags,
                                        _get_feature_tags, _get_language_tags, ...)
  - AttachList::get_attach_points      (hb_ot_layout_get_attach_points)
  - LigGlyph::get_lig_carets           (hb_ot_layout_get_ligature_carets)
  - fvar get_axis_infos / get_axes_deprecated / get_instance_coords
                                        (hb_ot_var_get_axis_infos, hb_ot_var_get_axes,
                                        hb_ot_var_named_instance_get_design_coords)
  - OpenTypeOffsetTable / CoreText / face-builder get_table_tags
                                        (hb_face_get_table_tags)

Extend test/api/test-ot-nullable-output.c with table-tags, fvar axis-info
and MATH kerning cases; each crashed before this change.

Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:53:56 -06:00
Behdad EsfahbodandClaude Opus 4.8 7052cd343e [GSUB] Fix NULL-deref in SingleSubst get_glyph_alternates
hb_ot_layout_lookup_get_glyph_alternates() documents its alternate_glyphs
output as nullable, and the AlternateSubst path was fixed in the previous
commit.  The Single-substitution fallback paths (SingleSubstFormat1 and
SingleSubstFormat2, used when the queried lookup is a single-substitution)
had the same defect: they gated the write on

    if (alternate_count && *alternate_count)

and then did *alternate_glyphs = glyph_id without checking alternate_glyphs.
Passing a NULL alternate_glyphs with a non-NULL, non-zero count on a covered
glyph therefore wrote through NULL and crashed.

Also require alternate_glyphs to be non-NULL before storing.

Fixes: GHSA-v5mv-8hhw-vff8
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:46:20 -06:00
Behdad Esfahbod a439a61f8f [vector] Guard base64 output-length overflow in SVG image embedding
hb_vector_buf_t::append_base64() sized its output as

    unsigned out_len = ((len + 2) / 3) * 4;

which overflows 32-bit for a very large len (len + 2 wraps, and the * 4
wraps for len above ~3.2 GB).  len is the attacker-controlled embedded
PNG length on the vector SVG paint path (hb-vector-paint-svg.cc), so a
wrapped out_len under-sizes the buffer while the encode loop still writes
4 bytes per 3 input bytes -- a heap out-of-bounds write.

Compute the group count without the +2 (len / 3 + (len % 3 != 0)) and use
hb_unsigned_mul_overflows()/hb_unsigned_add_overflows() so an oversized
input fails the allocation instead of wrapping.  resize_full() already
rejects a size that does not fit in int, so the remaining path is safe.

Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:30:40 -06:00