From 8033d749c243d450edf60009c68af910e9da0d5c Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Fri, 24 Mar 2017 14:55:56 +0900 Subject: [PATCH] removing height hacks by making all fonts (except unihan) have same height, taller hangul --- Slick2d/GameFontBase.kt | 41 +++--- Slick2d/GameFontImpl.kt | 6 +- assets/graphics/fonts/cjkpunct.tga | Bin 51218 -> 51244 bytes assets/graphics/fonts/hangul_johab.tga | Bin 197164 -> 246418 bytes assets/graphics/fonts/unipunct.tga | Bin 80658 -> 80684 bytes demo/.idea/workspace.xml | 118 +++++++++++++----- demo/TerrarumSansDemo.iml | 61 ++------- .../terrarum/imagefont/GameFontBase.kt | 41 +++--- .../terrarum/imagefont/GameFontImpl.kt | 6 +- demo/text.txt | 55 ++++---- 10 files changed, 163 insertions(+), 165 deletions(-) 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 ff72b85b30837634f79e41b06d72548495fcb952..af04303f3b1a43afef321f9006db5cc6aa9a499a 100644 GIT binary patch delta 144 zcmbO@iW-W%AiPk;!jo7yxMjpjMg9Z)ap6$vbR5n|Cx!iUA5jf#*tB_^NEshO<1&S3K0Vv)&fvytTlpz2&U w>MAf!?%gW`#2yoMT_*b$icHR(Z2+VNfLdiX=g!VRl6TnbTX-~Vqh13O00B=kFaQ7m diff --git a/assets/graphics/fonts/hangul_johab.tga b/assets/graphics/fonts/hangul_johab.tga index 3f29bc3ab15add6f64e11bf88c2a9a7fb7de4662..aed24a6e151b6cf9a281ed757c2fb088e405f6b1 100644 GIT binary patch delta 2209 zcmdT_O=ufe5cWJvPV8tSRhEJdD^S4%750G+I`|-g4m#){L1<(mVjB#_CD1H2ttc*Z ziw`d35{UCsCT$VTp)@{tTQ8z)O{~^XH})X{6ME30%CSwL3pun9XjD40vK@)I#~xzv z?!Le8ee=yXqm9+j%}>JNkr6R+^p}NwCwxBW$b*1t&z722aI@@M58!dwk+o5psw!_L zh292aQ36D;9ThQUkHwnW#Tyr1?8NT-U^w!tK+{~$MI9Le^h%!TIyzc9R8=D$ z!ekvv%GwIK*6Tjd;I=zWue-!Y>B#YSAJfzK^+EE5pzBblNttk zGa`+xAY5CM)BYmIswimMQKSDk?EMJo?~?GnaAXdKWWKD1Q?*WpC9PQ8nfw z%8SNOn-vjNxul~Eh#a;xk+~T^ttzc477gc5!3qb^i0d?c9IZ-D8Z7XUdp zZ$}1RW`On{6r0*!L9EGL!ZVclcM080ZX-opax z?e2Tm?T$P6AC*z8^(YK3HHhvdS;jH90kOdQd2qWSGzq+>w+o?;y&3B`mPuxMQ$;ycyjeVB4XP{Ap_|?aSf?A)#7lLaKWy?Wa`b zwG`oJ&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c3681ed250ffb725a1466bd282d09f..ce5a26df795aed30c813c750295bd1e5372f30f9 100644 GIT binary patch delta 285 zcmbRAjb+U@mJMGWCifmw+1z{V2IE9s7bu;9B$fdd+o;>Zge2$!XK&O!VZKp!2Ipki zHyWFLkAO^ZfU`I19$fpd^0U~GuBU=7=C*%>96K&mI}E|XY%b|Hu@vsrgpMdW1P zBRxP)01*EGVjm!11&Bek43Mt^#2(xKvM_ouLS;NAzdfZgdGA66m`o1PSsoxskS$k@ IC+cMY0KkQGO#lD@ 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 @@ +