From 8a52fcfb9107ad4f6cf41992c834bc7a17ecc9bd Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 8 Mar 2026 00:32:42 +0900 Subject: [PATCH] tfw part of your code was full of hacks --- src/assets/cyrilic_extB_variable.tga | 2 +- src/assets/cyrilic_variable.tga | 2 +- src/assets/thai_variable.tga | 2 +- .../gdx/TerrarumSansBitmap.kt | 22 ++++++++----------- work_files/cyrilic_extB_variable.kra | 4 ++-- work_files/cyrilic_variable.psd | 4 ++-- work_files/thai_variable.psd | 4 ++-- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/assets/cyrilic_extB_variable.tga b/src/assets/cyrilic_extB_variable.tga index a02f816..8d3709f 100644 --- a/src/assets/cyrilic_extB_variable.tga +++ b/src/assets/cyrilic_extB_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4755fd5ae329c3a73f4c87b95c0159276e09373b6be2f1a3fbef2aec731d5e76 +oid sha256:af0590cae6d254a9ce5b2204e8d6596c57baa4b4760a6acd3d8e9a452348ca1f size 122898 diff --git a/src/assets/cyrilic_variable.tga b/src/assets/cyrilic_variable.tga index 476ecf3..a46f6cf 100755 --- a/src/assets/cyrilic_variable.tga +++ b/src/assets/cyrilic_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:240277216f20dea758ad6bc933b6caa60b8c449a15c292819976e27e3695de6c +oid sha256:c47b422c1a73eaf2fbf429d64905e070cfea5129bde90df01adf1955ae373945 size 389138 diff --git a/src/assets/thai_variable.tga b/src/assets/thai_variable.tga index 0fa454f..50a3760 100755 --- a/src/assets/thai_variable.tga +++ b/src/assets/thai_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5153ea9337af90d633b61bb7ddcbdf11066da4d1e26657765e0c3cb7fd19e73 +oid sha256:1089824eb6031c20999cb8d094d1a014a4c530772063f9a30a378bf507fd859a size 122898 diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index 336a3cc..79afc5b 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -1125,8 +1125,7 @@ class TerrarumSansBitmap( var nonDiacriticCounter = 0 // index of last instance of non-diacritic char var stackUpwardCounter = 0 // TODO separate stack counter for centre- and right aligned var stackDownwardCounter = 0 - var nudgeUpwardCounter = 0 - var nudgeDownwardCounter = 0 + var nudgeUpHighWater = 0 // tracks max nudgeY seen in current stack, so subsequent marks with lower nudge still clear the previous one val HALF_VAR_INIT = W_VAR_INIT.minus(1).div(2) @@ -1205,8 +1204,7 @@ class TerrarumSansBitmap( stackUpwardCounter = 0 stackDownwardCounter = 0 - nudgeUpwardCounter = 0 - nudgeDownwardCounter = 0 + nudgeUpHighWater = 0 } // FIXME HACK: using 0th diacritics' X-anchor pos as a type selector /*else if (thisProp.writeOnTop && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) { @@ -1286,12 +1284,12 @@ class TerrarumSansBitmap( // set Y pos according to diacritics position when (thisProp.stackWhere) { GlyphProps.STACK_DOWN -> { - posYbuffer[charIndex] = (-thisProp.nudgeY + H_DIACRITICS * stackDownwardCounter) * flipY.toSign() - thisProp.nudgeY - nudgeDownwardCounter + posYbuffer[charIndex] = (-thisProp.nudgeY + H_DIACRITICS * stackDownwardCounter) * flipY.toSign() - thisProp.nudgeY stackDownwardCounter++ - nudgeDownwardCounter -= thisProp.nudgeY } GlyphProps.STACK_UP -> { - posYbuffer[charIndex] = -thisProp.nudgeY + (-H_DIACRITICS * stackUpwardCounter + -thisProp.nudgeY) * flipY.toSign() + thisProp.nudgeY + nudgeUpwardCounter + val effectiveNudge = maxOf(thisProp.nudgeY, nudgeUpHighWater) + posYbuffer[charIndex] = -effectiveNudge + (-H_DIACRITICS * stackUpwardCounter + -effectiveNudge) * flipY.toSign() + effectiveNudge // shift down on lowercase if applicable if (lastNonDiacriticChar.isLowHeight()) { //dbgprn("AAARRRRHHHH for character ${thisChar.toHex()}") @@ -1303,18 +1301,17 @@ class TerrarumSansBitmap( posYbuffer[charIndex] += H_STACKUP_LOWERCASE_SHIFTDOWN * flipY.toSign() // if minus-assign doesn't work, try plus-assign } + nudgeUpHighWater = effectiveNudge stackUpwardCounter++ - nudgeUpwardCounter += thisProp.nudgeY // dbgprn("lastNonDiacriticChar: ${lastNonDiacriticChar.charInfo()}; stack counter: $stackUpwardCounter") } GlyphProps.STACK_UP_N_DOWN -> { posYbuffer[charIndex] = (-thisProp.nudgeY + H_DIACRITICS * stackDownwardCounter) * flipY.toSign() stackDownwardCounter++ - if (thisProp.nudgeY < 0) - nudgeDownwardCounter -= thisProp.nudgeY - posYbuffer[charIndex] = (-thisProp.nudgeY + -H_DIACRITICS * stackUpwardCounter) * flipY.toSign() + val effectiveNudge = maxOf(thisProp.nudgeY, nudgeUpHighWater) + posYbuffer[charIndex] = (-effectiveNudge + -H_DIACRITICS * stackUpwardCounter) * flipY.toSign() // shift down on lowercase if applicable if (lastNonDiacriticChar.isLowHeight()) { if (diacriticsType == GlyphProps.DIA_OVERLAY) @@ -1323,9 +1320,8 @@ class TerrarumSansBitmap( posYbuffer[charIndex] += H_STACKUP_LOWERCASE_SHIFTDOWN * flipY.toSign() // if minus-assign doesn't work, try plus-assign } + nudgeUpHighWater = effectiveNudge stackUpwardCounter++ - if (thisProp.nudgeY > 0) - nudgeUpwardCounter += thisProp.nudgeY } // for BEFORE_N_AFTER, do nothing in here } diff --git a/work_files/cyrilic_extB_variable.kra b/work_files/cyrilic_extB_variable.kra index b89fd7f..4c45d08 100644 --- a/work_files/cyrilic_extB_variable.kra +++ b/work_files/cyrilic_extB_variable.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb6b2b248f480a6921d0ad57597d565b3edc27b6a71e8673b70740c5441cbe42 -size 60189 +oid sha256:50160968f842996eb9e2fc1fea81a940a24b0e214717c56d03c2fce237caf5d3 +size 60549 diff --git a/work_files/cyrilic_variable.psd b/work_files/cyrilic_variable.psd index aeb2a6c..e266e20 100644 --- a/work_files/cyrilic_variable.psd +++ b/work_files/cyrilic_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f07b8ede1ce5b8f8cf58f2cc49d94c221a0d18ed5540d5248107c4edc4d45673 -size 419330 +oid sha256:58341e9621efad84fb8e113fe18f86265055e7fd37c3d090d90ec6695052c0a9 +size 419355 diff --git a/work_files/thai_variable.psd b/work_files/thai_variable.psd index caa466a..0e8cdc3 100644 --- a/work_files/thai_variable.psd +++ b/work_files/thai_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac471d449ff0edc837870e8049cd3994a20ab92d63288a56264ef208c9af0d69 -size 123044 +oid sha256:5336bf17d48deef761369027eb2e178ea5c6dced6436bac8854d4fae1a24bc42 +size 128955