diff --git a/demo/src/net/torvald/terrarum/imagefont/GameFontBase.kt b/demo/src/net/torvald/terrarum/imagefont/GameFontBase.kt
index 902d590..ac888d3 100644
--- a/demo/src/net/torvald/terrarum/imagefont/GameFontBase.kt
+++ b/demo/src/net/torvald/terrarum/imagefont/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/demo/src/net/torvald/terrarum/imagefont/GameFontImpl.kt b/demo/src/net/torvald/terrarum/imagefont/GameFontImpl.kt
index 8af0e30..5ec28ac 100644
--- a/demo/src/net/torvald/terrarum/imagefont/GameFontImpl.kt
+++ b/demo/src/net/torvald/terrarum/imagefont/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/demo/text.txt b/demo/text.txt
index ec1567b..9e33850 100644
--- a/demo/text.txt
+++ b/demo/text.txt
@@ -1,37 +1,38 @@
Set locale in config.properties to “bgBG” for alternative Bulgarian letters, “srSR” for Serbian.
-ABCDEFGHIJKLM NOPQRSTUVWXYZ
-abcdefghijklm nopqrstuvwxyz
+ABCDEFGHIJKLM NOPQRSTUVWXYZ 12345?
+abcdefghijklm nopqrstuvwxyz 67890!
-Syö salmiakkia, koska se on hyvää sinulle
+The bitmap font for game developers who seek good font that has real multilingual support,
+for free (as in freedom AND without cost).
-The Olympic marmot (Marmota olympus) is a rodent in the squirrel family, Sciuridae.
-It lives only in the U.S. state of Washington, at middle elevations on the Olympic Peninsula.
-About the size of a domestic cat, an adult weighs around 8 kg (18 lb) in summer.
+There are many bitmap fonts on the internet. You care for the multilingual support, but alas!
+most of them does not support your language, vector fonts takes too much time to be loaded,
+even then their legibility suffers because fuck built-in antialias.
+You somehow found a good font, and it makes your game look like a linux terminal, and you say:
+“what the fuck? Is this a game or should I rm -rf this shit‽”
+You speak Japanese, and you wish to support it, but then このクソなfontは only good for Japanese,
+and it is not multilingual, and you don't have a time for this shenanigan.
+Eventually you give up, saying “fuck it!” and just use the fonts that do not match well.
-Brná je část statutárního a krajského města Ústí nad Labem v České republice, spadající
-pod městský obvod Ústí nad Labem-Střekov. Nachází se asi pět kilometrů jižně od centra
-města v Českém středohoří na pravém břehu řeky Labe.
+No more suffering. This font has everything you need.
-Malaysia er en forholdsvis ung stat. Sin endelige udstrækning fik den først i 1965 efter
-at Singapore trak sig ud. Staten blev grundlagt ved en sammenslutning af flere tidligere
-britiske besiddelser, foreløbigt i 1957 og endeligt i 1963.
+while (isVisible(BadFonts)) { ripAndTear(BadFonts).scope(Guts); }
+How multilingual? Real multilingual!
-Το θάλλιο συνοδεύει κυρίως θειούχα ορυκτά βασικών μετάλλων, όπως ο σφαλερίτης, ο σιδηροπυρίτης
-και ο γαληνίτης ενώ αναφέρονται και εμφανίσεις του σε κονδύλους μαγγανίου στους βυθούς των ωκεανών.
+Příliš žluťoučký kůň úpěl ďábelské ódy
+Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich
διαφυλάξτε γενικά τη ζωή σας από βαθειά ψυχικά τραύματα
ΔΙΑΦΥΛΆΞΤΕ ΓΕΝΙΚΆ ΤΗ ΖΩΉ ΣΑΣ ΑΠΌ ΒΑΘΕΙΆ ΨΥΧΙΚΆ ΤΡΑΎΜΑΤΑ
-Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.
-Příliš žluťoučký kůň úpěl ďábelské ódy. Árvíztűrő tükörfúrógép.
-Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.
-Pijamalı hasta yağız şoföre çabucak güvendi. Kŕdeľ ďatľov učí koňa žrať kôru.
-Voix ambiguë d'un cœur qui au zéphyr préfère les jattes de kiwi.
-Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila.
-
-sjaldgæft ekki stjórnarskrárvarin
-
-Also supports:
-‛Unicode’ „quotation marks“—dashes…‼
-으웽~. 얘! 위에 이 애 우유의 양 외워와! 아오~ 왜요? 어여! 예... 웬 초콜릿? 제가 원했던 건 뻥튀기 쬐끔과 의류예요. 얘야, 왜 또 불평? 퀡퇣풿횂
+Pack my box with five dozen liquor jugs
+Voix ambiguë d'un cœur qui au zéphyr préfère les jattes de kiwi
+정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 뚫훍뚫훍뚫(읗) 뚫훍뚫훍뚫(읗) 뚫훍뚫훍뚫 따다다
+Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa
+Árvíztűrő tükörfúrógép Kŕdeľ ďatľov učí koňa žrať kôru
とりなくこゑす ゆめさませ みよあけわたる ひんかしを そらいろはえて おきつへに ほふねむれゐぬ もやのうち
-鳥啼く声す 夢覚ませ 見よ明け渡る 東を 空色栄えて 沖つ辺に 帆船群れゐぬ 靄の中,
\ No newline at end of file
+鳥啼く声す 夢覚ませ 見よ明け渡る 東を 空色栄えて 沖つ辺に 帆船群れゐぬ 靄の中
+Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila
+Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства
+Pijamalı hasta yağız şoföre çabucak güvendi
+Also supports: ‛Unicode’ „quotation marks“—dashes…「括弧」‼
+ASCII Latin-1 Latin_Ext-A Latin_Ext-B Greek Cyrillic CJK-Ideo Kana Hangul_Syllables