diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 18f8e48..a7e83a3 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,12 +57,15 @@ Rightmost vertical column (should be 20 px tall) contains the tags. Tags are def Y |= Diacritics Anchor Points (see below) X -' A -,_ 0 Align 1 Align 0 Align 1 Align before - A -' 0 Left 0 Right 1 Centre* 1 the glyph + A -' 0 Left 0 Right 1 Centre 1 the glyph D --Diacritics Type Bit (see below; not all diacritics are actually marked as a diacritics 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) -Align Centre is actually "align to where the anchor point is". Said anchor point default to the X-centre of the glyph. +Align Centre and Align Right will respect the diacritics anchor points. +The Align Right AND Custom anchor point is being used for Thai diacritics. +When a width AND diacritics type bit is set, the entire glyph is shifted to the right as specified and the space of same width will be inserted. +(See SUNDANESE PAMINGKAL U+1BA1) Up&Down: 1. when two pixels are both #00FF00 it's "don't stack" diff --git a/assets/sundanese_variable.tga b/assets/sundanese_variable.tga index b30b756..9703fc0 100644 --- a/assets/sundanese_variable.tga +++ b/assets/sundanese_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7c6dd7d71404c8d528038fcdefd254b08097f5e50db9d863f2eab8aa52ffdbd3 +oid sha256:04804fb9386a09f3631954c60e5f3518e36fece773208ea02b319a26ba1a8c72 size 122898 diff --git a/assets/thai_variable.tga b/assets/thai_variable.tga index 590787a..0fa454f 100755 --- a/assets/thai_variable.tga +++ b/assets/thai_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ceb3411baa2b6aabb7a2de2404abed96082b057a72ae5d98632c062fdb0c3dd6 +oid sha256:c5153ea9337af90d633b61bb7ddcbdf11066da4d1e26657765e0c3cb7fd19e73 size 122898 diff --git a/demo.PNG b/demo.PNG index 73fe8e8..d8d0cef 100644 Binary files a/demo.PNG and b/demo.PNG differ diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index c275e6a..fbdfe90 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -333,10 +333,7 @@ class TerrarumSansBitmap( // If the line starts with a letter-with-diacritic, it will error out // Some diacritics (e.g. COMBINING TILDE) do not obey lowercase letters val charSeqNotBlank = codepoints.size > 0 // determine emptiness BEFORE you hack a null chars in - val newCodepoints = CodepointSequence() - newCodepoints.add(0) - newCodepoints.addAll(codepoints) - newCodepoints.add(0) + val newCodepoints = codepoints fun Int.flipY() = this * if (flipY) 1 else -1 @@ -657,7 +654,8 @@ class TerrarumSansBitmap( // if (directiveOpcode != 0) dbgprn("Directive opcode ${directiveOpcode.toString(2)}: ${code.charInfo()}") // if (glyphProps[code]?.isPragma("replacewith") == true) dbgprn("Replacer: ${code.charInfo()} into ${glyphProps[code]!!.extInfo.map { it.toString(16) }.joinToString()}") // if (stackWhere == GlyphProps.STACK_DONT) dbgprn("Diacritics Don't stack: ${code.charInfo()}") - if (stackWhere == GlyphProps.STACK_DOWN) dbgprn("Diacritics stack down: ${code.charInfo()}") +// if (stackWhere == GlyphProps.STACK_DOWN) dbgprn("Diacritics stack down: ${code.charInfo()}") +// if (writeOnTop > -1 && alignWhere == GlyphProps.ALIGN_RIGHT && width > 0) dbgprn("Diacritics aligned to the right with width of $width: ${code.charInfo()}") } } @@ -788,10 +786,10 @@ class TerrarumSansBitmap( posYbuffer[charIndex] = -thisProp.nudgeY nonDiacriticCounter = charIndex + extraWidth = thisProp.nudgeX // This resets extraWidth. NOTE: sign is flipped! stackUpwardCounter = 0 stackDownwardCounter = 0 - extraWidth = thisProp.nudgeX // This resets extraWidth. 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) { @@ -813,10 +811,13 @@ class TerrarumSansBitmap( when (thisProp.alignWhere) { GlyphProps.ALIGN_LEFT, GlyphProps.ALIGN_BEFORE -> posXbuffer[nonDiacriticCounter] GlyphProps.ALIGN_RIGHT -> { - println("thisprop alignright $kerning, $extraWidth") +// println("thisprop alignright $kerning, $extraWidth") + + val anchorPoint = + if (!itsProp.diacriticsAnchors[diacriticsType].xUsed) itsProp.width else itsProp.diacriticsAnchors[diacriticsType].x extraWidth += thisProp.width - posXbuffer[nonDiacriticCounter]+ kerning + extraWidth - thisProp.width + posXbuffer[nonDiacriticCounter] + anchorPoint - W_VAR_INIT + kerning + extraWidth } GlyphProps.ALIGN_CENTRE -> { val anchorPoint = @@ -964,7 +965,7 @@ class TerrarumSansBitmap( val c = dis[i] val cNext = dis.getOrElse(i+1) { -1 } - // turn Unicode Devanagari consonants into the internal one + // turn Unicode Devanagari consonants into the internal counterpart if (c in 0x0915..0x0939 || c in 0x0958..0x095F) if (cNext == DEVANAGARI_NUQTA) { seq0.add(c.toDevaInternal().internalDevaAddNukta()) @@ -973,9 +974,22 @@ class TerrarumSansBitmap( else { seq0.add(c.toDevaInternal()) } + // re-order Sundanese diacritics + else if ((c == 0x1BA1 || c == 0x1BA2) && cNext == 0x1BA5) { + seq0.add(cNext); seq0.add(c); i += 1 + } + // combine two Sundanese diacritics to internal counterpart + else if (c == 0x1BA4 && cNext == 0x1B80) { seq0.add(SUNDANESE_ING); i += 1 } + else if (c == 0x1BA8 && cNext == 0x1B80) { seq0.add(SUNDANESE_ENG); i += 1 } + else if (c == 0x1BA9 && cNext == 0x1B80) { seq0.add(SUNDANESE_EUNG); i += 1 } + else if (c == 0x1BA4 && cNext == 0x1B81) { seq0.add(SUNDANESE_IR); i += 1 } + else if (c == 0x1BA8 && cNext == 0x1B81) { seq0.add(SUNDANESE_ER); i += 1 } + else if (c == 0x1BA9 && cNext == 0x1B81) { seq0.add(SUNDANESE_EUR); i += 1 } + else if (c == 0x1BA3 && cNext == 0x1BA5) { seq0.add(SUNDANESE_LU); i += 1 } else seq0.add(c) + i += 1 } seq0.add(0) @@ -2094,7 +2108,7 @@ class TerrarumSansBitmap( (0x0B80..0x0BFF) + (0xF00C0..0xF00FF), // SHEET_TAMIL_VARW 0x980..0x9FF, // SHEET_BENGALI_VARW 0x2800..0x28FF, // SHEET_BRAILLE_VARW - (0x1B80..0x1BBF) + (0x1CC0..0x1CCF), // SHEET_SUNDANESE_VARW + (0x1B80..0x1BBF) + (0x1CC0..0x1CCF) + (0xF0500..0xF050F), // SHEET_SUNDANESE_VARW 0xF0110..0xF012F, // SHEET_DEVANAGARI2_INTERNAL_VARW ) private val codeRangeHangulCompat = 0x3130..0x318F @@ -2394,7 +2408,7 @@ class TerrarumSansBitmap( private fun enclosedAlphnumSuplY(c: CodePoint) = (c - 0x1F100) / 16 private fun tamilIndexY(c: CodePoint) = (if (c < 0xF0000) (c - 0x0B80) else (c - 0xF0040)) / 16 private fun brailleIndexY(c: CodePoint) = (c - 0x2800) / 16 - private fun sundaneseIndexY(c: CodePoint) = (if (c < 0x1BC0) (c - 0x1B80) else (c - 0x1C80)) / 16 + private fun sundaneseIndexY(c: CodePoint) = (if (c >= 0xF0500) (c - 0xF04B0) else if (c < 0x1BC0) (c - 0x1B80) else (c - 0x1C80)) / 16 private fun devanagari2IndexY(c: CodePoint) = (c - 0xF0110) / 16 val charsetOverrideDefault = Character.toChars(CHARSET_OVERRIDE_DEFAULT).toSurrogatedString() diff --git a/work_files/sundanese_variable.psd b/work_files/sundanese_variable.psd index 6306acd..c3540f4 100644 --- a/work_files/sundanese_variable.psd +++ b/work_files/sundanese_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:89cf949203a094fdae7391efbd0fd01f8599e9b88df3f80aeaea486a75a0ffb3 -size 166291 +oid sha256:a8812d9c9bc4eebafa652884a822629ae9178c26e2010277af3362fcb893f5b7 +size 166308 diff --git a/work_files/thai_variable.psd b/work_files/thai_variable.psd index 662744a..caa466a 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:d20dd7374ebacdbb38c8d8a431d4ba357f478ff18735b7a7f169c158f18569ab -size 123326 +oid sha256:ac471d449ff0edc837870e8049cd3994a20ab92d63288a56264ef208c9af0d69 +size 123044