From b0391e5d8031e693a1ff72c62c61cff3e911537b Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 1 Mar 2026 10:59:44 +0900 Subject: [PATCH] a hack was added --- OTFbuild/opentype_features.py | 19 ++++++++++++++++--- .../gdx/TerrarumSansBitmap.kt | 7 +++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/OTFbuild/opentype_features.py b/OTFbuild/opentype_features.py index cdcbc71..225feb9 100644 --- a/OTFbuild/opentype_features.py +++ b/OTFbuild/opentype_features.py @@ -1197,7 +1197,7 @@ def _generate_psts_anusvara(glyphs, has, conjuncts): ) # Direct predecessor triggers - for cp in [0x093E, 0x0948, 0x094C, 0x094F]: + for cp in [0x093A, 0x093E, 0x0948, 0x094C, 0x094F]: if has(cp): body.append( f" sub {glyph_name(cp)}" @@ -1537,10 +1537,13 @@ def _generate_anusvara_gpos(glyphs, has): shift3_triggers = [cp for cp in [0x094F, SC.DEVANAGARI_RA_SUPER_COMPLEX] if has(cp)] # +2px triggers: uni0948, uni094C, simple reph - shift2_triggers = [cp for cp in [0x093A, 0x0948, 0x094C, SC.DEVANAGARI_RA_SUPER] + shift2_triggers = [cp for cp in [0x0948, 0x094C, SC.DEVANAGARI_RA_SUPER] if has(cp)] - if not shift3_triggers and not shift2_triggers: + shift2_up2_triggers = [cp for cp in [0x093A] + if has(cp)] + + if not shift3_triggers and not shift2_triggers and not shift2_up2_triggers: return "" lines = [] @@ -1550,6 +1553,11 @@ def _generate_anusvara_gpos(glyphs, has): lines.append(f" pos {glyph_name(anusvara_lower)} <100 0 0 0>;") lines.append(f"}} AnusvaraShift2;") + if shift2_up2_triggers: + lines.append(f"lookup AnusvaraShift2Up2 {{") + lines.append(f" pos {glyph_name(anusvara_lower)} <100 100 0 0>;") # float up by two pixels. This is a hack + lines.append(f"}} AnusvaraShift2Up2;") + if shift3_triggers: lines.append(f"lookup AnusvaraShift3 {{") lines.append(f" pos {glyph_name(anusvara_lower)} <150 0 0 0>;") @@ -1568,6 +1576,11 @@ def _generate_anusvara_gpos(glyphs, has): f" pos {glyph_name(cp)}" f" {glyph_name(anusvara_lower)}' lookup AnusvaraShift2;" ) + for cp in shift2_up2_triggers: + lines.append( + f" pos {glyph_name(cp)}" + f" {glyph_name(anusvara_lower)}' lookup AnusvaraShift2Up2;" + ) lines.append("} abvm;") return '\n'.join(lines) diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index 3726c6b..b6fd3ce 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -1258,8 +1258,11 @@ class TerrarumSansBitmap( val effectivePrev = if (hasReph) str.getOrElse(charIndex - 2) { -1 } else prev if (effectivePrev == 0x094F || hasComplexReph) { posXbuffer[charIndex] += 3 - } else if (effectivePrev in intArrayOf(0x093A, 0x0948, 0x094C) || hasSimpleReph) { + } else if (effectivePrev in intArrayOf(0x0948, 0x094C) || hasSimpleReph) { posXbuffer[charIndex] += 2 + } else if (effectivePrev == 0x093A) { + posXbuffer[charIndex] += 2 + posYbuffer[charIndex] += 2 // float up by two pixels. This is a hack } } @@ -1896,7 +1899,7 @@ class TerrarumSansBitmap( // 094E (prishthamatra) is reordered before the consonant cluster, // so scan backward to find it val hasPrishthamatra = (1..5).any { j -> seq4.getOrElse(i - j) { -1 } == 0x094E } - if (effectivePrev in intArrayOf(0x093E, 0x0948, 0x094C, 0x094F) || hasPrishthamatra || hasReph) { + if (effectivePrev in intArrayOf(0x093A, 0x093E, 0x0948, 0x094C, 0x094F) || hasPrishthamatra || hasReph) { seq4[i] = DEVANAGARI_ANUSVARA_LOWER } }