Commit Graph
202 Commits
Author SHA1 Message Date
Behdad Esfahbod f072bff4b0 [ot] Exercise GPOS lookup variations
Extend the lookup-variation fixture with a GDEF ItemVariationStore-backed
ConditionValue and a GPOS conditional positioning lookup. This covers
variation-index evaluation, GPOS shaping, and lookup collection while
reusing the existing partial-instancing checks.

Tested with the full Meson suite and OTS validation of the fixture.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 20:40:06 -06:00
Behdad Esfahbod 3f39e24e75 [subset] Partially instantiate lookup conditions
Reduce LookupVariationRecord conditions to false, true, or a residual
condition when axes are pinned or restricted.  Fold compound AND, OR,
and NOT conditions, remap value-condition variation indices, and emit a
constant condition when a surviving lookup becomes unconditional.

Extend the test font with a second axis and all condition formats so the
subset tests cover structural, full, and partial instancing behavior.

Tested with the full Meson test suite, targeted Clang HB_NO_VAR and GCC
builds, and OTS validation of the fixture.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:43:47 -06:00
Behdad Esfahbod 2c05df744c [ot] Support LookupVariationRecord shaping
Parse and sanitize the FeatureVariations 1.1 lookup-oriented records.
Resolve their effective lookup sets while constructing the shape-plan
key so cache entries remain exact without retaining raw coordinates.

Handle ADD_DEFAULT_LOOKUPS, multiple matching conditions, and the
interaction with version 1.0 feature substitutions.  Keep the existing
public FeatureVariations query API behavior unchanged.

