Commit Graph
21377 Commits
Author SHA1 Message Date
Behdad Esfahbod eb8d87f024 [beyond-64k] Preserve CursivePos format when subsetting
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
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 4997b9f75c Revert some AI noise
Broke some access that was guarded behind hb_barrier()
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 533452d0d6 [beyond-64k] Update SinglePos / PairPos for latest proposal 2026-06-05 12:34:51 +02:00
Behdad Esfahbod 435a67417e [beyond-64k] Add CursivePosFormat2 2026-06-05 12:34:51 +02:00
Behdad Esfahbod 0932bbc45c [beyond-64k] Update PairPosFormat3 to latest proposal 2026-06-05 12:34:51 +02:00
Behdad Esfahbod 155c19c216 [beyond-64k] Add SinglePos formats 3/4 2026-06-05 12:34:51 +02:00
Garret Rieger 8647a429ce Fix subset fuzzer timeout. (#6019)
https://oss-fuzz.com/testcase-detail/5440786836815872
2026-06-04 04:37:23 -06:00
Khaled Hosny 56feae4035 14.2.1 14.2.1 2026-06-02 14:30:59 +03:00
Behdad Esfahbod 8beb229a4c [gen-tag-table] Generate bytes instead of str in rust output (#6017) 2026-06-02 03:11:23 -06:00
Fuqiao Xue 6dda1a083c Add HB_SCRIPT_KATAKANA_OR_HIRAGANA (#5995)
* Add HB_SCRIPT_KATAKANA_OR_HIRAGANA

Fix #1473.

* Refactor HB_SCRIPT_KATAKANA_OR_HIRAGANA
2026-06-02 02:33:52 -06:00
Behdad Esfahbod 2575326527 [rust] Bulk-populate HarfRust input buffer (#6016)
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
2026-06-02 01:46:23 -06:00
Behdad Esfahbod a4eb9e25d3 [rust] Avoid parsing HarfRust language tags (#6015)
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
2026-06-01 10:35:24 -06:00
Behdad Esfahbod 97650e50e2 [rust] Use SmallVec for HarfRust features (#6014)
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
2026-06-01 09:53:23 -06:00
Behdad Esfahbod 8987443bd3 [rust] Bulk-copy HarfRust shape results (#6013)
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
2026-06-01 08:49:52 -06:00
Behdad EsfahbodandClaude Opus 4.8 d639197ed5 [COLR] Fix glyph extents for .notdef in COLRv1 fonts (#6012)
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>
2026-06-01 03:23:05 -06:00
Behdad Esfahbod 27734f01dc Fix unused-warning error
https://github.com/harfbuzz/harfbuzz/pull/6009#issuecomment-4590976488
2026-06-01 10:54:05 +02:00
Behdad Esfahbod 0efc579fc4 [config] Fix CFF closure with HB_NO_DRAW (#6009)
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_r3121421428
https://github.com/harfbuzz/harfbuzz/issues/5955#issuecomment-4289771142
https://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>
2026-06-01 02:32:21 -06:00
Dominik RöttschesandBehdad Esfahbod 30bde663e7 Pass codepoints for context directly to HarfRust shaper (#6008)
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>
2026-06-01 02:32:01 -06:00
Behdad Esfahbod bc4cd305ca [rust] Use new harfrust GlyphFlags getter (#6011)
* [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
2026-06-01 02:23:26 -06:00
Behdad Esfahbod fd707f8151 [fontations] Map default variations
https://github.com/servo/servo/pull/38707#issuecomment-4587826343
2026-05-31 21:26:19 +02:00
Behdad Esfahbod 2353415a37 [rust] Reinstate commented-out git branch for harfrust
For development purposes.
2026-05-30 23:23:59 +02:00
Behdad Esfahbod e020ac487e [buffer] Harden verification after non-monotone clusters (#6010)
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
2026-05-30 08:48:03 -06:00
Behdad Esfahbod abc3b1a363 [avar] Avoid float-to-int overflow UB in avar2 mapping
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>
2026-05-30 15:41:53 +02:00
Takeru Suzuki 689383d05b [subset] keep East Asian spacing palt by default (#6007)
`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
2026-05-29 03:19:18 -06:00
Behdad EsfahbodandChad Brokaw 77abf89986 [harfrust] Honor hb font funcs during shaping (#6002)
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>
2026-05-28 13:33:21 -04:00
Qunxin Liu 1e434eb7fd [subset-repack] increase the MAX_SPACES limit (#5996)
This fixes: https://github.com/harfbuzz/harfbuzz/issues/5980
2026-05-27 16:43:47 -06:00
Behdad Esfahbod 2326d8cc49 Merge pull request #6005 from harfbuzz/fontations-paint-match-more
Match more paint tests across backends (ot, ft, fontations)
2026-05-27 11:42:23 -06:00
Behdad Esfahbod 719a1d3c10 [paint] Round COLRv1 alpha consistently
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
2026-05-27 12:42:55 +02:00
Behdad Esfahbod 788706d568 [test] Normalize linear paint transcripts
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
2026-05-27 12:40:44 +02:00
Behdad Esfahbod 88adc6437e Merge pull request #6004 from harfbuzz/fontations-colr-match
[hb/ft] Match COLRv1 paint order to fontations
2026-05-27 04:17:23 -06:00
Behdad Esfahbod 56ac9c925f [paint] Push COLRv1 root clip under font transform
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
2026-05-27 10:48:19 +02:00
Behdad Esfahbod 202202b349 [test] Disable stale beyond-64k API checks
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
2026-05-27 09:38:31 +02:00
Behdad Esfahbod c6ebdf6520 [font] Adjust extents rounding to be inclusive 2026-05-26 22:40:38 +02:00
Behdad Esfahbod b90b89feb9 [font] Fix extents scaling truncation 2026-05-26 22:35:31 +02:00
Behdad Esfahbod 83f88d2ed6 Merge pull request #6003 from harfbuzz/mort-contextual-offsets
[mort] Fix contextual offsets
2026-05-26 14:32:59 -06:00
Behdad Esfahbod 98626f60ab [aat] Avoid overflow in obsolete offset math
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
2026-05-26 18:56:46 +02:00
Behdad Esfahbod f9d86e2d73 [aat] Mark in-place deleted glyph replacements
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
2026-05-26 18:47:19 +02:00
Behdad Esfahbod 20bc59869e [aat] Fix mort contextual substitution offsets
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
2026-05-26 18:43:06 +02:00
Behdad Esfahbod 4b287d9f86 [rust] Remove accidental change to comments 2026-05-26 17:21:18 +02:00
Behdad Esfahbod 53c761783b [harfrust] Update shape glue for harfrust 0.8 (#6001)
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
2026-05-26 09:18:15 -06:00
dependabot[bot] 1cd1e02274 Bump github/codeql-action from 4.35.5 to 4.36.0
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.35.5 to 4.36.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/9e0d7b8d25671d64c341c19c0152d693099fb5ba...7211b7c8077ea37d8641b6271f6a365a22a5fbfa)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-25 20:43:16 +03:00
Dominik Röttsches 0a7092643f [rust] Windows build fixes
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.
2026-05-25 15:21:45 +03:00
fanc999-1 cb3fd656b2 Some CMake updates for Windows builds (#5997)
* 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.
2026-05-22 05:22:05 -06:00
fanc999-1 f54cb4a3ae build: Fix building hb-gpu on Windows (#5986)
Correct the d3dcompiler dependency-it should be looking for
D3DCompiler.lib (or so), not D3DCompiler_47.lib, to link to
D3DCompiler_47.dll.
2026-05-22 04:18:45 -06:00
dependabot[bot] 22ea52f42f Bump github/codeql-action from 4.35.4 to 4.35.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.35.4 to 4.35.5.
- [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/68bde559dea0fdcac2102bfdf6230c5f70eb485e...9e0d7b8d25671d64c341c19c0152d693099fb5ba)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-19 09:09:27 +03:00
dependabot[bot] cbd63f557e Bump fonttools from 4.62.1 to 4.63.0 in /.ci
Bumps [fonttools](https://github.com/fonttools/fonttools) from 4.62.1 to 4.63.0.
- [Release notes](https://github.com/fonttools/fonttools/releases)
- [Changelog](https://github.com/fonttools/fonttools/blob/main/NEWS.rst)
- [Commits](https://github.com/fonttools/fonttools/compare/4.62.1...4.63.0)

---
updated-dependencies:
- dependency-name: fonttools
  dependency-version: 4.63.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-19 09:09:03 +03:00
Behdad Esfahbod f3c6b3ab92 [algs] Saturating arithmetic for get_size() on 32-bit (#5988)
On 32-bit platforms size_t is unsigned int, so the typical
get_size() computation `min_size + count * static_size`
silently wraps when the product exceeds UINT_MAX.  The
truncated value then flows into sanitize / serialize as a
small but plausible size, defeating bounds checks.

Add three helpers in hb-algs.hh:

  hb_unsigned_mul_saturate (a, b, ...)
  hb_unsigned_add_saturate (a, b, ...)
  hb_unsigned_mul_add_saturate (a, b, c)   /* a*b + c */

They saturate to SIZE_MAX on overflow.  Variadic overloads
left-fold so 3+ arguments work.  On 64-bit (size_t wider than
unsigned int), all three reduce to plain a*b / a+b — the
inputs to size computations are at most unsigned int so the
result fits in size_t without overflow.

Convert every get_size() that does arithmetic over variable
inputs:

  hb-open-type.hh        UnsizedArrayOf, ArrayOf,
                         HeadlessArrayOf, ArrayOfM1,
                         sorted-array-with-header, CFFIndex
  hb-ot-layout-common.hh CmapSubtableFormat-style,
                         VarRegionList, VarData, MultiVarData,
                         DeltaSetIndexMapFormat01
  hb-ot-hdmx-table.hh    DeviceRecord, hdmx
  hb-ot-cff-common.hh    Charset0, Charset wrapper
  hb-ot-cff1-table.hh    Encoding, Charset wrapper
                         (also widened unsigned accumulator
                         to size_t)
  hb-ot-os2-table.hh     OS/2 (widened accumulator to size_t)
  hb-ot-var-common.hh    TupleVariationHeader,
                         TupleVariationData accumulator
  hb-ot-var-hvar-table.hh DeltaSetIndexMap
  hb-vector.hh           hb_vector_t::get_size

When saturation kicks in, check_range() and extend_size()
naturally reject the resulting value (SIZE_MAX truncated to
unsigned is UINT_MAX, far past any real blob; extend_size
already rejects sizes >= INT_MAX).

Assisted-by: Claude <noreply@anthropic.com>
2026-05-18 15:11:34 -06:00
Behdad Esfahbod fd0360d985 [gpu] Silence float-to-double promotion warnings in Metal demo
MTLClearColorMake takes doubles; cast bg[] floats explicitly to
avoid -Wdouble-promotion warnings.

Assisted-by: Claude <noreply@anthropic.com>
2026-05-18 15:30:45 +01:00
Dominik Röttsches 4321818220 Cross-platform clippy-friendly casts in FFI
Bindgen generates a std::os::raw::c_char as return type for
functions like hb_blob_get_data. Depending on platform/arch, this
can be an i8 or u8. In the Rust side code, receiving
the data, these are interpreted as u8. Perform the pointer
casts in a way that compiles without clippy warnings about
unnecessary casts when the c_char type was already u8.
2026-05-18 17:02:39 +03:00
Khaled Hosny 8d24ed6cd6 [arabic-pua] Fix mapping for isolated lam alef maksura ligature (#5985)
Correct the ArabicPUATraditional.txt entry for 0xF295 which should be
isolated not final form. Also enable 0xFC43 ligature so the ligature is
actually used.

Fixes https://github.com/harfbuzz/harfbuzz/issues/5984
2026-05-17 15:24:40 -06:00