diff --git a/Slick2d/GameFontBase.kt b/Slick2d/GameFontBase.kt index 902d590..ac888d3 100644 --- a/Slick2d/GameFontBase.kt +++ b/Slick2d/GameFontBase.kt @@ -54,20 +54,20 @@ open class GameFontBase : Font { 9 } - private fun isHangul(c: Char) = c.toInt() >= 0xAC00 && c.toInt() < 0xD7A4 - private fun isAscii(c: Char) = c.toInt() >= 0x20 && c.toInt() <= 0xFF + private fun isHangul(c: Char) = c.toInt() in 0xAC00..0xD7A3 + private fun isAscii(c: Char) = c.toInt() in 0x20..0xFF private fun isRunic(c: Char) = runicList.contains(c) - private fun isExtA(c: Char) = c.toInt() >= 0x100 && c.toInt() < 0x180 - private fun isExtB(c: Char) = c.toInt() >= 0x180 && c.toInt() < 0x250 - private fun isKana(c: Char) = c.toInt() >= 0x3040 && c.toInt() < 0x3100 - private fun isCJKPunct(c: Char) = c.toInt() >= 0x3000 && c.toInt() < 0x3040 - private fun isUniHan(c: Char) = c.toInt() >= 0x3400 && c.toInt() < 0xA000 - private fun isCyrilic(c: Char) = c.toInt() >= 0x400 && c.toInt() < 0x460 - private fun isFullwidthUni(c: Char) = c.toInt() >= 0xFF00 && c.toInt() < 0xFF20 - private fun isUniPunct(c: Char) = c.toInt() >= 0x2000 && c.toInt() < 0x2070 - private fun isWenQuanYi1(c: Char) = c.toInt() >= 0x33F3 && c.toInt() <= 0x69FC - private fun isWenQuanYi2(c: Char) = c.toInt() >= 0x69FD && c.toInt() <= 0x9FDC - private fun isGreek(c: Char) = c.toInt() >= 0x370 && c.toInt() <= 0x3CE + private fun isExtA(c: Char) = c.toInt() in 0x100..0x17F + private fun isExtB(c: Char) = c.toInt() in 0x180..0x24F + private fun isKana(c: Char) = c.toInt() in 0x3040..0x30FF + private fun isCJKPunct(c: Char) = c.toInt() in 0x3000..0x303F + private fun isUniHan(c: Char) = c.toInt() in 0x3400..0x9FFF + private fun isCyrilic(c: Char) = c.toInt() in 0x400..0x45F + private fun isFullwidthUni(c: Char) = c.toInt() in 0xFF00..0xFF1F + private fun isUniPunct(c: Char) = c.toInt() in 0x2000..0x206F + private fun isWenQuanYi1(c: Char) = c.toInt() in 0x33F3..0x69FC + private fun isWenQuanYi2(c: Char) = c.toInt() in 0x69FD..0x9FDC + private fun isGreek(c: Char) = c.toInt() in 0x370..0x3CE @@ -199,17 +199,17 @@ open class GameFontBase : Font { hangulSheet.getSubImage(indexCho, choRow).drawWithShadow( Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(), - Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(), + Math.round(y).toFloat(), scale.toFloat(), thisCol ) hangulSheet.getSubImage(indexJung, jungRow).drawWithShadow( Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(), - Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(), + Math.round(y).toFloat(), scale.toFloat(), thisCol ) hangulSheet.getSubImage(indexJong, jongRow).drawWithShadow( Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(), - Math.round(((H - H_HANGUL) / 2).toFloat() + y + 1f).toFloat(), + Math.round(y).toFloat(), scale.toFloat(), thisCol ) } @@ -345,12 +345,7 @@ open class GameFontBase : Font { try { sheetKey[prevInstance]!!.getSubImage(sheetX, sheetY).drawWithShadow( Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(), - - // to deal with the height difference of the sheets - Math.round(y).toFloat() + (if (prevInstance == SHEET_CJK_PUNCT) -1 // height hack - else if (prevInstance == SHEET_FW_UNI) (H - H_HANGUL) / 2 // completely legit height adjustment - else 0).toFloat(), - + Math.round(y).toFloat(), scale.toFloat(), thisCol ) } @@ -512,9 +507,7 @@ open class GameFontBase : Font { internal val W_LATIN_WIDE = 9 // width of regular letters internal val H = 20 - internal val H_HANGUL = 16 internal val H_UNIHAN = 16 - internal val H_KANA = 20 internal val SHEET_ASCII_VARW = 0 internal val SHEET_HANGUL = 1 diff --git a/Slick2d/GameFontImpl.kt b/Slick2d/GameFontImpl.kt index 8af0e30..5ec28ac 100644 --- a/Slick2d/GameFontImpl.kt +++ b/Slick2d/GameFontImpl.kt @@ -11,7 +11,7 @@ class GameFontImpl : GameFontBase() { init { GameFontBase.hangulSheet = SpriteSheet( - "./assets/graphics/fonts/hangul_johab.tga", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL) + "./assets/graphics/fonts/hangul_johab.tga", GameFontBase.W_HANGUL, GameFontBase.H) GameFontBase.asciiSheet = SpriteSheet( "./assets/graphics/fonts/ascii_variable.tga", 15, 19, 1) GameFontBase.extASheet = SpriteSheet( @@ -19,9 +19,9 @@ class GameFontImpl : GameFontBase() { GameFontBase.extBSheet = SpriteSheet( "./assets/graphics/fonts/LatinExtB_variable.tga", 15, 19, 1) GameFontBase.kanaSheet = SpriteSheet( - "./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H_KANA) + "./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H) GameFontBase.cjkPunct = SpriteSheet( - "./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H_KANA) + "./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H) /*uniHan = new SpriteSheet( "./assets/graphics/fonts/unifont_unihan" + ((!terrarum.gameLocale.contains("zh")) diff --git a/assets/graphics/fonts/cjkpunct.tga b/assets/graphics/fonts/cjkpunct.tga index ff72b85..af04303 100644 Binary files a/assets/graphics/fonts/cjkpunct.tga and b/assets/graphics/fonts/cjkpunct.tga differ diff --git a/assets/graphics/fonts/hangul_johab.tga b/assets/graphics/fonts/hangul_johab.tga index 3f29bc3..aed24a6 100644 Binary files a/assets/graphics/fonts/hangul_johab.tga and b/assets/graphics/fonts/hangul_johab.tga differ diff --git a/assets/graphics/fonts/unipunct.tga b/assets/graphics/fonts/unipunct.tga index 344d6f8..ce5a26d 100644 Binary files a/assets/graphics/fonts/unipunct.tga and b/assets/graphics/fonts/unipunct.tga differ diff --git a/demo/.idea/workspace.xml b/demo/.idea/workspace.xml index 24a498c..350da7f 100644 --- a/demo/.idea/workspace.xml +++ b/demo/.idea/workspace.xml @@ -27,7 +27,7 @@ - + @@ -36,11 +36,11 @@ - + - - + + @@ -48,11 +48,11 @@ - + - - + + @@ -60,6 +60,16 @@ + + + + + + + + + + @@ -96,17 +106,17 @@ - @@ -123,6 +133,9 @@ + + + @@ -169,9 +182,6 @@ - - - @@ -182,6 +192,18 @@ + + + @@ -384,7 +406,7 @@ - + @@ -397,13 +419,13 @@ - + - + @@ -429,6 +451,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -453,7 +505,6 @@ - @@ -491,7 +542,7 @@ - + @@ -503,38 +554,45 @@ - - + - - - - - + + + - - + + - - + + + + + + + + + + + + diff --git a/demo/TerrarumSansDemo.iml b/demo/TerrarumSansDemo.iml index b19a530..3425576 100644 --- a/demo/TerrarumSansDemo.iml +++ b/demo/TerrarumSansDemo.iml @@ -6,67 +6,20 @@ +