[hangul] Apply 'calt' feature to non-Hangul characters in Hangul runs (#6030)

This commit is contained in:
j0j1j2 authored and GitHub committed 2026-06-16 13:55:17 +02:00
1 parent 9c7f4dffe5
commit 72dfc30899
4 files changed
+27 -3

No files matched your search

+21 -3
View File
@@ -67,14 +67,23 @@ static void
override_features_hangul (hb_ot_shape_planner_t *plan)
{
/* Uniscribe does not apply 'calt' for Hangul, and certain fonts
* (Noto Sans CJK, Source Sans Han, etc) apply all of jamo lookups
* in calt, which is not desirable. */
plan->map.disable_feature (HB_TAG('c','a','l','t'));
* (Noto Sans CJK, Source Han Sans, etc) apply all of jamo lookups
* in calt, which is not desirable.
*
* Rather than disabling 'calt' for the entire run, which also turns
* it off for any other characters in the run, allocate a mask for it
* and clear that mask on jamo only (in setup_masks_hangul). That
* keeps jamo out of reach of such lookups while letting the rest of
* the run shape with 'calt' as usual.
*
* https://github.com/harfbuzz/harfbuzz/discussions/4853 */
plan->map.add_feature (HB_TAG('c','a','l','t'));
}
struct hangul_shape_plan_t
{
hb_mask_t mask_array[HANGUL_FEATURE_COUNT];
hb_mask_t calt_mask;
};
static void *
@@ -87,6 +96,8 @@ data_create_hangul (const hb_ot_shape_plan_t *plan)
for (unsigned int i = 0; i < HANGUL_FEATURE_COUNT; i++)
hangul_plan->mask_array[i] = plan->map.get_1_mask (hangul_features[i]);
hangul_plan->calt_mask = plan->map.get_1_mask (HB_TAG('c','a','l','t'));
return hangul_plan;
}
@@ -405,7 +416,14 @@ setup_masks_hangul (const hb_ot_shape_plan_t *plan,
unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info;
for (unsigned int i = 0; i < count; i++, info++)
{
info->mask |= hangul_plan->mask_array[info->hangul_shaping_feature()];
/* Keep 'calt' away from jamo; see override_features_hangul(). */
hb_codepoint_t u = info->codepoint;
if (isL (u) || isV (u) || isT (u))
info->mask &= ~hangul_plan->calt_mask;
}
}
HB_BUFFER_DEALLOCATE_VAR (buffer, hangul_shaping_feature);
+1
View File
@@ -22,6 +22,7 @@ in_house_tests = [
'emoji-clusters.tests',
'fallback-positioning.tests',
'glyph-props-no-gdef.tests',
'hangul-calt.tests',
'hangul-jamo.tests',
'harfbust.tests',
'hebrew-diacritics.tests',
@@ -0,0 +1,5 @@
../fonts/600387433d01cd5799e421dad6510a54c862f56b.ttf;;U+AC00,U+003D,U+003E;[ga=0+600|eq_gt.calt=1+600]
../fonts/600387433d01cd5799e421dad6510a54c862f56b.ttf;;U+AC00,U+B098;[ga_na.calt=0+600]
../fonts/600387433d01cd5799e421dad6510a54c862f56b.ttf;;U+1100,U+1100;[jamoL=0+600|jamoL=1+600]
../fonts/600387433d01cd5799e421dad6510a54c862f56b.ttf;;U+B098,U+B098;[na_na.liga=0+600]
../fonts/600387433d01cd5799e421dad6510a54c862f56b.ttf;--features=calt=0;U+AC00,U+003D,U+003E;[ga=0+600|equal=1+600|greater=2+600]