Commit Graph
2648 Commits
Author SHA1 Message Date
Behdad EsfahbodandClaude Sonnet 4.6 63fb2eec90 Monotone characters fixups (#5752)
* [buffer] Fix a typo and doc string

* [buffer] Add merge_grapheme_clusters / merge_out_grapheme_clusters

Cluster merges serve two distinct purposes that require different level
gates:

- Grapheme grouping: combining marks merged into their base cluster.
  Correct gate: IS_GRAPHEMES (levels 0 and 3).
  New functions: merge_grapheme_clusters / merge_out_grapheme_clusters.

- Monotonicity maintenance: clusters merged to prevent non-monotone
  output after ligature formation, reordering, etc.
  Correct gate: IS_MONOTONE (levels 0 and 1).
  Existing functions: merge_clusters / merge_out_clusters.

Previously both paths shared merge_clusters_impl's single IS_MONOTONE
gate, so GRAPHEMES (level 3) was incorrectly blocked from merging
grapheme clusters.  This also caused a regression in the Thai and
Hangul shapers for MONOTONE_CHARACTERS (level 1): when their explicit
== MONOTONE_GRAPHEMES call-site guards were removed in #5069, the
impls' IS_MONOTONE gate no longer protected them.

Gates are now in the inline wrappers in hb-buffer.hh; the _impl
functions are gate-free.  hb_form_clusters, CoreText grapheme
detection, and the Thai/Hangul shapers are updated to call the
grapheme-semantic variants.  Fixes #5750.

Fixes https://github.com/harfbuzz/harfbuzz/issues/5751
Fixes https://github.com/harfbuzz/harfbuzz/issues/5750

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

* [thai] Adjust grapheme merging logic

* [hangul] Tweak grapheme merging

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:25:24 -07:00
Behdad Esfahbod 78f11ed726 Update test results for previous commit 2026-02-16 16:20:33 -03:00
Khaled Hosny c763763662 [buffer-serialize] Fix calculating absolute offsets with partial range
Fixes https://github.com/harfbuzz/harfbuzz/issues/5743
2026-02-15 17:30:16 +02:00
Behdad Esfahbod 3a827474c0 Merge pull request #5735 from harfbuzz/hb-draw
Add `hb-draw`
2026-02-14 17:26:33 -07:00
Behdad EsfahbodandClaude Sonnet 4.5 49c1678b75 [test] Update draw tests after removing --quiet option
- Remove tests for --quiet/-q option
- Change --ned to --flat in remaining tests
- Remove expected output files for quiet tests

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 18:28:48 -03:00
Garret Rieger 07e48ef1f0 Fix two bugs in hb_set_is_subset().
1. If smaller set has empty pages the subset checking logic was incorrectly incrementing the larger page index after skipping the empty smaller page index.
2. The logic for is_subset() on mixed inverted/not inverted sets was wrong.
2026-02-13 15:06:01 -07:00
Behdad EsfahbodandClaude Opus 4.6 1c32b69fe3 [hb-draw] Fix color font scaling by creating upem_font from face directly
Creating upem_font as a sub-font of the main font (which has scale =
upem * 64 due to subpixel bits) caused the paint API to emit spurious
parent→child scale transforms. With precision=2 rounding, 1/64 rounds
to 0.02 and 0.02*64 = 1.28, destroying the mathematical cancellation
and making color glyphs ~1.6x too large.

Fix by creating upem_font directly from the face, eliminating the
parent-child relationship. Update expected test outputs accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad Esfahbod fe9a8de890 [hb-svg-compare] Try normalize paths to drop degenerate lineto's
Such that we can compare to both FreeType and Fontations.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod 77d3ed5e75 [hb-draw] Use 6 bits of subpixel
Helps hb-ft since that doesn't work in floats all through.
Other backends should be unaffected.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod fe58d1bd0d [hb-draw-compare] Fix sorting 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 8a5e9536e3 [hb-draw-compare] Simplify sharding; remove non-sharded path 2026-02-12 15:26:19 -07:00
Behdad Esfahbod abb15ee099 [hb-draw-compare] Implement multiprocessing for hb-svg-compare stage 2026-02-12 15:26:19 -07:00
Behdad Esfahbod aff053af24 [hb-draw-compare] Switch from hb-view to hb-draw
MASSIVE speedup!
2026-02-12 15:26:19 -07:00
Behdad Esfahbod 431502033b [draw/run-tests.py] Use batching 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 8121167f69 [draw/run-tests] Simplify 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 2caa4c22a5 [draw] Change conditional tests 2026-02-12 15:26:19 -07:00
Behdad Esfahbod e6346b63bf [draw] Add VARC tests 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 7bbc027e11 [test/draw] Add more tests / change naming 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 529043f033 [hb-draw] More tests 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 69a4f5f501 [hb-draw] Change subpixel bits to 0 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 008402dccf [hb-draw] Default to upem font size 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 0fd8261638 [test/draw] Change directory structure a bit 2026-02-12 15:26:19 -07:00
Behdad Esfahbod f035a1df87 [test/draw] Switch tests to U+XXXX notation instead of text 2026-02-12 15:26:19 -07:00
Behdad Esfahbod e91036cf0b [hb-draw-compare] Remove unused stuff 2026-02-12 15:26:19 -07:00
Behdad Esfahbod e5c227b49b [test] Restructure record-test.sh's a bit
Haven't reviewed, AI code.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod a4381db671 [test] Add draw/record-test.sh
Haven't reviewed. AI code.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod 32a8fd62e8 Move hb-draw-compare and hb-svg-compare to test/draw 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 8150eed010 [test] Start of a draw test suite 2026-02-12 15:26:19 -07:00
Qunxin Liu 7ed158f930 Fix fuzzer issue (#5741)
Fixes: https://oss-fuzz.com/testcase-detail/6406793692774400
2026-02-11 13:12:30 -07:00
Qunxin Liu e601560b77 fix fuzzer issue: https://oss-fuzz.com/testcase-detail/6005602106277888
Do not use pointers that may point outside of the allocated memory region
2026-01-23 11:44:39 -07:00
Behdad Esfahbod dc73849f56 [gvar] Fix padding size calcs (#5718)
The previous state of is_long_offset() is irrelevant here.

Fixes https://oss-fuzz.com/testcase-detail/5920156651159552
2026-01-22 18:08:51 -07:00
Qunxin Liu b17fa8ef39 Fix fuzzer found heap-use-after-free crash (#5717)
Fixes https://oss-fuzz.com/testcase-detail/6005602106277888
2026-01-21 14:42:29 -07:00
Qunxin Liu 1c0a3a14d3 [subset] fix padding in gvar table
Add necessary padding if original font is using long format and
subsetted font is using short format
2026-01-20 14:47:54 -08:00
Behdad Esfahbod bb7dbc25ec Fix some unused-var warnings under NDEBUG 2026-01-10 07:42:07 -07:00
Qunxin Liu cf31e7ac4e [instancer] support full instancing for avar2 (#5676) 2025-12-11 10:54:49 -07:00
Khaled Hosny 46bc4e95f9 [kbts] Update to version 2.0 2025-11-28 12:56:36 +02:00
Garret Rieger 09c14fa4f2 Fix fuzzer found memory leak. (#5643)
Fixes https://oss-fuzz.com/testcase-detail/6083012753424384
2025-11-14 02:27:35 -07:00
Behdad Esfahbod 33f8ee8efc [test] Add HarfBust tests 2025-11-10 02:55:44 -07:00
Behdad Esfahbod b11c14227f Match backtrack/lookahead per syllable (#5635)
* [match-backtrack] Fix syllable-setting logic

If accidentally backtrack_len() was equal idx, we were setting
syllable, even though we want to match backtrack, which shouldn't
match syllable.

I'm surprised how this was not exposed before.

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

* Always match backtrack per syllable

* Always match lookahead per syllable as well

* Add Indic test for per-syllable backtrack/lookahead matching
2025-11-04 13:49:52 -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
Khaled Hosny 6105bad187 Fix applying synthetic slight to glyph origins (#5629)
* Fix applying synthetic slight to glyph origins

The hb_font_t::get_glyph_[h/v]_origins() methods were applying all the
transformations to the first glyph in the buffer. This shows up for
vertical text only because h_origin callback is usually unset.

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

* Don’t apply slant to glyph origin

Per discussion in https://github.com/harfbuzz/harfbuzz/issues/5628#issuecomment-3459345504

* Disable only font functions that fail
2025-10-29 13:59:51 -06:00
Behdad Esfahbod f159600ccb Fix a draw fuzzer uninitialized-memory issue (#5615)
Fixes https://oss-fuzz.com/testcase-detail/5714890590584832
2025-10-17 19:49:40 -06:00
Harry Dalton 780b986659 [shape] Test fallback to kern table under different shapers
More specifically, this asserts that the `kern` table is avoided for
certain shapers, and that we avoid double-spacing in the presence of
`dist` for the same.
2025-10-17 16:26:21 -06:00
Khaled Hosny 189358e3d0 [test] Add test for harfrust#278 (#5610)
Add test case for https://github.com/harfbuzz/harfrust/pull/278
2025-10-14 20:06:26 -06:00
Qunxin Liu 0952bc0ac2 [subset] de-duplicate features (#5494) 2025-09-26 12:10:28 -04:00
Garret Rieger 54ab8f0df4 [repacker] make repacker object ids stable.
Prior to this change the object id for a vertex in the repacker graph is it's position in the topological ordering. As a result after each sorting the object ids change. This decouples the topological sorting from the object id assignments. A separate ordering list is retained. This simplifies handling around object ids which no longer needs to account for them shifting, and improves performance by eliminating the step of reassigned link object ids after each sort.
2025-09-15 16:34:44 -06:00
Behdad Esfahbod d6343fa3bf [instancer/varstore] Update test expectations 2025-09-13 13:38:47 -06:00
Garret Rieger aa58b43de4 [subset] Introduce HB_SUBSET_FLAGS_RETAIN_NUM_GLYPHS. (#5547)
Used in conjunction with retain gids, when set the num glyphs from the input font will be preserved. Empty glyphs will be inserted as necessary to maintain the num glyphs value. Put under experimental for now.
2025-09-12 14:24:41 -06:00
Behdad Esfahbod c9480db91b [instancer/varstore] Add a heuristic to speed up optimization 2025-09-12 12:51:26 -06:00
Garret Rieger 6dadd8461f Re-disable fonttools comparison for update_def_wght.tests 2025-09-12 12:38:22 -06:00