diff --git a/.gitignore b/.gitignore
index 0698352..a1b30b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,5 @@ demo/out/*
demo/lib/*
demo/assets/*
out/*
-lib/*
\ No newline at end of file
+lib/*
+Terrarum-sans-bitmap*.zip
\ No newline at end of file
diff --git a/.idea/artifacts/FontDemoGDX.xml b/.idea/artifacts/FontDemoGDX.xml
new file mode 100644
index 0000000..9483570
--- /dev/null
+++ b/.idea/artifacts/FontDemoGDX.xml
@@ -0,0 +1,9 @@
+
+
+ $PROJECT_DIR$/out/artifacts/FontDemoGDX
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/TerrarumSansBitmap.xml b/.idea/artifacts/TerrarumSansBitmap.xml
index e693b18..c1de259 100644
--- a/.idea/artifacts/TerrarumSansBitmap.xml
+++ b/.idea/artifacts/TerrarumSansBitmap.xml
@@ -1,6 +1,6 @@
- $PROJECT_DIR$
+ $PROJECT_DIR$/FontTestGDX/lib
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..7478dc1
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/demo/.idea/kotlinc.xml b/.idea/kotlinc.xml
similarity index 52%
rename from demo/.idea/kotlinc.xml
rename to .idea/kotlinc.xml
index 0dd4b35..3c50bd3 100644
--- a/demo/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -3,4 +3,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/demo/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/GdxLib.xml
similarity index 55%
rename from demo/.idea/libraries/KotlinJavaRuntime.xml
rename to .idea/libraries/GdxLib.xml
index a83cacd..09fa810 100644
--- a/demo/.idea/libraries/KotlinJavaRuntime.xml
+++ b/.idea/libraries/GdxLib.xml
@@ -1,8 +1,6 @@
-
+
-
-
@@ -10,8 +8,9 @@
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/TesterLib.xml b/.idea/libraries/TesterLib.xml
new file mode 100644
index 0000000..d20e73d
--- /dev/null
+++ b/.idea/libraries/TesterLib.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index fa8838a..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml
new file mode 100644
index 0000000..3efe9d6
--- /dev/null
+++ b/.idea/markdown-navigator.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown-navigator/profiles_settings.xml b/.idea/markdown-navigator/profiles_settings.xml
new file mode 100644
index 0000000..57927c5
--- /dev/null
+++ b/.idea/markdown-navigator/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cac86c6..0548357 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,73 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/modules.xml b/.idea/modules.xml
index e68d521..46a4f1d 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,6 +3,7 @@
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4010717..7780478 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,10 +7,34 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -30,9 +54,17 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -41,12 +73,14 @@
-
-
+
+
-
-
-
+
+
+
+
+
@@ -55,6 +89,13 @@
+
+
+
getG
@@ -70,127 +111,83 @@
-
-
-
-
-
-
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
+
+
+
+
+
@@ -204,31 +201,14 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -238,30 +218,64 @@
-
-
-
-
-
+
+
+
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
@@ -274,15 +288,12 @@
-
-
-
@@ -336,17 +347,18 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -361,9 +373,16 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -388,258 +407,253 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -666,7 +680,7 @@
-
+
@@ -697,12 +711,11 @@
- BuildJAR_TerrarumSansBitmap
+ FontTestGDX
-
@@ -710,7 +723,7 @@
- lib
+ TesterLib
diff --git a/BuildJAR_TerrarumSansBitmap.iml b/BuildJAR_TerrarumSansBitmap.iml
index c33f24f..1f959f2 100644
--- a/BuildJAR_TerrarumSansBitmap.iml
+++ b/BuildJAR_TerrarumSansBitmap.iml
@@ -8,6 +8,6 @@
-
+
\ No newline at end of file
diff --git a/FontTestGDX/FontTestGDX.iml b/FontTestGDX/FontTestGDX.iml
new file mode 100644
index 0000000..0afdbdc
--- /dev/null
+++ b/FontTestGDX/FontTestGDX.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demo/text.txt b/FontTestGDX/demotext.txt
similarity index 100%
rename from demo/text.txt
rename to FontTestGDX/demotext.txt
diff --git a/FontTestGDX/lib/TerrarumSansBitmap.jar b/FontTestGDX/lib/TerrarumSansBitmap.jar
new file mode 100644
index 0000000..521e9d4
Binary files /dev/null and b/FontTestGDX/lib/TerrarumSansBitmap.jar differ
diff --git a/FontTestGDX/src/FontTestGDX.kt b/FontTestGDX/src/FontTestGDX.kt
new file mode 100644
index 0000000..e65c427
--- /dev/null
+++ b/FontTestGDX/src/FontTestGDX.kt
@@ -0,0 +1,60 @@
+import com.badlogic.gdx.Game
+import com.badlogic.gdx.Gdx
+import com.badlogic.gdx.Screen
+import com.badlogic.gdx.backends.lwjgl.LwjglApplication
+import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
+import com.badlogic.gdx.graphics.GL20
+import net.torvald.terrarumsansbitmap.gdx.GameFontBase
+
+/**
+ * Created by minjaesong on 2018-07-26.
+ */
+class FontTestGDX : Game() {
+
+ lateinit var font: GameFontBase
+
+ override fun create() {
+ font = GameFontBase("./assets")
+ }
+
+ override fun getScreen(): Screen? {
+ return null
+ }
+
+ override fun setScreen(screen: Screen?) {
+ }
+
+ override fun render() {
+
+ Gdx.gl.glClearColor(.094f, .094f, .094f, 1f)
+ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
+ Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
+ Gdx.gl.glEnable(GL20.GL_BLEND)
+ Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
+
+ }
+
+ override fun pause() {
+ }
+
+ override fun resume() {
+ }
+
+ override fun resize(width: Int, height: Int) {
+ }
+
+ override fun dispose() {
+ font.dispose()
+ }
+}
+
+fun main(args: Array) {
+ val appConfig = LwjglApplicationConfiguration()
+ appConfig.vSyncEnabled = false
+ appConfig.resizable = false//true;
+ appConfig.width = 740 // photographic ratio (1.5:1)
+ appConfig.height = 1110 // photographic ratio (1.5:1)
+ appConfig.title = "Terrarum Sans Bitmap Test (GDX)"
+
+ LwjglApplication(FontTestGDX(), appConfig)
+}
diff --git a/TerrarumSansBitmap.jar b/TerrarumSansBitmap.jar
deleted file mode 100644
index 68e2cc5..0000000
Binary files a/TerrarumSansBitmap.jar and /dev/null differ
diff --git a/demo/.idea/.name b/demo/.idea/.name
deleted file mode 100644
index d28c669..0000000
--- a/demo/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-TerrarumSansDemo
\ No newline at end of file
diff --git a/demo/.idea/artifacts/unnamed.xml b/demo/.idea/artifacts/unnamed.xml
deleted file mode 100644
index dcc4e25..0000000
--- a/demo/.idea/artifacts/unnamed.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- $PROJECT_DIR$/out/artifacts/unnamed
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/.idea/misc.xml b/demo/.idea/misc.xml
deleted file mode 100644
index 0548357..0000000
--- a/demo/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/.idea/modules.xml b/demo/.idea/modules.xml
deleted file mode 100644
index f14e97b..0000000
--- a/demo/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/.idea/workspace.xml b/demo/.idea/workspace.xml
deleted file mode 100644
index 6066c55..0000000
--- a/demo/.idea/workspace.xml
+++ /dev/null
@@ -1,828 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- "|
- ,\n
- main
- E7F
-
-
- \n
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1487243351068
-
-
- 1487243351068
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- unnamed
-
-
-
-
-
-
-
-
-
-
-
-
- Detection
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
- Kotlin|TerrarumSansDemo
-
-
-
-
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
- KotlinJavaRuntime
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/META-INF/MANIFEST.MF b/demo/META-INF/MANIFEST.MF
deleted file mode 100644
index 908b34f..0000000
--- a/demo/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,4 +0,0 @@
-Manifest-Version: 1.0
-Class-Path: lib/lwjgl.jar lib/lwjgl_util.jar lib/slick.jar lib/kotlin-reflect.jar lib/kotlin-runtime.jar
-Main-Class: net.torvald.terrarum.imagefont.GameFontDemoKt
-
diff --git a/demo/TerrarumSansDemo.iml b/demo/TerrarumSansDemo.iml
deleted file mode 100644
index a66d395..0000000
--- a/demo/TerrarumSansDemo.iml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/config.properties b/demo/config.properties
deleted file mode 100644
index c22105c..0000000
--- a/demo/config.properties
+++ /dev/null
@@ -1 +0,0 @@
-locale=enUS
\ No newline at end of file
diff --git a/demo/src/net/torvald/terrarum/imagefont/GameFontBase.kt b/demo/src/net/torvald/terrarum/imagefont/GameFontBase.kt
deleted file mode 100644
index 7d0e2b6..0000000
--- a/demo/src/net/torvald/terrarum/imagefont/GameFontBase.kt
+++ /dev/null
@@ -1,700 +0,0 @@
-package net.torvald.terrarumsansbitmap.slick2d
-
-import org.newdawn.slick.Color
-import org.newdawn.slick.Font
-import org.newdawn.slick.Image
-import org.newdawn.slick.SpriteSheet
-import org.newdawn.slick.opengl.Texture
-import java.io.BufferedOutputStream
-import java.io.File
-import java.io.FileInputStream
-import java.io.FileOutputStream
-import java.util.*
-import java.util.zip.GZIPInputStream
-
-/**
- * LibGDX port of Terrarum Sans Bitmap implementation
- *
- * Filename and Extension for the spritesheet is hard-coded, which are:
- *
- * - ascii_variable.tga
- * - hangul_johab.tga
- * - LatinExtA_variable.tga
- * - LatinExtB_variable.tga
- * - kana.tga
- * - cjkpunct.tga
- * - wenquanyi.tga.gz
- * - cyrillic_variable.tga
- * - fullwidth_forms.tga
- * - unipunct_variable.tga
- * - greek_variable.tga
- * - thai_variable.tga
- * - puae000-e0ff.tga
- *
- *
- * Glyphs are drawn lazily (calculated on-the-fly, rather than load up all), which is inevitable as we just can't load
- * up 40k+ characters on the machine, which will certainly make loading time painfully long.
- *
- * @param noShadow Self-explanatory
- * @param flipY If you have Y-down coord system implemented on your GDX (e.g. legacy codebase), set this to ```true``` so that the shadow won't be upside-down. For glyph getting upside-down, set ```TextureRegionPack.globalFlipY = true```.
- *
- * Created by minjaesong on 2017-06-15.
- */
-class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
-
- private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
- private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
- private fun getHanJongseong(hanIndex: Int) = hanIndex % JONG_COUNT
-
- private val jungseongWide = arrayOf(8, 12, 13, 17, 18, 21)
- private val jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22)
-
- private fun isJungseongWide(hanIndex: Int) = jungseongWide.contains(getHanJungseong(hanIndex))
- private fun isJungseongComplex(hanIndex: Int) = jungseongComplex.contains(getHanJungseong(hanIndex))
-
- private fun getHanInitialRow(hanIndex: Int): Int {
- val ret: Int
-
- if (isJungseongWide(hanIndex))
- ret = 2
- else if (isJungseongComplex(hanIndex))
- ret = 4
- else
- ret = 0
-
- return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
- }
-
- private fun getHanMedialRow(hanIndex: Int) = if (getHanJongseong(hanIndex) == 0) 6 else 7
-
- private fun getHanFinalRow(hanIndex: Int): Int {
- val jungseongIndex = getHanJungseong(hanIndex)
-
- return if (jungseongWide.contains(jungseongIndex))
- 8
- else
- 9
- }
-
- private fun isHangul(c: Char) = c.toInt() in codeRange[SHEET_HANGUL]
- private fun isAscii(c: Char) = c.toInt() in codeRange[SHEET_ASCII_VARW]
- //private fun isRunic(c: Char) = runicList.contains(c)
- private fun isExtA(c: Char) = c.toInt() in codeRange[SHEET_EXTA_VARW]
- private fun isExtB(c: Char) = c.toInt() in codeRange[SHEET_EXTB_VARW]
- private fun isKana(c: Char) = c.toInt() in codeRange[SHEET_KANA]
- private fun isCJKPunct(c: Char) = c.toInt() in codeRange[SHEET_CJK_PUNCT]
- private fun isUniHan(c: Char) = c.toInt() in codeRange[SHEET_UNIHAN]
- private fun isCyrilic(c: Char) = c.toInt() in codeRange[SHEET_CYRILIC_VARW]
- private fun isFullwidthUni(c: Char) = c.toInt() in codeRange[SHEET_FW_UNI]
- private fun isUniPunct(c: Char) = c.toInt() in codeRange[SHEET_UNI_PUNCT]
- private fun isGreek(c: Char) = c.toInt() in codeRange[SHEET_GREEK_VARW]
- private fun isThai(c: Char) = c.toInt() in codeRange[SHEET_THAI_VARW]
- private fun isDiacritics(c: Char) = c.toInt() in 0xE34..0xE3A
- || c.toInt() in 0xE47..0xE4E
- || c.toInt() == 0xE31
- private fun isCustomSym(c: Char) = c.toInt() in codeRange[SHEET_CUSTOM_SYM]
- private fun isArmenian(c: Char) = c.toInt() in codeRange[SHEET_HAYEREN_VARW]
- private fun isKartvelian(c: Char) = c.toInt() in codeRange[SHEET_KARTULI_VARW]
- private fun isIPA(c: Char) = c.toInt() in codeRange[SHEET_IPA_VARW]
-
-
-
- private fun extAindexX(c: Char) = (c.toInt() - 0x100) % 16
- private fun extAindexY(c: Char) = (c.toInt() - 0x100) / 16
-
- private fun extBindexX(c: Char) = (c.toInt() - 0x180) % 16
- private fun extBindexY(c: Char) = (c.toInt() - 0x180) / 16
-
- //private fun runicIndexX(c: Char) = runicList.indexOf(c) % 16
- //private fun runicIndexY(c: Char) = runicList.indexOf(c) / 16
-
- private fun kanaIndexX(c: Char) = (c.toInt() - 0x3040) % 16
- private fun kanaIndexY(c: Char) = (c.toInt() - 0x3040) / 16
-
- private fun cjkPunctIndexX(c: Char) = (c.toInt() - 0x3000) % 16
- private fun cjkPunctIndexY(c: Char) = (c.toInt() - 0x3000) / 16
-
- private fun cyrilicIndexX(c: Char) = (c.toInt() - 0x400) % 16
- private fun cyrilicIndexY(c: Char) = (c.toInt() - 0x400) / 16
-
- private fun fullwidthUniIndexX(c: Char) = (c.toInt() - 0xFF00) % 16
- private fun fullwidthUniIndexY(c: Char) = (c.toInt() - 0xFF00) / 16
-
- private fun uniPunctIndexX(c: Char) = (c.toInt() - 0x2000) % 16
- private fun uniPunctIndexY(c: Char) = (c.toInt() - 0x2000) / 16
-
- private fun unihanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
- private fun unihanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
-
- private fun greekIndexX(c: Char) = (c.toInt() - 0x370) % 16
- private fun greekIndexY(c: Char) = (c.toInt() - 0x370) / 16
-
- private fun thaiIndexX(c: Char) = (c.toInt() - 0xE00) % 16
- private fun thaiIndexY(c: Char) = (c.toInt() - 0xE00) / 16
-
- private fun symbolIndexX(c: Char) = (c.toInt() - 0xE000) % 16
- private fun symbolIndexY(c: Char) = (c.toInt() - 0xE000) / 16
-
- private fun armenianIndexX(c: Char) = (c.toInt() - 0x530) % 16
- private fun armenianIndexY(c: Char) = (c.toInt() - 0x530) / 16
-
- private fun kartvelianIndexX(c: Char) = (c.toInt() - 0x10D0) % 16
- private fun kartvelianIndexY(c: Char) = (c.toInt() - 0x10D0) / 16
-
- private fun ipaIndexX(c: Char) = (c.toInt() - 0x250) % 16
- private fun ipaIndexY(c: Char) = (c.toInt() - 0x250) / 16
-
- private val unihanWidthSheets = arrayOf(
- SHEET_UNIHAN,
- SHEET_FW_UNI
- )
- private val variableWidthSheets = arrayOf(
- SHEET_ASCII_VARW,
- SHEET_EXTA_VARW,
- SHEET_EXTB_VARW,
- SHEET_CYRILIC_VARW,
- SHEET_UNI_PUNCT,
- SHEET_GREEK_VARW,
- SHEET_THAI_VARW,
- SHEET_HAYEREN_VARW,
- SHEET_KARTULI_VARW,
- SHEET_IPA_VARW
- )
-
- private val fontParentDir = if (fontDir.endsWith('/') || fontDir.endsWith('\\')) fontDir else "$fontDir/"
- private val fileList = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
- "ascii_variable.tga",
- "hangul_johab.tga",
- "LatinExtA_variable.tga",
- "LatinExtB_variable.tga",
- "kana.tga",
- "cjkpunct.tga",
- "wenquanyi.tga.gz",
- "cyrilic_variable.tga",
- "fullwidth_forms.tga",
- "unipunct_variable.tga",
- "greek_variable.tga",
- "thai_variable.tga",
- "hayeren_variable.tga",
- "kartuli_variable.tga",
- "ipa_ext_variable.tga",
- "puae000-e0ff.tga"
- )
- private val cyrilic_bg = "cyrilic_bulgarian_variable.tga"
- private val cyrilic_sr = "cyrilic_serbian_variable.tga"
- private val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
- 0..0xFF,
- 0xAC00..0xD7A3,
- 0x100..0x17F,
- 0x180..0x24F,
- 0x3040..0x30FF,
- 0x3000..0x303F,
- 0x3400..0x9FFF,
- 0x400..0x52F,
- 0xFF00..0xFF1F,
- 0x2000..0x205F,
- 0x370..0x3CE,
- 0xE00..0xE5F,
- 0x530..0x58F,
- 0x10D0..0x10FF,
- 0x250..0x2AF,
- 0xE000..0xE0FF
- )
- private val glyphWidths: HashMap = HashMap() // if the value is negative, it's diacritics
- private val sheets: Array
-
-
- init {
- val sheetsPack = ArrayList()
-
- // first we create pixmap to read pixels, then make texture using pixmap
- fileList.forEachIndexed { index, it ->
- val isVariable1 = it.endsWith("_variable.tga")
- val isVariable2 = variableWidthSheets.contains(index)
- val isVariable = isVariable1 && isVariable2
-
- // idiocity check
- if (isVariable1 && !isVariable2)
- throw Error("[TerrarumSansBitmap] font is named as variable on the name but not enlisted as")
- else if (!isVariable1 && isVariable2)
- throw Error("[TerrarumSansBitmap] font is enlisted as variable on the name but not named as")
-
-
- val image: Image
-
-
- // unpack gz if applicable
- if (it.endsWith(".gz")) {
- val gzi = GZIPInputStream(FileInputStream(fontParentDir + it))
- val wholeFile = gzi.readBytes()
- gzi.close()
- val fos = BufferedOutputStream(FileOutputStream("tmp_wenquanyi.tga"))
- fos.write(wholeFile)
- fos.flush()
- fos.close()
-
- image = Image("tmp_wenquanyi.tga")
-
- File("tmp_wenquanyi.tga").delete()
- }
- else {
- image = Image(fontParentDir + it)
- }
-
- val texture = image.texture
-
- if (isVariable) {
- println("[TerrarumSansBitmap] loading texture $it [VARIABLE]")
- buildWidthTable(texture, codeRange[index], 16)
- }
- else {
- println("[TerrarumSansBitmap] loading texture $it")
- }
-
- val texRegPack = if (isVariable) {
- SpriteSheet(image, W_VAR_INIT, H - 1, HGAP_VAR)
- }
- else if (index == SHEET_UNIHAN) {
- SpriteSheet(image, W_UNIHAN, H_UNIHAN) // the only exception that is height is 16
- }
- // below they all have height of 20 'H'
- else if (index == SHEET_FW_UNI) {
- SpriteSheet(image, W_UNIHAN, H)
- }
- else if (index == SHEET_CJK_PUNCT) {
- SpriteSheet(image, W_ASIAN_PUNCT, H)
- }
- else if (index == SHEET_KANA) {
- SpriteSheet(image, W_KANA, H)
- }
- else if (index == SHEET_HANGUL) {
- SpriteSheet(image, W_HANGUL, H)
- }
- else if (index == SHEET_CUSTOM_SYM) {
- SpriteSheet(image, SIZE_CUSTOM_SYM, SIZE_CUSTOM_SYM) // TODO variable
- }
- else throw IllegalArgumentException("[TerrarumSansBitmap] Unknown sheet index: $index")
-
-
- sheetsPack.add(texRegPack)
- }
-
- sheets = sheetsPack.toTypedArray()
- }
-
- private var localeBuffer = ""
-
- fun reload(locale: String) {
- if (!localeBuffer.startsWith("ru") && locale.startsWith("ru")) {
- val image = Image(fontParentDir + fileList[SHEET_CYRILIC_VARW])
- sheets[SHEET_CYRILIC_VARW].destroy()
- sheets[SHEET_CYRILIC_VARW] = SpriteSheet(image, W_VAR_INIT, H, HGAP_VAR, 0)
- }
- else if (!localeBuffer.startsWith("bg") && locale.startsWith("bg")) {
- val image = Image(fontParentDir + cyrilic_bg)
- sheets[SHEET_CYRILIC_VARW].destroy()
- sheets[SHEET_CYRILIC_VARW] = SpriteSheet(image, W_VAR_INIT, H, HGAP_VAR, 0)
- }
- else if (!localeBuffer.startsWith("sr") && locale.startsWith("sr")) {
- val image = Image(fontParentDir + cyrilic_sr)
- sheets[SHEET_CYRILIC_VARW].destroy()
- sheets[SHEET_CYRILIC_VARW] = SpriteSheet(image, W_VAR_INIT, H, HGAP_VAR, 0)
- }
-
- localeBuffer = locale
- }
-
- override fun getLineHeight(): Int = H
- override fun getHeight(p0: String) = lineHeight
-
-
-
-
- private val offsetUnihan = (H - H_UNIHAN) / 2
- private val offsetCustomSym = (H - SIZE_CUSTOM_SYM) / 2
-
- private var textBuffer: CharSequence = ""
- private var textBWidth = intArrayOf() // absolute posX of glyphs from print-origin
- private var textBGSize = intArrayOf() // width of each glyph
-
- override fun drawString(x: Float, y: Float, str: String) {
- drawString(x, y, str, Color.white)
- }
-
- override fun drawString(p0: Float, p1: Float, p2: String?, p3: Color?, p4: Int, p5: Int) {
- throw UnsupportedOperationException()
- }
-
- override fun drawString(x: Float, y: Float, str: String, color: Color) {
- if (textBuffer != str) {
- textBuffer = str
- val widths = getWidthOfCharSeq(str)
-
- textBGSize = widths
-
- textBWidth = IntArray(str.length, { charIndex ->
- if (charIndex == 0)
- 0
- else {
- var acc = 0
- (0..charIndex - 1).forEach { acc += maxOf(0, widths[it]) } // don't accumulate diacrtics (which has negative value)
- /*return*/acc
- }
- })
- }
-
-
- //print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
- //textBWidth.forEach { print("$it ") }; println()
-
-
- val mainCol = color
- val shadowCol = color.darker(0.5f)
-
-
- textBuffer.forEachIndexed { index, c ->
- val sheetID = getSheetType(c)
- val sheetXY = getSheetwisePosition(c)
-
- //println("[TerrarumSansBitmap] sprite: $sheetID:${sheetXY[0]}x${sheetXY[1]}")
-
- if (sheetID == SHEET_HANGUL) {
- val hangulSheet = sheets[SHEET_HANGUL]
- val hIndex = c.toInt() - 0xAC00
-
- val indexCho = getHanChosung(hIndex)
- val indexJung = getHanJungseong(hIndex)
- val indexJong = getHanJongseong(hIndex)
-
- val choRow = getHanInitialRow(hIndex)
- val jungRow = getHanMedialRow(hIndex)
- val jongRow = getHanFinalRow(hIndex)
-
-
- if (!noShadow) {
- hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index] + 1, y, shadowCol)
- hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index] , y, shadowCol)
- hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index] + 1, y, shadowCol)
-
- hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index] + 1, y, shadowCol)
- hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index] , y, shadowCol)
- hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index] + 1, y, shadowCol)
-
- hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index] + 1, y, shadowCol)
- hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index] , y, shadowCol)
- hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index] + 1, y, shadowCol)
- }
-
-
- hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index], y, mainCol)
- hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index], y, mainCol)
- hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index], y, mainCol)
- }
- else {
- try {
- val offset = if (!isDiacritics(c)) 0 else {
- if (index > 0) // LIMITATION: does not support double (or more) diacritics properly
- (textBGSize[index] - textBGSize[index - 1]) / 2
- else
- textBGSize[index]
- }
-
- if (!noShadow) {
- sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
- x + textBWidth[index] + 1 + offset,
- y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym
- else
- 0),
- shadowCol
- )
- sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
- x + textBWidth[index] + offset,
- y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan + 1
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym + 1
- else
- 1),
- shadowCol
- )
- sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
- x + textBWidth[index] + 1 + offset,
- y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan + 1
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym + 1
- else
- 1),
- shadowCol
- )
- }
-
-
- sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
- x + textBWidth[index] + offset,
- y + if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym
- else 0,
- mainCol
- )
- }
- catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
- }
- }
- }
-
- }
-
-
- fun dispose() {
- sheets.forEach { it.destroy() }
- }
-
- private fun getWidthOfCharSeq(s: CharSequence): IntArray {
- val len = IntArray(s.length)
- for (i in 0..s.lastIndex) {
- val chr = s[i]
- val ctype = getSheetType(s[i])
-
- if (variableWidthSheets.contains(ctype)) {
- if (!glyphWidths.containsKey(chr.toInt())) {
- println("[TerrarumSansBitmap] no width data for glyph number ${Integer.toHexString(chr.toInt()).toUpperCase()}")
- len[i] = W_LATIN_WIDE
- }
-
- len[i] = glyphWidths[chr.toInt()]!!
- }
- else if (ctype == SHEET_CJK_PUNCT)
- len[i] = W_ASIAN_PUNCT
- else if (ctype == SHEET_HANGUL)
- len[i] = W_HANGUL
- else if (ctype == SHEET_KANA)
- len[i] = W_KANA
- else if (unihanWidthSheets.contains(ctype))
- len[i] = W_UNIHAN
- else if (ctype == SHEET_CUSTOM_SYM)
- len[i] = SIZE_CUSTOM_SYM
- else
- len[i] = W_LATIN_WIDE
-
- if (scale > 1) len[i] *= scale
-
- if (i < s.lastIndex) len[i] += interchar
- }
- return len
- }
-
- private fun getSheetType(c: Char): Int {
- if (isHangul(c))
- return SHEET_HANGUL
- else if (isKana(c))
- return SHEET_KANA
- else if (isUniHan(c))
- return SHEET_UNIHAN
- else if (isAscii(c))
- return SHEET_ASCII_VARW
- else if (isExtA(c))
- return SHEET_EXTA_VARW
- else if (isExtB(c))
- return SHEET_EXTB_VARW
- else if (isCyrilic(c))
- return SHEET_CYRILIC_VARW
- else if (isUniPunct(c))
- return SHEET_UNI_PUNCT
- else if (isCJKPunct(c))
- return SHEET_CJK_PUNCT
- else if (isFullwidthUni(c))
- return SHEET_FW_UNI
- else if (isGreek(c))
- return SHEET_GREEK_VARW
- else if (isThai(c))
- return SHEET_THAI_VARW
- else if (isCustomSym(c))
- return SHEET_CUSTOM_SYM
- else if (isArmenian(c))
- return SHEET_HAYEREN_VARW
- else if (isKartvelian(c))
- return SHEET_KARTULI_VARW
- else if (isIPA(c))
- return SHEET_IPA_VARW
- else
- return SHEET_UNKNOWN
- // fixed width
- // fallback
- }
-
- private fun getSheetwisePosition(ch: Char): IntArray {
- val sheetX: Int; val sheetY: Int
- when (getSheetType(ch)) {
- SHEET_UNIHAN -> {
- sheetX = unihanIndexX(ch)
- sheetY = unihanIndexY(ch)
- }
- SHEET_EXTA_VARW -> {
- sheetX = extAindexX(ch)
- sheetY = extAindexY(ch)
- }
- SHEET_EXTB_VARW -> {
- sheetX = extBindexX(ch)
- sheetY = extBindexY(ch)
- }
- SHEET_KANA -> {
- sheetX = kanaIndexX(ch)
- sheetY = kanaIndexY(ch)
- }
- SHEET_CJK_PUNCT -> {
- sheetX = cjkPunctIndexX(ch)
- sheetY = cjkPunctIndexY(ch)
- }
- SHEET_CYRILIC_VARW -> {
- sheetX = cyrilicIndexX(ch)
- sheetY = cyrilicIndexY(ch)
- }
- SHEET_FW_UNI -> {
- sheetX = fullwidthUniIndexX(ch)
- sheetY = fullwidthUniIndexY(ch)
- }
- SHEET_UNI_PUNCT -> {
- sheetX = uniPunctIndexX(ch)
- sheetY = uniPunctIndexY(ch)
- }
- SHEET_GREEK_VARW -> {
- sheetX = greekIndexX(ch)
- sheetY = greekIndexY(ch)
- }
- SHEET_THAI_VARW -> {
- sheetX = thaiIndexX(ch)
- sheetY = thaiIndexY(ch)
- }
- SHEET_CUSTOM_SYM -> {
- sheetX = symbolIndexX(ch)
- sheetY = symbolIndexY(ch)
- }
- SHEET_HAYEREN_VARW -> {
- sheetX = armenianIndexX(ch)
- sheetY = armenianIndexY(ch)
- }
- SHEET_KARTULI_VARW -> {
- sheetX = kartvelianIndexX(ch)
- sheetY = kartvelianIndexY(ch)
- }
- SHEET_IPA_VARW -> {
- sheetX = ipaIndexX(ch)
- sheetY = ipaIndexY(ch)
- }
- else -> {
- sheetX = ch.toInt() % 16
- sheetY = ch.toInt() / 16
- }
- }
-
- return intArrayOf(sheetX, sheetY)
- }
-
- fun buildWidthTable(texture: Texture, codeRange: IntRange, cols: Int = 16) {
- val binaryCodeOffset = W_VAR_INIT
-
- val cellW = W_VAR_INIT + 1
- val cellH = H
-
- for (code in codeRange) {
-
- val cellX = ((code - codeRange.start) % cols) * cellW
- val cellY = ((code - codeRange.start) / cols) * cellH
-
- val codeStartX = cellX + binaryCodeOffset
- val codeStartY = cellY
-
- var glyphWidth = 0
-
- for (downCtr in 0..3) {
- // if ALPHA is not zero, assume it's 1
- if (texture.textureData[4 * (codeStartX + (codeStartY + downCtr) * texture.textureWidth) + 3] != 0.toByte()) {
- glyphWidth = glyphWidth or (1 shl downCtr)
- }
- }
-
- val isDiacritics = texture.textureData[4 * (codeStartX + (codeStartY + H - 1) * texture.textureWidth) + 3] != 0.toByte()
- if (isDiacritics)
- glyphWidth = -glyphWidth
-
- glyphWidths[code] = glyphWidth
- }
- }
-
-
- override fun getWidth(text: String): Int {
- return getWidthOfCharSeq(text).sum()
- }
-
- companion object {
-
- internal val JUNG_COUNT = 21
- internal val JONG_COUNT = 28
-
- internal val W_ASIAN_PUNCT = 10
- internal val W_HANGUL = 12
- internal val W_KANA = 12
- internal val W_UNIHAN = 16
- internal val W_LATIN_WIDE = 9 // width of regular letters
- internal val W_VAR_INIT = 15
-
- internal val HGAP_VAR = 1
-
- internal val H = 20
- internal val H_UNIHAN = 16
-
- internal val SIZE_CUSTOM_SYM = 18
-
- internal val SHEET_ASCII_VARW = 0
- internal val SHEET_HANGUL = 1
- internal val SHEET_EXTA_VARW = 2
- internal val SHEET_EXTB_VARW = 3
- internal val SHEET_KANA = 4
- internal val SHEET_CJK_PUNCT = 5
- internal val SHEET_UNIHAN = 6
- internal val SHEET_CYRILIC_VARW = 7
- internal val SHEET_FW_UNI = 8
- internal val SHEET_UNI_PUNCT = 9
- internal val SHEET_GREEK_VARW = 10
- internal val SHEET_THAI_VARW = 11
- internal val SHEET_HAYEREN_VARW = 12
- internal val SHEET_KARTULI_VARW = 13
- internal val SHEET_IPA_VARW = 14
- internal val SHEET_CUSTOM_SYM = 15
-
- internal val SHEET_UNKNOWN = 254
-
- /**
- * Runic letters list used for game. The set is
- * Younger Futhark + Medieval rune 'e' + Punct + Runic Almanac
-
- * BEWARE OF SIMILAR-LOOKING RUNES, especially:
-
- * * Algiz ᛉ instead of Maðr ᛘ
-
- * * Short-Twig Hagall ᚽ instead of Runic Letter E ᛂ
-
- * * Runic Letter OE ᚯ instead of Óss ᚬ
-
- * Examples:
- * ᛭ᛋᛁᚴᚱᛁᚦᛦ᛭
- * ᛭ᛂᛚᛋᛅ᛭ᛏᚱᚢᛏᚾᛁᚾᚴᚢᚾᛅ᛬ᛅᚱᚾᛅᛏᛅᛚᛋ
- */
- //internal val runicList = arrayOf('ᚠ', 'ᚢ', 'ᚦ', 'ᚬ', 'ᚱ', 'ᚴ', 'ᚼ', 'ᚾ', 'ᛁ', 'ᛅ', 'ᛋ', 'ᛏ', 'ᛒ', 'ᛘ', 'ᛚ', 'ᛦ', 'ᛂ', '᛬', '᛫', '᛭', 'ᛮ', 'ᛯ', 'ᛰ')
- // TODO expand to full Unicode runes
-
- var interchar = 0
- var scale = 1
- set(value) {
- if (value > 0) field = value
- else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)")
- }
- }
-
-}
\ No newline at end of file
diff --git a/demo/src/net/torvald/terrarum/imagefont/GameFontDemo.kt b/demo/src/net/torvald/terrarum/imagefont/GameFontDemo.kt
deleted file mode 100644
index 477f4b2..0000000
--- a/demo/src/net/torvald/terrarum/imagefont/GameFontDemo.kt
+++ /dev/null
@@ -1,97 +0,0 @@
-package net.torvald.terrarum.imagefont
-
-import net.torvald.terrarumsansbitmap.slick2d.GameFontBase
-import org.newdawn.slick.*
-import java.io.File
-import java.io.FileInputStream
-import java.nio.file.FileSystems
-import java.nio.file.Files
-import java.util.*
-
-/**
- * Created by SKYHi14 on 2017-02-16.
- */
-
-class GameFontDemo : BasicGame("Terrarum Sans Bitmap Demo") {
-
- lateinit var gameFont: Font
-
- override fun init(p0: GameContainer?) {
- gameFont = GameFontBase("assets/")
- }
-
- override fun update(gc: GameContainer, delta: Int) {
- appgc!!.setTitle("Terrarum Sans Bitmap — F: ${gc.fps}")
- }
-
- override fun render(gc: GameContainer, g: Graphics) {
- g.font = gameFont
- g.background = Color(0x282828)
- text.forEachIndexed { i, s ->
- g.drawString(s, 10f, 10f + i * gameFont.lineHeight)
- }
- }
-
- companion object {
- lateinit var gameLocale: String
- var hasError: Boolean
- val text = ArrayList()
-
- init {
- try {
- val prop = Properties()
- prop.load(FileInputStream("./config.properties"))
-
- gameLocale = prop.getProperty("locale")
-
- if (gameLocale.length < 2)
- throw IllegalArgumentException("Bad locale setting: “$gameLocale”")
-
-
- Files.lines(FileSystems.getDefault().getPath("./text.txt")).forEach(
- { text.add(it) }
- )
-
- hasError = false
- }
- catch (e: Exception) {
- gameLocale = "enUS"
- hasError = true
- text.add("There was some problem loading the demo :(")
- text.add("This is what JVM says:")
- text.add("")
- e.message!!.split('\n').forEach {
- text.add(it)
- }
- }
- }
- }
-}
-
-var appgc: AppGameContainer? = null
-
-fun main(args: Array) {
-
- System.setProperty("java.library.path", "lib")
- System.setProperty("org.lwjgl.librarypath", File("lib").absolutePath)
-
- val WIDTH = 1000
- val HEIGHT = 800
-
- try {
- appgc = AppGameContainer(GameFontDemo())
- appgc!!.setDisplayMode(WIDTH, HEIGHT, false)
-
- appgc!!.setMultiSample(0)
- appgc!!.setShowFPS(false)
-
- // game will run normally even if it is not focused
- appgc!!.setUpdateOnlyWhenVisible(false)
- appgc!!.alwaysRender = true
-
- appgc!!.start()
- }
- catch (ex: Exception) {
- ex.printStackTrace()
- }
-}
\ No newline at end of file