diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 090c5b2..e76ee98 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ Rightmost vertical column (should be 20 px tall) contains the tags. Tags are def X -' A -,_ 0 Align 1 Align 0 Align 1 Align before A -' 0 left 0 right 1 centre 1 the glyph - D --write-on-top, usually it's diatritics but not always (e.g. devanagari vowel sign O) + D --Diacritics Type Bit (see below; not all diacritics are marked as one on the spritesheet) S -,_ 0 Stack 1 Stack 0 Before 1 Up & (MSB) S -' 0 up 0 down 1 &After 1 Down (e.g. U+0C48) @@ -66,10 +66,10 @@ TODO: c - Nudging Y - Anchor point Y for undefined, undefined, undefined X - Anchor point X for undefined, undefined, undefined -Y - Anchor point Y for centre-aligned diacritics, undefined, undefined -X - Anchor point X for centre-aligned diacritics, undefined, undefined +Y - Anchor point Y for (unused), undefined, undefined +X - Anchor point X for Type-0 (centre-aligned) diacritics, undefined, undefined -* Nudging Bits encoding: +* Nudging Bits Encoding: SXXXXXXX SYYYYYYY 00000000 @@ -83,7 +83,15 @@ Y-positive: nudges towards up 1X1X1X1X 1X2X2X2X 1X3X3X3X where Red is first, Green is second, Blue is the third diacritics. -MSB for each word must be set to indicate the value is being used. +MSB for each word must be set so that the pixel would appear brighter on the image editor. +(the font program will only read low 7 bits for each RGB channel) + +* Diacritics Type Bit Encoding: + + FFFFFFFF FFFFFFFF FFFFFFFF (For Type-0) + TTTT0000 00000000 00000000 (For Type-1 to Type-15) + +Right now, only the type-0 diacritics and its anchor point is used by the font. -= NOTE =- @@ -94,9 +102,6 @@ Interpretation: DIA_OVERLAY = 1 DIA_JOINER = 2 -Right now, only the type-0 diacritics anchor point is used by the font. - -TODO: use D-bit to give each diacritic a type ``` diff --git a/assets/ascii_variable.tga b/assets/ascii_variable.tga index 0d99d8b..6fc930e 100755 Binary files a/assets/ascii_variable.tga and b/assets/ascii_variable.tga differ diff --git a/assets/devanagari_bengali_variable.tga b/assets/devanagari_bengali_variable.tga index 7b9a7cd..083b632 100755 Binary files a/assets/devanagari_bengali_variable.tga and b/assets/devanagari_bengali_variable.tga differ diff --git a/assets/diacritical_marks_variable.tga b/assets/diacritical_marks_variable.tga index 9bcb325..36d06d9 100755 Binary files a/assets/diacritical_marks_variable.tga and b/assets/diacritical_marks_variable.tga differ diff --git a/assets/latinExtD_variable.tga b/assets/latinExtD_variable.tga index aaddc35..f9e9990 100644 Binary files a/assets/latinExtD_variable.tga and b/assets/latinExtD_variable.tga differ diff --git a/assets/thai_variable.tga b/assets/thai_variable.tga index 7d051b6..b432f0b 100755 Binary files a/assets/thai_variable.tga and b/assets/thai_variable.tga differ diff --git a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt index dac1b8b..7ce8e74 100755 --- a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt +++ b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt @@ -19,7 +19,7 @@ data class GlyphProps( val alignWhere: Int = 0, // ALIGN_LEFT..ALIGN_BEFORE - val writeOnTop: Boolean = false, + val writeOnTop: Int = -1, // -1: false, 0: Type-0, 1: Type-1, etc; val stackWhere: Int = 0, // STACK_UP..STACK_UP_N_DOWN diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index 43af856..c3e8fc1 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -751,13 +751,19 @@ class TerrarumSansBitmap( 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 + 17).and(255) != 0 + var writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17) // NO .tagify() + if (writeOnTop and 255 == 0) writeOnTop = -1 + else { + writeOnTop = writeOnTop.ushr(8) + if (writeOnTop == 0xFFFFFF) writeOnTop = 0 + } 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 (nudgingBits != 0) dbgprn("${code.charInfo()} nudgeX=$nudgeX, nudgeY=$nudgeY, nudgingBits=0x${nudgingBits.toString(16)}") +// if (writeOnTop >= 0) dbgprn("WriteOnTop: ${code.charInfo()} (Type-${writeOnTop})") // extra info val extCount = glyphProps[code]?.requiredExtInfoCount() ?: 0 @@ -888,7 +894,7 @@ class TerrarumSansBitmap( if (isHangul(thisChar) && !isHangulChoseong(thisChar) && !isHangulCompat(thisChar)) { posXbuffer[charIndex] = posXbuffer[nonDiacriticCounter] } - else if (!thisProp.writeOnTop) { + else if (thisProp.writeOnTop < 0) { posXbuffer[charIndex] = -thisProp.nudgeX + when (itsProp.alignWhere) { GlyphProps.ALIGN_RIGHT -> @@ -982,7 +988,7 @@ class TerrarumSansBitmap( (if (errorOnUnknownChar) throw throw InternalError("No GlyphProps for char '${str[nonDiacriticCounter]}' " + "(${str[nonDiacriticCounter].charInfo()})") else nullProp) posXbuffer[posXbuffer.lastIndex] = 1 + posXbuffer[posXbuffer.lastIndex - 1] + // adding 1 to house the shadow - if (lastCharProp?.writeOnTop == true) { + if (lastCharProp != null && lastCharProp.writeOnTop >= 0) { val realDiacriticWidth = if (lastCharProp.alignWhere == GlyphProps.ALIGN_CENTRE) { (lastCharProp.width).div(2) + penultCharProp.diacriticsAnchors[0].x } @@ -1088,7 +1094,7 @@ class TerrarumSansBitmap( } // for lowercase i and j, if cNext is a diacritic that goes on top, remove the dots - else if (diacriticDotRemoval.containsKey(c) && glyphProps[cNext]?.writeOnTop == true && glyphProps[cNext]?.stackWhere == GlyphProps.STACK_UP) { + else if (diacriticDotRemoval.containsKey(c) && (glyphProps[cNext]?.writeOnTop ?: -1) >= 0 && glyphProps[cNext]?.stackWhere == GlyphProps.STACK_UP) { seq.add(diacriticDotRemoval[c]!!) } // rearrange {letter, before-and-after diacritics} as {letter, before-diacritics, after-diacritics} diff --git a/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt b/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt index 56f0de9..22f1dc1 100644 --- a/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt +++ b/src/net/torvald/terrarumtypewriterbitmap/gdx/TerrarumTypewriterBitmap.kt @@ -241,7 +241,9 @@ class TerrarumTypewriterBitmap( 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 + 17).and(255) != 0 + var writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17).tagify() + if (writeOnTop == 0) writeOnTop = -1 + else if (writeOnTop == 0xFFFFFF) writeOnTop = 0 val stackWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 18).and(255) != 0).toInt() shl y) } @@ -439,7 +441,7 @@ class TerrarumTypewriterBitmap( } - if (!thisProp.writeOnTop) { + if (thisProp.writeOnTop < 0) { posXbuffer[charIndex] = -thisProp.nudgeX + when (itsProp.alignWhere) { GlyphProps.ALIGN_RIGHT -> @@ -456,7 +458,7 @@ class TerrarumTypewriterBitmap( stackDownwardCounter = 0 extraWidth = thisProp.nudgeX // NOTE: sign is flipped! } - else if (thisProp.writeOnTop && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) { + /*else if (thisProp.writeOnTop >= 0 && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) { posXbuffer[charIndex] = when (itsProp.alignWhere) { GlyphProps.ALIGN_RIGHT -> posXbuffer[nonDiacriticCounter] + TerrarumSansBitmap.W_VAR_INIT + alignmentOffset @@ -466,7 +468,7 @@ class TerrarumTypewriterBitmap( posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset } - } + }*/ else { // set X pos according to alignment information posXbuffer[charIndex] = when (thisProp.alignWhere) { @@ -530,7 +532,7 @@ class TerrarumTypewriterBitmap( val lastCharProp = glyphProps[str.last()] val penultCharProp = glyphProps[str[nonDiacriticCounter]]!! posXbuffer[posXbuffer.lastIndex] = 1 + posXbuffer[posXbuffer.lastIndex - 1] + // adding 1 to house the shadow - if (lastCharProp?.writeOnTop == true) { + if (lastCharProp != null && lastCharProp.writeOnTop >= 0) { val realDiacriticWidth = if (lastCharProp.alignWhere == GlyphProps.ALIGN_CENTRE) { (lastCharProp.width).div(2) + penultCharProp.diacriticsAnchors[0].x } diff --git a/work_files/ascii_variable.psd b/work_files/ascii_variable.psd index db433c4..a8582f9 100644 Binary files a/work_files/ascii_variable.psd and b/work_files/ascii_variable.psd differ diff --git a/work_files/devanagari_bengali_variable.psd b/work_files/devanagari_bengali_variable.psd index 918d41b..bdb5d78 100644 Binary files a/work_files/devanagari_bengali_variable.psd and b/work_files/devanagari_bengali_variable.psd differ diff --git a/work_files/diacritical_marks_variable.psd b/work_files/diacritical_marks_variable.psd index 784ef18..4bec8ee 100644 Binary files a/work_files/diacritical_marks_variable.psd and b/work_files/diacritical_marks_variable.psd differ diff --git a/work_files/latinExtD_variable.psd b/work_files/latinExtD_variable.psd index ebf97f0..9d1577c 100644 Binary files a/work_files/latinExtD_variable.psd and b/work_files/latinExtD_variable.psd differ diff --git a/work_files/thai_variable.psd b/work_files/thai_variable.psd index adf3c92..015c743 100644 Binary files a/work_files/thai_variable.psd and b/work_files/thai_variable.psd differ