Use the layout Types array and offset forms for GSUB subtables that
gain 24-bit coverage-indexed arrays in the beyond-64k formats.
This widens SingleSubst substitute arrays, MultipleSubst sequence
offsets, AlternateSubst alternate-set offsets, LigatureSubst
ligature-set offsets, and the LigatureSet offsets to Ligature
tables while preserving the nested 16-bit counts required by the
spec.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Use the layout Types for chained context rule-set arrays and
ChainRuleSet offsets. For class-based formats, use a named
ChainClassRuleSet wrapper so the 24-bit surrounding offsets do not
leak as a second template argument at the call site.
This brings ChainedSequenceContextFormat4 and Format5 in line with
the spec's 24-bit counts and offsets while keeping class-rule
payloads in their 16-bit class-value form.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Use the layout Types for sequence context rule-set arrays and
RuleSet offsets. For class-based formats, use a named ClassRuleSet
wrapper so the 24-bit surrounding offsets do not leak as a second
template argument at the call site.
This brings SequenceContextFormat4 and Format5 in line with the
spec's 24-bit counts and offsets while keeping class-rule payloads
in their 16-bit class-value form.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Template the coverage-based sequence context format over layout
Types and dispatch format 6 through the MediumTypes instance.
This matches the spec's wider coverage-offset variant while keeping
formats 1 through 5 unchanged.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Fold the GDEF versioned header fields back into GDEF and select
active offsets from the table version.
Version 1.4 now honors the spec's 32-bit offset2 fields when they
are present. LigCaretList is templated over layout Types so the
version 1.4 LigCaretList2 layout can use the 32-bit coverage offset,
24-bit glyph count, and 24-bit LigGlyph offsets.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Move the GSUB/GPOS versioned header fields back into GSUBGPOS
and select the active ScriptList, FeatureList, and LookupList
offsets from the table version.
Version 1.2 now uses the spec's 32-bit offset2 fields when they
are present, while the common list internals remain the existing
16-bit layout structures.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Add the BASE BaseCoord format 4 dispatch arm. The format mirrors
format 2, but stores the reference glyph as a 24-bit glyph ID for
fonts with an extended glyph repertoire. Share the implementation
through a Types-templated format pair.
The subsetting path remaps the widened reference glyph in the same
way format 2 remaps its 16-bit reference glyph.
Testing: meson test -C build
Assisted-by: OpenAI Codex
CursivePos format 2 reuses the templated format-1 body with wider
fields. Preserve the source format when serializing subsets so a format-2
subtable is not emitted with a format-1 tag.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Use the HarfRust bulk UnicodeBuffer glyph-info append API to populate
the shaping buffer from HarfBuzz glyph infos after one slice cast. This
avoids per-codepoint add calls in the HarfBuzz-to-HarfRust bridge.
Testing: ninja -C build src/rust/libharfbuzz_rust.a
Assisted-by: OpenAI Codex
HarfBuzz language tags are already available as C string bytes.
Pass those bytes directly to HarfRust Language::new instead of
converting through UTF-8 and FromStr.
Testing: ninja -C build src/rust/libharfbuzz_rust.a
Assisted-by: OpenAI Codex
Most shaping calls pass maximum a couple of user features. Store the
converted HarfRust feature list in a SmallVec with the same inline
capacity that HarfRust uses for shape-plan user features, avoiding
a heap allocation for common cases.
Testing: ninja -C build src/rust/libharfbuzz_rust.a
Assisted-by: OpenAI Codex
HarfRust glyph infos and positions are layout-compatible with the
corresponding HarfBuzz buffer structs. Assert that size, alignment,
and visible field offsets match, then copy both arrays directly into
the HarfBuzz buffer instead of translating each glyph field-by-field.
Also, don't truncate hb buffer before resizing it to populate. This
would not zero the private fields (var1/var2, var), but that's not
visible to user nor used later.
Assisted-by: OpenAI Codex
get_base_glyph_paintrecord() looked up the BaseGlyphList with the
reference-returning bsearch(), which yields the all-zero Null object
when the glyph is absent, and then rejected non-matches by comparing
record->glyphId against the requested gid. For glyph 0 the Null
object's glyphId (0) equals the requested gid, so the sentinel was
taken for a real record. .notdef then resolved to a bogus empty paint,
and COLR::get_extents() returned success with 0,0,0,0 instead of
letting hb_ot_get_glyph_extents() fall back to the glyf outline.
Use bfind(), which reports presence directly, so a missing glyph
(including glyph 0) returns nullptr and extents fall back correctly.
This surfaced as a mark-positioning difference: fallback mark
positioning centers a mark using the base and mark glyph extents, so a
.notdef mark over a space was positioned differently from shapers that
report the real outline extents (e.g. fontations/HarfRust).
Testing:
- test/api/test-extents.c: glyph 0 (.notdef, has an outline) now
reports its outline extents; updated the expectation accordingly.
- b/util/hb-shape Noto-COLRv1.ttf -u 0020,0650 now matches
--font-funcs=fontations.
- meson test -C build (246 passed, 1 skipped)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
HB_NO_DRAW only disables the draw-dependent OT-font CFF extents
path. It should not imply full HB_NO_CFF for downstream builds
that independently disable CFF subsetting.
Keep the HB_TINY behavior by making HB_NO_CFF conditional on the
combination of HB_TINY and HB_NO_DRAW. Also avoid calling the CFF2
instance-metrics helper when OT-font CFF support is disabled, since
that helper needs the CFF2 extents implementation.
Context:
https://github.com/harfbuzz/harfbuzz/pull/5958#discussion_r3121421428https://github.com/harfbuzz/harfbuzz/issues/5955#issuecomment-4289771142https://github.com/harfbuzz/harfbuzz/issues/5955#issuecomment-4345573851
Tested by compiling src/harfbuzz-subset.cc directly with
-DHB_NO_DRAW -DHB_NO_SUBSET_CFF and checking the CFF2 extents symbol
is no longer undefined. Also direct-compiled src/harfbuzz.cc with the
same defines, plus src/harfbuzz-subset.cc for plain HB_TINY and
HB_TINY with HAVE_CONFIG_OVERRIDE_H using util/gpu/web.
Assisted-by: OpenAI Codex <codex@openai.com>
Avoid unnecessary round-trip of converting pre- and post-context from
Unicode codepoints to UTF-8 in C++ (hb-harfrust.cc) and back to Rust
&str (and eventually back to codepoints) in Rust (shape.rs).
Instead, use the new codepoint-based context setters in HarfRust.
Verified locally against CJK_article.html blink_perf menchmark to
gain approximately 2-4%.
Requires https://github.com/harfbuzz/harfrust/pull/371 and a newly
released HarfRust version.
Assisted-by: Google Antigravity
Co-authored-by: Behdad Esfahbod <behdad@behdad.org>
* [rust] Reinstate commented-out git branch for harfrust
For development purposes.
* [rust] Use new HarfRust GlyphFlags getter
Faster.
* [rust] Pin to new harfrust 0.8.2
When buffer verification detects non-monotone clusters, skip the
unsafe-to-break and unsafe-to-concat checks that rely on monotone
cluster order. Keep reporting the monotone-cluster failure as the
underlying verifier error.
Also turn the unsafe-to-break text range assertion into a verifier
failure so malformed intermediate verifier state does not abort the
process.
Testing:
meson test -C build
Assisted-by: OpenAI Codex
map_coords_16_16() converted roundf(delta * 4) back to int without
bounding the float first. With attacker-controlled avar2 long-word
(32-bit) ItemVariationStore deltas, delta * 4 can exceed INT_MAX, and
the implicit float-to-int conversion is undefined behavior per the C++
standard (out-of-range floating-to-integral conversion). The result was
clamped immediately afterwards, so there was no memory-safety impact,
but the conversion itself trips UBSan.
Clamp the float to the 16.16 normalized range before the conversion so
the narrowing can never go out of range.
Fixes: https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-xxfv-x2x5-8992
Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`palt` (Proportional Alternate Widths) is widely used in Japanese
typography but was not retained in the default subset layout features,
unlike its vertical counterpart `vpal` and the closely related `halt`
/ `vhal` / `chws` / `vchw` already kept by default. As a result,
subsetting silently stripped `palt` data, and downstream CSS
`font-feature-settings: "palt"` had no effect.
Add `palt` to the default layout features list alongside the other
East Asian spacing features.
Verified locally with `meson test -C build` (240/240 OK, 0 failures)
and by subsetting NotoSansJP-Bold.ttf with `hb-subset`: `palt` is
stripped on main and retained with this patch, while the other CJK
spacing features (`halt`, `vpal`, `vhal`) are unaffected.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6006
Assisted-by: Claude
Wire the HarfRust shaper through the active hb_font_t callback
surface so custom hb_font_funcs_t are respected during shaping.
Add a harfrust-specific test-shape invocation to cover that path.
Tested: meson test -C build test-shape-harfrust
Tested: HB_SHAPER_LIST=harfrust meson test -C build harfbuzz:shape_threads
Tested: HB_SHAPER_LIST=harfrust meson test -C build test-shape
Assisted-by: OpenAI Codex
---------
Co-authored-by: Chad Brokaw <cbrokaw@gmail.com>
Round COLRv1 alpha values when packing them into 8-bit colors in the
native OpenType and FreeType paint paths.
This removes the old downward truncation bias and aligns native output
with the backend behavior expected by the updated paint fixtures.
Update the affected test-paint fixtures for the rounded alpha values.
Testing:
CCACHE_DISABLE=1 meson test -C build --print-errorlogs
Assisted-by: OpenAI Codex
Reduce linear gradient anchors and normalize color lines before
printing them in test-paint. This makes the transcript reflect the
renderer-facing gradient geometry instead of backend-specific raw
COLRv1 anchors and stop ranges.
Also normalize signed zero in transform output so the fixtures stay
stable across backends.
Testing:
CCACHE_DISABLE=1 meson test -C build test-paint --print-errorlogs
Assisted-by: OpenAI Codex
Make the native COLRv1 paint paths report the root clip in font
units under the font transform. This matches the order used by
fontations and removes the need to pre-scale the HB-OT clip extents.
For the FreeType path, add a helper to convert FT_ClipBox values
back to font units before pushing them under the font transform, and
share that conversion with nested COLR glyph clip boxes.
Update paint and vector expectations for the new transform/clip stack.
Testing:
CCACHE_DISABLE=1 meson test -C build --print-errorlogs
Assisted-by: OpenAI Codex
The disabled assertions cover behavior from an older beyond-64k proposal.
That proposal has since changed, and current backends should not be
required to implement the stale loca-derived glyph count and metrics rules.
Keep the checks visible as disabled reminders until the library code is
adapted to the updated design.
Tested with:
CCACHE_DISABLE=1 HB_FONT_FUNCS=fontations meson test -C build test-be-glyph-advance test-be-num-glyphs
Assisted-by: OpenAI Codex
Keep obsolete AAT offset-to-index helpers signed, but do the arithmetic
in 64-bit values before clamping back to an int index. This preserves
the existing large positive failure index used for invalid offsets while
avoiding signed int overflow for malformed data.
Testing:
- b/util/hb-shape CharcoalCY.dfont Empty-handed
- b/util/hb-shape CharcoalCY.dfont --unicodes=002D,002D
- test/shape/run-tests.py build/util/hb-shape test/shape/data/in-house/tests/kern-format2.tests
- meson test -Cb
Assisted-by: OpenAI Codex
Contextual and non-contextual AAT subtables replace glyphs in place.
When such a replacement produced the AAT deleted glyph, we changed only
the glyph ID and did not set the AAT-deleted metadata that later cleanup
uses to remove deleted glyphs from the buffer.
Make replace_glyph_inplace() match the other AAT replacement helpers by
setting the deleted scratch flag and glyph-info marker for glyph 0xFFFF.
Testing:
- b/util/hb-shape CharcoalCY.dfont --unicodes=002D,002D
- b/util/hb-shape CharcoalCY.dfont Empty-handed
- meson test -Cb
Assisted-by: OpenAI Codex
The legacy mort contextual subtable uses signed word offsets to
per-glyph substitution tables. A zero offset means that there is no
table for that action. We were treating the fields like morx lookup
indices with 0xFFFF as the sentinel, so zero-offset state entries tried
to substitute arbitrary glyphs from the start of the state table.
Keep morx using lookup-index semantics, but use signed offsets and the
zero sentinel for mort. This fixes CharcoalCY shaping of text such as
"Empty-handed", which previously produced out-of-font glyph IDs.
Testing:
- b/util/hb-shape CharcoalCY.dfont Empty-handed
- b/util/hb-shape CharcoalCY.dfont --unicodes=002D,002D
- meson test -Cb
Fixes: https://github.com/harfbuzz/harfbuzz/issues/5887
Assisted-by: OpenAI Codex
Update the Rust bridge and Cargo dependency to harfrust 0.8.
Switch shaping calls to ShapeOptions, keep the cached shaper
path, and remove an unused face_data argument from the shaping
ABI.
Tested: meson compile -C build
Assisted-by: OpenAI Codex
Cast and add #[allow(clippy::unnecessary_cast)] as the C compiler
chooses different signedness for the hb_script_t and hb_tag_t enum
types depending on architecture. Add casts where needed and add
clippy suppressions to avoid warnings when compiled on systems
where the enum is unsigned by default.
* CMake: Fix building hb-gpu on Windows
Add the needed items for the program to build and link on Windows in the
CMake build files as well.
* CMake: Fix introspection builds with ICU
Grab the library name from the results of find_package(ICU COMPONENTS
uc) and use it instead for linking HarfBuzz, et al, so that we have a
proper command line to link to ICU-UC when running g-ir-scanner.