Tested with the full Meson test suite.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:08:11 -06:00
Behdad Esfahbod db981a8baf [gsubgpos] Preserve concat hazards at end of input (#6238)
The RuleSet fast paths filtered out rules requiring another glyph when
the skipping iterator reached the end of the buffer. Unlike the normal
rule walk, that early return did not record the resulting
unsafe-to-concat range.

Keep the end-of-input optimization, but track filtered rules and mark
their concat hazard before returning. Cover both contextual and chained
contextual rule sets with a five-rule font that forces the fast paths.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-05 14:44:39 -06:00
Behdad Esfahbod 92e67ef19f [ot] Preserve pair-positioning and ligature concat hazards
A zero-valued PairPos record can select a different, non-zero record
if the second glyph changes, so keep the pair unsafe to concat even
when no positioning was applied.

Likewise, make the ligature second-glyph digest rejection report the
same hazard as the full ligature walk.

Tests: meson test -C build

Port of https://github.com/harfbuzz/harfrust/pull/465

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-04 19:55:47 -06:00
Dylan PulverandDylan Pulver 2688e6c579 [unicode] Treat U+180F FVS4 as Default_Ignorable (#6229)
U+180F MONGOLIAN FREE VARIATION SELECTOR FOUR was added in Unicode
14.0 and has Default_Ignorable_Code_Point=Yes, but
is_default_ignorable() only covered U+180B..180E, so FVS4 was never
hidden and leaked a .notdef into the output.

8c65442069 ("[Unicode 14] Handle U+180F FVS4") added the U+180F case
to _hb_glyph_info_set_unicode_props() and to the Arabic shaper, but
that branch sits inside "if (unicode->is_default_ignorable (u))", so
it has been unreachable since it was written.  Extending the range to
U+180B..180F makes it live.

U+180B..180F are all Default_Ignorable_Code_Point per
DerivedCoreProperties.txt, so the range stays contiguous.

Before, with a font with no Mongolian coverage:

  $ hb-shape Roboto-Regular.abc.ttf -u U+0061,U+180F
  [1=0+1114|0=0@-908,0+0]

Every other default ignorable (U+180B..180E, U+FE00, U+200B) on that
font shapes to [1=0+1114].  After the change U+180F matches them.

Added two cases to mongolian-variation-selector.tests, which already
covered FVS1, FVS2, FVS3 and MVS but not FVS4: U+180F, and U+1810
MONGOLIAN DIGIT ZERO to pin the top of the range so it cannot be
widened by accident.

Tested with "meson test -C build": 254/254 OK, 0 failures.  Restoring
the old U+180B..180E fails in-house 6174/6176, and widening it to
U+180B..1810 fails the same way.

Assisted-by: claude-opus-5

Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com>
2026-09-03 16:26:30 -06:00
Behdad Esfahbod ebdb43f4d9 [test] Add mort and morx text-rendering tests (#6206) 2026-08-24 14:54:55 -06:00
ff217d3039 [graphite2] Fix cluster values when the buffer was reversed (#6156)
When the requested direction differs from the script's horizontal
direction, the Graphite2 shaper reverses the buffer before segmenting.
Input cluster values then decrease along the buffer, so assigning each
Graphite group the cluster of its base character can leave earlier
characters outside the resulting cluster map.

Preserve the source span of every Graphite glyph while constructing the
output. At monotone cluster levels, seed each glyph from the minimum
endpoint of that span and use merge_clusters() over each Graphite output
range. Keep the historical base-character behavior at non-monotone
levels.

HarfBuzz cluster values are opaque client labels and can be repeated or
gapped. Merging them can therefore coalesce multiple Graphite layout
groups. Preserve the Graphite group index separately for positioning so
every group's advance is emitted even when its HarfBuzz cluster was
merged. Validate Graphite slot source bounds before indexing the input.

Add shape regressions using a subset of Awami Nastaliq and an API test
with repeated input clusters. The latter used to merge the output
clusters correctly but drop an entire layout-group advance, reducing
the total from 3200 to 1269.

Tested with:
meson test -C build test-graphite2
meson test -C build --suite shape
meson test -C build



Assisted-by: Codex <codex@openai.com>

Co-authored-by: Michael Brown <michael.brown@rubicotech.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 12:48:13 -06:00
Garret Rieger 49bf947b0a In text-rendering-tests/update.py escape test names sourced from https://github.com/OpenType/fonttest before putting them into meson.build. 2026-08-11 12:27:52 -06:00
Behdad Esfahbod c14ad7c6cb [aat] Fix insertion at end of text (#6142)
Insertion state machines may emit glyphs during the end-of-text transition, when the buffer has no current input glyph. Emit the glyph first in that case and apply AAT metadata to the new output glyph instead of buffer->cur().

Add a regression font whose end-of-text action inserts the AAT deleted-glyph sentinel.

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-08-09 12:37:15 -06:00
Khaled Hosny 6b6f0d9770 [GPOS] Apply mark-attachment cross-direction offsets immediately
Fixes https://github.com/harfbuzz/harfbuzz/issues/4596

See the issue for more details.

Instead of deferring mark positioning to the end of GPOS application, we
now apply cross-direction offsets (y-direction in horizontal text)
immediately and keep applying main-direction (x-direction in horizontal
text) as before.

This is still not 100% compatible with DirectWrite or Core Text (they
apply both directions immediately), but enough to fix the reported
issue.

Based on Behdad’s patch below, but fixes the Noto Nastaliq regression by
resolving the base offset through the whole cursive attachment chain
since cursive offsets are relative the previous glyph and get finalized
only at end of GPOS:
https://github.com/harfbuzz/harfbuzz/issues/4596#issuecomment-2276300688

The remaining failure is not a regression, the new expectation now match
DirectWrite and Core Text.

The tests include a subsetted bug font, as well as two constructed fonts
where curs lookup come before mark ones, once with kern before mark and
with kern after mark, to show that lookup order affects y but not
x-direction.
2026-07-30 23:27:22 +03:00
Khaled Hosny 6cc6d89e05 [GPOS] Count decomposed pieces as one ligature component
Non-first pieces of a MultipleSubst now add no extra component, so a
decomposed glyph absorbed into a ligature counts as the single component
it started as, and its marks attach where MarkBasePos would.

Part of https://github.com/harfbuzz/harfbuzz/issues/4969
2026-07-25 13:35:41 +03:00
Khaled Hosny a49431bcf9 [GPOS] Attach mark to first component of MultipleSubst in MarkLigPos
Do what MarkBasePos already does, so the backward search skips the
leftover pieces of a decomposition instead of giving up on them.

Fixes https://github.com/harfbuzz/harfbuzz/issues/4969
2026-07-25 13:35:28 +03:00
j0j1j2 72dfc30899 [hangul] Apply 'calt' feature to non-Hangul characters in Hangul runs (#6030) 2026-06-16 13:55:17 +02: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
David Corbett 27f1be922e [indic] Categorize U+1CF5 and U+1CF6 as CS (#5949) 2026-04-18 19:54:27 -06:00
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 e5c227b49b [test] Restructure record-test.sh's a bit
Haven't reviewed, AI code.
2026-02-12 15:26:19 -07:00
Khaled Hosny 46bc4e95f9 [kbts] Update to version 2.0 2025-11-28 12:56:36 +02: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
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
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
David Corbett e189b34ec9 [Unicode 17] Update the emoji table & cluster test 2025-09-10 11:19:14 -04:00
Behdad Esfahbod 2c22a65f0c [test] Add test for would_apply with multiple subtables
From HarfRust issue:
https://github.com/harfbuzz/harfrust/issues/118
2025-08-08 15:14:16 -06:00
Behdad Esfahbod 4f8193ceff [tests/vertical] Add test for previous commit 2025-07-26 13:06:45 -06:00
Khaled Hosny 16fe5422b6 [kbts] Add some tests 2025-07-23 21:39:23 +03:00
Behdad Esfahbod d47a319b82 [rust] Roll deps forward
Adjust tests. See:

https://github.com/harfbuzz/harfbuzz/issues/5388
2025-07-15 12:08:00 -06:00
Behdad Esfahbod 7278f8a20e [test/shape] Clean up meson
Fixes https://github.com/harfbuzz/harfbuzz/issues/5366
2025-06-14 11:02:37 -06:00
Behdad Esfahbod cc884606bc [test/shape] --safe-to-insert-tatweel
At some point we should switch to --show-flags.
For now, tests all pass regardless of this switch.
2025-06-06 21:39:03 -06:00
Behdad Esfahbod 7908e86e35 [util/test-shape] Only output one line per test
If a shape call was failing, perhaps because of --verify failing,
hb-shape was producing multiple lines possibly, making the test
runner get out of sync and fail all following tests.

https://github.com/harfbuzz/harfruzz/issues/60
2025-06-06 20:19:06 -06:00
Behdad Esfahbod 604056056c [test/shape] Move LucidaGrande test to macos.tests 2025-05-09 23:17:35 -06:00
Behdad Esfahbod 19a5d1aabd [test/shape] Only do unsafe-to-concat check for ot shaper
For now, to get harfRuzz testing going better.
2025-05-07 16:57:19 -06:00
Behdad Esfahbod 2f7fbeeea2 [test/shape] Allow specifying shaper / face-loader as env-vars 2025-05-07 13:42:56 -06:00
Behdad Esfahbod 21a67df4c9 [run-tests.py] Clean up file descriptors 2025-05-06 15:42:48 -06:00
Behdad Esfahbod e31721b5cf [test/shape] Write cmdline as test description 2025-04-06 21:41:09 -06:00
Behdad Esfahbod c60067c675 [test/subset] See if this fixes CI 2025-04-06 15:25:58 -06:00
Behdad Esfahbod 8456c33ac3 [test/shape] Respect @face-loaders directive 2025-04-06 14:33:44 -06:00
Behdad Esfahbod 1f1cbb64ee Merge pull request #5260 from harfbuzz/tap
Use TAP protocol for tests
2025-04-06 14:30:07 -06:00
Behdad Esfahbod 03f4230188 [mac] Add tests for --face-loader
https://github.com/harfbuzz/harfbuzz/issues/5142
2025-04-06 13:32:28 -06:00
Behdad Esfahbod 5a46872853 Add test for https://github.com/harfbuzz/harfbuzz/issues/5232 2025-04-06 13:32:28 -06:00
Behdad Esfahbod 5efdb884a5 [run-tests] Fix remaining bot fails, fingers crossed 2025-04-06 03:21:15 -06:00
Behdad Esfahbod 8132a6607f [shape/run-tests] Don't return non-zero
TAP protocol.
2025-04-06 03:12:38 -06:00
Behdad Esfahbod a530672f04 [meson.build] Don't use str.replace() method
Too recent.
2025-04-06 02:34:48 -06:00
Behdad Esfahbod b01cea95e1 [meson] Cosmetic 2025-04-06 02:34:48 -06:00
Behdad Esfahbod ee50fad676 [run-tests] black 2025-04-06 02:34:48 -06:00
Behdad Esfahbod 69fd949014 [test/shape] Run using TAP protocol
Run all tests for a suite in one process. Saves runtime from
3s to 2s.
2025-04-06 02:34:48 -06:00
Behdad Esfahbod 2834900d92 [test/shape] Run each test suite in one process 2025-04-06 02:34:48 -06:00
Behdad Esfahbod c523f9ac13 [test/shape] Use TAP
Checkpoint.
2025-04-06 02:34:48 -06:00