Commit Graph
307 Commits
Author SHA1 Message Date
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
jfkthame 603ab95602 Return size_t rather than unsigned int from get_size() (#5915)
* [subset] Return size_t rather than unsigned from get_size() methods

It's possible some get_size() computations during serialization
may overflow 32-bit arithmetic.

(The result of get_size() is used as size_t when allocating via
hb_serialize_context_t::extend(), but if the return value was
declared as unsigned int, the value may have wrapped resulting
in under-allocation.)

* [subset] Use size_t when accumulating subset_data_size

* [graph] Use size_t (rather than signed int64_t) for vertex_len variables

* Use size_t for sanitize_closure_t::stride to avoid narrowing
2026-04-13 11:01:19 -06:00
Behdad Esfahbod 7433361337 [gpos] Guard cursive attachment reversal
Cursive attachment reversal clears the old child edge before
walking the existing chain and reinstalling reversed links.
If the chain distance does not stay in range for
attach_chain(), reinstalling the reversed edge can truncate
and leave a poisoned chain value.

Pass the buffer length into the reversal helper so it drops
out-of-bounds chains, and use a round-trip fit check before
storing the reversed distance. When the reversed distance does
not fit, leave the old edge detached instead of corrupting
the chain.

Testing: CCACHE_DISABLE=1 meson test -C build --print-errorlogs
Fixes https://issues.chromium.org/issues/496302307
Assisted-by: OpenAI Codex <codex@openai.com>
2026-03-26 14:14:57 -06:00
Behdad EsfahbodandClaude Opus 4.6 6a1c028a61 [buffer] Add hb_buffer_changed() (#5755)
* [buffer] Add hb_buffer_changed()

To be called by message callbacks if they modify buffer glyph indices,
to update internal caches (currently the buffer digest).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [buffer] Implement changed() callback and hook up to OT shaper.

* Only install buffer changed() callback if messaging enabled

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 09:16:54 -07:00
Behdad Esfahbod 120a38a55e [GDEF] Inline a function (#5701)
17% speedup in Duployan benchmark!
2026-01-05 15:52:54 -07:00
Behdad Esfahbod 18e46b1ae5 [GDEF] Speed up mark set filtering
Remove one bounds check.
2026-01-03 17:08:46 -07:00
Behdad Esfahbod 29a47dcd83 Enlarge MappingCache to 256 entries again
Matches HR.
2025-12-31 16:35:58 -07:00
Behdad Esfahbod 1c3633e121 [GDEF] Use set-digest, not bit-set, for mark coverages again
This seems to be slightly faster, more memory efficient, and
matches HarfRust.
2025-12-31 15:56:43 -07:00
Behdad Esfahbod a789943958 [binary-cache] Enlarge to 256 entries
2% speedup in NotoNastaliqUrdu benchmark.
2025-12-30 12:15:12 -07:00
Behdad Esfahbod c48fa2fa4d [ligature] Adjust fast path to be in sync with contextuals
Shouldn't have any observable difference.
2025-12-20 18:29:28 -07:00
Behdad Esfahbod d15bc8d4e9 [contextual] Use a binary coverage cache (in format2)
Reduces cache size by half.

Since we discard the actual coverage number anyway.
2025-12-20 17:08:48 -07:00
Behdad Esfahbod f9971108eb [contextual] Add coverage cache for format2
5% speedup in NotoNastaliq benchmark.
2025-12-20 16:53:20 -07:00
Behdad Esfahbod d9e3b4efed Fix a compiler warning / error 2025-11-25 18:00:39 -07:00
Behdad Esfahbod 346b8dcf93 Wrap formats in struct
Part of https://github.com/harfbuzz/harfbuzz/issues/5601

This was done automatically using codex, the ChatGPT coding
agent.
2025-11-11 12:29:06 -07:00
Behdad Esfahbod 2bcce37ffd [Coverage] Wrap format in a struct
Part of https://github.com/harfbuzz/harfbuzz/issues/5601
2025-11-11 02:24:50 -07:00
Behdad Esfahbod 844f2fea06 [GPOS] Handle attach_chain() overflow (#5636)
Fixes https://oss-fuzz.com/testcase-detail/5461871294742528
2025-11-03 20:28:54 -07:00
Garret Rieger 07ee609f5a Fix invalid pointer conversions in graph Coverage. (#5622)
For #5604.
2025-10-20 20:06:43 -06:00
Behdad Esfahbod 4a26e289f7 Add hb_ot_layout_lookup_collect_glyph_alternates() (#5367)
* [map] Massage operator << overloads

* [ot-layout] Add +hb_ot_layout_lookup_collect_glyph_alternates

To collect all glyph mapping from SingleSubst or AlternateSubst
lookups in one call.  Needed by FreeType autohinter for performance.

New API:
+hb_ot_layout_lookup_collect_glyph_alternates()

* [layout] Change hb_ot_layout_lookup_collect_glyph_alternates() API

https://github.com/harfbuzz/harfbuzz/pull/5367#discussion_r2149019638
2025-09-30 13:31:04 -06:00
Behdad Esfahbod af286b8f71 [Coverage] Simplify initialization 2025-09-30 13:00:36 -06:00
Behdad Esfahbod fc7617251a [ValueFormat] comment 2025-09-24 12:42:53 -06:00
Behdad Esfahbod d350cb833a Speed up ValueFormat len() calc 2025-09-23 20:34:13 -06:00
Behdad Esfahbod a89c36e0d9 [GPOS/kerx] Support attaching marks to bases after them (#5520)
See comments. Fuzzer found. I'm surprised this was not discovered
before though. I hope I have not missed anything.

Fixes https://oss-fuzz.com/testcase-detail/6399443634290688
2025-09-02 13:05:11 -06:00
Behdad Esfahbod c61a4f26a0 [GPOS] Micro-optimize offset propagation 2025-08-29 02:11:52 -06:00
Behdad Esfahbod bc6eba9407 Fix kerx attachment shaping issues (#5515)
* [ot-shape] Don't zero offsets of default-ignorables

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/5514

* [ot-shape] Propagate chain offsets in opposite direction if RTL

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/5514
2025-08-27 13:29:15 -06:00
Behdad Esfahbod 6b62d3678b [ligature-cache] Handle case of ligature with no components (#5500)
In the cache with "seconds" set-digest.
2025-08-25 14:02:59 -06:00
Behdad Esfahbod 8bdedb3b9e Limit external caches (#5483)
* Revert "[external_cache] Remove a conditional (#5471)"

This reverts commit 9794ad9e00.

* Limit external_cache to 8 subtables per lookup
2025-08-20 00:27:41 -06:00
Behdad Esfahbod 2254574384 Match positions no malloc (#5481)
* Reduce allocation of match_positions by caching one in ctx

* Use a stack-array for small match-positions

This surgically enables stack-backed storage in vector.

* Handle match-positions alloc failure

And make allocations unchecked.

* Clean up CFF hack to use static storage in vector

* Fixup for match_positions allocations

* Fix vector handling of foreign arrays memory management
2025-08-20 00:06:00 -06:00
Behdad Esfahbod 9794ad9e00 [external_cache] Remove a conditional (#5471) 2025-08-16 15:51:05 -06:00
Behdad Esfahbod 368598b5bd Increase match_positions stack allocation from 4 to 8 (#5468)
Slight speedup on NotoNastaliq.
2025-08-16 00:38:42 -06:00
Behdad Esfahbod dae2c8bbbd [ligature] Add a set-digest on the second component (#5464) 2025-08-14 22:26:40 -06:00
Behdad Esfahbod 8268473a02 Add external_cache_create separate from cache_func (#5463)
* Add external_cache_create separate from cache_func

* Simplify cache_func_t signature

* Rename a cache type

* Rename another cache type
2025-08-14 21:57:19 -06:00
Behdad Esfahbod cf614fc85d [LigatureSet] Use slow path only if <= 1 ligatures (#5462) 2025-08-14 16:23:45 -06:00
Behdad Esfahbod 4aa7dcba0e [Coverage cache] Micro-optimize 2025-08-12 03:18:38 -06:00
Behdad Esfahbod a4dbb7d459 [Coverage] Cache NOT_COVERED effectively (#5453)
Before, our cache.set was always failing for NOT_COVERED,
making the cache ineffective for uncovered glyphs. Fix that.

Some nice speedups in Latin fonts.
2025-08-12 02:34:49 -06:00
Behdad Esfahbod 6ec1b2790c [lookup] Give each subtable an external-cache opportunity (#5449)
* [lookup] Give each subtable an external-cache opportunity

* [subtable-cache] Fixups
2025-08-11 01:14:19 -06:00
Qunxin Liu cd49b14b4f [subset] add more aggressive pruning for MarkLigPos and MarkMarkPos (#5434)
Remove lig/mark glyphs without defined anchor points after subsetting
2025-07-29 15:32:26 -06:00
Behdad Esfahbod 11daf566a3 [GDEF] Rename a var 2025-07-26 06:35:20 -06:00
Behdad Esfahbod 7b56d3a1e5 [ot-layout] s/hb_ot_lookup_cache_t/hb_ot_layout_mapping_cache_t/g 2025-07-26 06:29:10 -06:00
Behdad Esfahbod 09978fc510 [ot] Rename hb_ot_lookup_cache_op_t, and cache to subtable_cache 2025-07-26 06:29:10 -06:00
Behdad Esfahbod 786f8381bd [GDEF] Use bit-set instead of set-digest for mark glyph classes
Most fonts don't even have these. Some, like NotoSansDuployan
have huge ones. This speeds it up by 25%.
2025-07-25 04:00:37 -06:00
Qunxin Liu 879c4ac784 [subset] MarkBasePos: remove base glyphs with empty base record
BaseRecord could become empty if all anchor offsets for retained mark
classes are null
2025-07-24 14:25:54 -07:00
Behdad Esfahbod 3d154bc6b2 [buffer-message] Fix potential buffer overflow...
...when buffer messaging is enabled and with malicious font.

Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-p965-5rr7-9mhq
2025-07-14 13:54:49 -06:00
Qunxin Liu 5dbb814164 [subset] AnchorFormat3: better check for when should downgrade to format1 2025-07-14 10:54:43 -06:00
Behdad Esfahbod 6ed598e1c0 Merge pull request #5382 from harfbuzz/lig_split
[repacker] Implement table splitting for LigatureSubst
2025-07-10 13:03:44 -06:00
Qunxin Liu 95dc11092f [subset] bug fix
Don't downgrade to format1 when subsetting
2025-07-10 12:25:10 -06:00
Garret Rieger 38ab13c67e [repacker] add support for splitting GSUB Ligature lookups. 2025-07-04 23:37:24 +00:00
Behdad Esfahbod 47089fe7a3 Big misc changes
- Make geometry types into templates taking float or double.
- Changes to paint() transform elimination.
- Add font->has_nonzero_coords and use it across.
- Extensions to avar processing for otherwise invalid mappings.
2025-06-08 13:43:27 +03:00
Behdad Esfahbod c124252df5 [algs] Add support for little-endian int types
As well as 64bit-int, and float types.

Add Align type.
2025-06-08 13:43:27 +03:00