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>
This commit is contained in:
Behdad EsfahbodandClaude Sonnet 4.6 authored and GitHub committed 2026-02-20 11:25:24 -07:00
1 parent 821b375331
commit 63fb2eec90
8 files changed
+58 -34

No files matched your search

+11 -1
View File
@@ -1,7 +1,17 @@
# Our cluster-level=3 doesn't really test anything here.
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=3;U+0078,U+030A,U+0058,U+030A;[gid2=0+1083|gid3=1@-1132,-8+0|gid1=2+1200|gid3=3@-1190,349+0]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=3;U+0078,U+030A,U+0058,U+030A;[gid2=0+1083|gid3=0@-1132,-8+0|gid1=2+1200|gid3=2@-1190,349+0]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=2;U+0078,U+030A,U+0058,U+030A;[gid2=0+1083|gid3=1@-1132,-8+0|gid1=2+1200|gid3=3@-1190,349+0]
../fonts/43ef465752be9af900745f72fe29cb853a1401a5.ttf;--cluster-level=1;U+05D4,U+05B7,U+05E9,U+05BC,U+05C1,U+05B8,U+05DE,U+05B4,U+05DD;[uni05DD=8+1359|uni05B4=7@111,0+0|uni05DE=6+1391|uni05B8=5+0|uni05BC=3+0|uni05C1=3+0|uni05E9=2+1451|uni05B7=1@28,0+0|uni05D4=0+1338]
../fonts/6f36d056bad6d478fc0bf7397bd52dc3bd197d5f.ttf;--cluster-level=1;U+099B,U+09CB,U+09C8,U+09C2,U+09CB,U+098C;[evowelsigninibeng=0+346|aivowelsignbeng=0+346|evowelsignbeng=0+346|chabeng=0+687|uuvowelsignlongbeng=0@-96,0+0|aavowelsignbeng=0+266|aavowelsignbeng=4+266|lvocalicbeng=5+639]
../fonts/fd07ea46e4d8368ada1776208c07fd596f727852.ttf;--cluster-level=1;U+0D4E,U+0D4D,U+200D;[uni0D4E=0+0|uni25CC=0+418|uni0D4D=0+0|space=0+0]
../fonts/c2d320136762887c43d245ecd2ffc2c0d57cfcb3.ttf;;U+0DAF,U+0DCF,U+0DAF;[dasinh=0+547|aavowelsignsinh=0+379|dasinh=2+532]
# https://github.com/harfbuzz/harfbuzz/issues/5750
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=0 --no-positions --no-glyph-names;U+0020,U+0E33;[0=0|0=0|0=0]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=1 --no-positions --no-glyph-names;U+0020,U+0E33;[0=0|0=1|0=1]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=2 --no-positions --no-glyph-names;U+0020,U+0E33;[0=0|0=1|0=1]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=3 --no-positions --no-glyph-names;U+0020,U+0E33;[0=0|0=0|0=0]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=0 --no-positions --no-glyph-names;U+0020,U+0E34,U+0E33;[0=0|0=0|0=0|0=0]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=1 --no-positions --no-glyph-names;U+0020,U+0E34,U+0E33;[0=0|0=1|0=1|0=1]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=2 --no-positions --no-glyph-names;U+0020,U+0E34,U+0E33;[0=0|0=2|0=1|0=2]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=3 --no-positions --no-glyph-names;U+0020,U+0E34,U+0E33;[0=0|0=0|0=0|0=0]