diff --git a/.idea/workspace.xml b/.idea/workspace.xml index cc81e4b..bdf91f1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -11,12 +11,9 @@ - - - + - @@ -35,11 +32,11 @@ - + - + @@ -47,13 +44,13 @@ - - + + - + @@ -74,8 +71,8 @@ - - + + @@ -83,11 +80,11 @@ - + - - + + @@ -95,18 +92,18 @@ - - + + - + - - - + + + @@ -142,7 +139,6 @@ - getColour .094 ө @@ -151,15 +147,15 @@ getSheetT Unexpected Unexp - + fun getSh codeRange isHangul toColo - + fun relo 3633 println( - + Width ta getWidth glyphWidthBuffer GlyphProps.LE @@ -172,6 +168,7 @@ ArrayList<Int> appConfig.height textBuffer + no stan .141 @@ -193,11 +190,11 @@ @@ -485,7 +482,7 @@ - + @@ -862,37 +859,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -905,14 +871,18 @@ - - + + + + + + - - - + + + @@ -920,6 +890,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c48884..0f04e9e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,17 +44,24 @@ Green-tinted area (should be 10 px tall) contains the tags. Tags are defined as 1 | 2 | only valid if write-on-top is 1 1 | 4 | and is centre-aligned and non-zero 1 -+ 8 | (if this is zero, floorOf(width/2) will be used instead) - 0 -+ 0 Align 1 Align 0 Align - 1 -+ 0 left 0 right 1 Centre + 0 -+ 0 Align 1 Align 0 Align 1 Align before + 1 -+ 0 left 0 right 1 centre 1 the glyph 0 == Write on top of prev chars (e.g. diacritics) 1 == Diacritics stack 0:upward/1:downward -(MSB) 0 == Diacritics comes befor the glyph +(MSB) X == undefined, should be 0 -NOTE: if glyphs are right or centre aligned, they must be aligned in the same way - inside of the bitmap; the program assumes every variable-width glyphs to have - a width of 15, regardless of the tagged width. +NOTE: If glyphs are right or centre aligned, they must be aligned in the + same way inside of the bitmap; the program assumes every variable- + width glyphs to have a width of 15, regardless of the tagged width. + If the diacritic is aligned before the glyph, the diacritic itself + is always assumed as left-aligned, as this font will swap position + of said diacritic and the glyph right before it. ``` +![Visual representation of left/right/centre align](alignment_illustration.jpg) + +(fun fact: it was drawn on Rhodia memopad with Lamy 2000, then photographed and edited on my iPhone. Letter used is a Cherokee WE Ꮺ) + ### Implementing the Korean writing system On this font, Hangul letters are printed by assemblying two or three letter pieces. There are 10 sets of Hangul letter pieces on the font. Top 6 are initials, middle 2 are medials, and bottom 2 are finals. On the rightmost side, there's eight assembled glyphs to help you with (assuming you have basic knowledge on the writing system). Top 6 tells you how to use 6 initials, and bottom 2 tells you how to use 2 finals. diff --git a/FontTestGDX/demotext.txt b/FontTestGDX/demotext.txt index 73e3f92..c30ee38 100644 --- a/FontTestGDX/demotext.txt +++ b/FontTestGDX/demotext.txt @@ -90,9 +90,9 @@ How multilingual? Real multilingual! 􏃯Unicode References:􀀀 Basic Latin Latin-1 Latin Extension A Latin Extionsion B IPA Extension Greek Cyrillic - Cyrillic Supplement Armenian Thai Georgian Runic Cherokee General Punctuations CJK Symbols - Kana Kana Phonetic Extension CJK Unihan Extension A CJK Unihan Hangul Syllables Fullwidth Forms - Kana Supplement + Cyrillic Supplement Armenian Devanagari Thai Georgian Runic Cherokee General Punctuations + CJK Symbols Kana Kana Phonetic Extension CJK Unihan Extension A CJK Unihan Hangul Syllables + Fullwidth Forms Kana Supplement GitHub’s issue page is open! You can report any 􏽕errors􀀀, or leave 􏽕suggestions􀀀. You can help this font to be more versatile. (for more languages, more frameworks) 􏽕Clone􀀀 this repo, make diff --git a/FontTestGDX/lib/TerrarumSansBitmap.jar b/FontTestGDX/lib/TerrarumSansBitmap.jar index 2709fd2..7e00d11 100644 Binary files a/FontTestGDX/lib/TerrarumSansBitmap.jar and b/FontTestGDX/lib/TerrarumSansBitmap.jar differ diff --git a/alignment_illustration.jpg b/alignment_illustration.jpg new file mode 100644 index 0000000..509369c Binary files /dev/null and b/alignment_illustration.jpg differ diff --git a/assets/devanagari_bengali_variable.tga b/assets/devanagari_bengali_variable.tga index bf32353..568fbff 100644 Binary files a/assets/devanagari_bengali_variable.tga and b/assets/devanagari_bengali_variable.tga differ diff --git a/assets/thai_variable.tga b/assets/thai_variable.tga index 8dc77e6..b87d968 100644 Binary files a/assets/thai_variable.tga and b/assets/thai_variable.tga differ diff --git a/demo.PNG b/demo.PNG index 07f29c7..8bcb2d4 100644 Binary files a/demo.PNG and b/demo.PNG differ diff --git a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt index 98bb607..6693837 100644 --- a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt +++ b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt @@ -25,6 +25,6 @@ data class GlyphProps( tags.ushr(1).and(15), tags.and(1) == 1, tags.ushr(8).and(1) == 1, - tags.ushr(9).and(1) == 1 + tags.ushr(5).and(3) == 3 ) } \ No newline at end of file diff --git a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt index 7bbfb73..318e3e6 100644 --- a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt @@ -469,7 +469,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo GlyphProps.LEFT -> 0 GlyphProps.RIGHT -> thisProp.width - W_VAR_INIT GlyphProps.CENTRE -> Math.floor((thisProp.width - W_VAR_INIT) / 2.0).toInt() - else -> throw InternalError("Unsupported alignment: ${thisProp.alignWhere} for '$thisChar' (${thisChar.charInfo()})") + else -> 0 // implies "diacriticsBeforeGlyph = true" } if (!thisProp.writeOnTop) { @@ -521,11 +521,13 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo var shadowCol = mainCol.cpy().mul(0.5f,0.5f,0.5f,1f) + resetHash() var index = 0 while (index <= textBuffer.lastIndex) { val c = textBuffer[index] val sheetID = getSheetType(c) val (sheetX, sheetY) = getSheetwisePosition(c) + val hash = getHash(c) //println("[TerrarumSansBitmap] sprite: $sheetID:${sheetX}x${sheetY}") @@ -948,6 +950,18 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo val charsetOverrideBulgarian = Character.toChars(CHARSET_OVERRIDE_BG_BG) val charsetOverrideSerbian = Character.toChars(CHARSET_OVERRIDE_SR_SR) + private val hashBasis = -3750763034362895579L + private val hashPrime = 1099511628211L + private var hashAccumulator = hashBasis + fun getHash(char: Int): Long { + hashAccumulator = hashAccumulator xor char.toLong() + hashAccumulator *= hashPrime + return hashAccumulator + } + fun resetHash() { + hashAccumulator = hashBasis + } + companion object { internal val JUNG_COUNT = 21 internal val JONG_COUNT = 28