diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84cba10..090c5b2 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,8 +87,9 @@ MSB for each word must be set to indicate the value is being used. -= NOTE =- -This encoding involves one HACK: using 0th diacritics' X-anchor pos as a type selector -This hack applies only when write-on-top bit is set. +The code has remnants of one old HACK: using 0th diacritics' X-anchor pos as a type selector +This hack applied only when write-on-top bit is set. Relevant codes are currently commented out instead of +being completely removed for future debugging. Interpretation: DIA_OVERLAY = 1 DIA_JOINER = 2 diff --git a/assets/typewriter/typewriter_ko_3set-390.tga b/assets/typewriter/typewriter_ko_3set-390.tga index f03c251..81f4729 100644 Binary files a/assets/typewriter/typewriter_ko_3set-390.tga and b/assets/typewriter/typewriter_ko_3set-390.tga differ diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index 2b0f727..43af856 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -906,7 +906,7 @@ class TerrarumSansBitmap( extraWidth = thisProp.nudgeX // NOTE: sign is flipped! } // FIXME HACK: using 0th diacritics' X-anchor pos as a type selector - else if (thisProp.writeOnTop && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) { + /*else if (thisProp.writeOnTop && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) { posXbuffer[charIndex] = when (itsProp.alignWhere) { GlyphProps.ALIGN_RIGHT -> posXbuffer[nonDiacriticCounter] + W_VAR_INIT + alignmentOffset @@ -916,7 +916,7 @@ class TerrarumSansBitmap( posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset } - } + }*/ else { // set X pos according to alignment information posXbuffer[charIndex] = when (thisProp.alignWhere) { @@ -1372,7 +1372,7 @@ class TerrarumSansBitmap( if (it.first.matches(maskL!!) && it.second.matches(maskR!!)) { val contraction = if (glyphProps[prevChar]?.isKernYtype == true || glyphProps[thisChar]?.isKernYtype == true) it.yy else it.bb - dbgprn("Kerning rule match #${index+1}: ${prevChar.toChar()}${thisChar.toChar()}, Rule:${it.first.s} ${it.second.s}; Contraction: $contraction") +// dbgprn("Kerning rule match #${index+1}: ${prevChar.toChar()}${thisChar.toChar()}, Rule:${it.first.s} ${it.second.s}; Contraction: $contraction") return -contraction } @@ -1380,71 +1380,6 @@ class TerrarumSansBitmap( return 0 } else 0 - /*else if (prevChar in lowHeightLetters) { - return if (thisChar in kernTees) kernTee // lh - T - else if (thisChar in kernYees) kernYee // lh - Y - else 0 - } - else if (prevChar in kernElls) { - return if (thisChar in kernTees) kernTee // L - T - else if (thisChar in kernVees) kernYee // L - V - else if (thisChar in kernYees) kernYee // L - Y - else 0 - } - else if (prevChar in kernTees) { - return if (thisChar in lowHeightLetters) kernTee // T - lh - else if (thisChar in kernJays) kernTee // T - J - else if (thisChar in kernAyes) kernYee // T - A - else if (thisChar in kernDees) kernTee // T - d - else 0 - } - else if (prevChar in kernYees) { - return if (thisChar in lowHeightLetters) kernYee // Y - lh - else if (thisChar in kernAyes) kernYee // Y - A - else if (thisChar in kernJays) kernYee // Y - J - else if (thisChar in kernDees) kernYee // Y - d - else 0 - } - else if (prevChar in kernAyes) { - return if (thisChar in kernVees) kernAV // A - V - else if (thisChar in kernTees) kernAV // A - T - else if (thisChar in kernYees) kernYee // A - Y - else 0 - } - else if (prevChar in kernVees) { - return if (thisChar in kernAyes) kernAV // V - A - else if (thisChar in kernJays) kernAV // V - J - else if (thisChar in kernDees) kernAV // V - d - else 0 - } - else if (prevChar in kernGammas) { - return if (thisChar in kernAyes) kernYee // Γ - Α - else if (thisChar in lowHeightLetters) kernTee // Γ - lh - else if (thisChar in kernJays) kernTee // Γ - J - else if (thisChar in kernDees) kernTee // Γ - d - else 0 - } - else if (prevChar in kernBees) { - return if (thisChar in kernTees) kernTee // b - T - else if (thisChar in kernYees) kernYee // b - Y - else 0 - } - else if (prevChar in kernLowVees) { - return if (thisChar in kernTees) kernTee - else if (thisChar in kernLowLambdas) kernAVlow - else 0 - } - else if (prevChar in kernLowLambdas) { - return if (thisChar in kernTees) kernTee - else if (thisChar in kernLowVees) kernAVlow - else 0 - } - else if (prevChar in slashes) { - return if (thisChar in kernDees || thisChar in lowHeightLetters) kernSlash // / - d - else if (thisChar in slashes) kernDoubleSlash - else 0 - } - else 0*/ } companion object { diff --git a/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt b/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt index 3ae328a..56f0de9 100644 --- a/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt +++ b/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt @@ -223,12 +223,12 @@ class TerrarumTypewriterBitmap( } val nudgingBits = pixmap.getPixel(codeStartX, codeStartY + 10).tagify() - val nudgeX = nudgingBits.ushr(16).toByte().toInt() // signed 8-bit int - val nudgeY = nudgingBits.ushr(8).toByte().toInt() // signed 8-bit int + val nudgeX = nudgingBits.ushr(24).toByte().toInt() // signed 8-bit int + val nudgeY = nudgingBits.ushr(16).toByte().toInt() // signed 8-bit int val diacriticsAnchors = (0..5).map { - val yPos = 11 + (it / 3) - val shift = (2 - (it % 3)) * 8 + val yPos = 11 + (it / 3) * 2 + val shift = (3 - (it % 3)) * 8 val yPixel = pixmap.getPixel(codeStartX, codeStartY + yPos).tagify() val xPixel = pixmap.getPixel(codeStartX, codeStartY + yPos + 1).tagify() val y = (yPixel ushr shift) and 127 @@ -239,14 +239,15 @@ class TerrarumTypewriterBitmap( DiacriticsAnchor(it, x, y, xUsed, yUsed) }.toTypedArray() - val alignWhere = (11..12).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y).and(255) != 0).toInt() shl y) } + val alignWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 15).and(255) != 0).toInt() shl y) } - val writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 13).and(255) != 0 + val writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17).and(255) != 0 - val stackWhere = (14..15).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y).and(255) != 0).toInt() shl y) } + val stackWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 18).and(255) != 0).toInt() shl y) } glyphProps[code] = GlyphProps(width, isLowHeight, nudgeX, nudgeY, diacriticsAnchors, alignWhere, writeOnTop, stackWhere, GlyphProps.DEFAULT_EXTINFO, hasKernData, isKernYtype, kerningMask) -// if (code < 256) dbgprn("${code.charInfo()} width: $width, tags: ${glyphProps[code]}") + +// if (nudgingBits != 0) println("${code.charInfo()} nudgeX=$nudgeX, nudgeY=$nudgeY, nudgingBits=0x${nudgingBits.toString(16)}") // extra info val extCount = glyphProps[code]?.requiredExtInfoCount() ?: 0 @@ -439,7 +440,7 @@ class TerrarumTypewriterBitmap( if (!thisProp.writeOnTop) { - posXbuffer[charIndex] = thisProp.nudgeX + + posXbuffer[charIndex] = -thisProp.nudgeX + when (itsProp.alignWhere) { GlyphProps.ALIGN_RIGHT -> posXbuffer[nonDiacriticCounter] + TerrarumSansBitmap.W_VAR_INIT + alignmentOffset + interchar + kerning + extraWidth @@ -453,7 +454,7 @@ class TerrarumTypewriterBitmap( stackUpwardCounter = 0 stackDownwardCounter = 0 - extraWidth = -thisProp.nudgeX // NOTE: sign is flipped! + extraWidth = thisProp.nudgeX // NOTE: sign is flipped! } else if (thisProp.writeOnTop && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) { posXbuffer[charIndex] = when (itsProp.alignWhere) { diff --git a/work_files/typewriter_input/typewriter_ko_3set-390.psd b/work_files/typewriter_input/typewriter_ko_3set-390.psd index 19eb62c..56dc9bc 100644 Binary files a/work_files/typewriter_input/typewriter_ko_3set-390.psd and b/work_files/typewriter_input/typewriter_ko_3set-390.psd differ