diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7d13a63..7119cde 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,8 +7,10 @@
+
+
@@ -29,8 +31,8 @@
-
-
+
+
@@ -78,26 +80,25 @@
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
-
-
+
+
@@ -105,8 +106,8 @@
-
-
+
+
@@ -138,7 +139,6 @@
- fun dispo
xHei
not copy
getColour
@@ -164,15 +164,17 @@
buildWidthTable
lastNonDiacriticChar
c.toInt()
- ArrayList<Int>
har.toInt()
println
!!
+ ArrayList<Int>
+ appConfig.height
.141
c
har
+ TEXH
@@ -464,7 +466,6 @@
-
@@ -476,7 +477,7 @@
-
+
@@ -527,27 +528,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -881,20 +861,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -902,17 +868,55 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
diff --git a/FontTestGDX/demotext.txt b/FontTestGDX/demotext.txt
index abb62c3..4f5417e 100644
--- a/FontTestGDX/demotext.txt
+++ b/FontTestGDX/demotext.txt
@@ -88,10 +88,11 @@ 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
- CJK Unihan Extension A CJK Unihan Hangul Syllables Fullwidth Forms
+ 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
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 changes,
-and make a pull request! I appreciate any and all supports.
\ No newline at end of file
+You can help this font to be more versatile. (for more languages, more frameworks) Clone this repo, make
+changes, and make a pull request! I appreciate any and all supports.
\ No newline at end of file
diff --git a/FontTestGDX/lib/TerrarumSansBitmap.jar b/FontTestGDX/lib/TerrarumSansBitmap.jar
index 4ec5919..d2d8c0b 100644
Binary files a/FontTestGDX/lib/TerrarumSansBitmap.jar and b/FontTestGDX/lib/TerrarumSansBitmap.jar differ
diff --git a/FontTestGDX/src/FontTestGDX.kt b/FontTestGDX/src/FontTestGDX.kt
index 518ffc0..74e8bfd 100644
--- a/FontTestGDX/src/FontTestGDX.kt
+++ b/FontTestGDX/src/FontTestGDX.kt
@@ -1,14 +1,10 @@
-import com.badlogic.gdx.Game
-import com.badlogic.gdx.Gdx
-import com.badlogic.gdx.Screen
+import com.badlogic.gdx.*
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
-import com.badlogic.gdx.graphics.Color
-import com.badlogic.gdx.graphics.GL20
-import com.badlogic.gdx.graphics.Pixmap
-import com.badlogic.gdx.graphics.Texture
+import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer
+import com.badlogic.gdx.utils.ScreenUtils
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
/**
@@ -24,6 +20,8 @@ class FontTestGDX : Game() {
lateinit var frameBuffer: FrameBuffer
+ lateinit var camera: OrthographicCamera
+
override fun create() {
font = GameFontBase("./assets", flipY = false, errorOnUnknownChar = true) // must test for two flipY cases
@@ -140,17 +138,28 @@ class FontTestGDX : Game() {
println(font.toColorCode(0xF_F55))
println(font.toColorCode(0xE_CCC))
- frameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, appConfig.width, appConfig.height, true)
+ frameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, TEXW, TEXH, true)
+
+ camera = OrthographicCamera(TEXW.toFloat(), TEXH.toFloat())
+ camera.translate(TEXW.div(2f), 0f)
+ camera.setToOrtho(true, TEXW.toFloat(), TEXH.toFloat())
+ camera.update()
+
+
+ Gdx.input.inputProcessor = Navigator(this)
}
override fun getScreen(): Screen? {
return null
}
+ var scrollOffsetY = 0f
+
override fun setScreen(screen: Screen?) {
}
var tex: Texture? = null
+ var screenshotExported = false
override fun render() {
@@ -163,15 +172,28 @@ class FontTestGDX : Game() {
Gdx.gl.glEnable(GL20.GL_BLEND)
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
+ batch.projectionMatrix = camera.combined
batch.begin()
batch.color = Color(0xeeeeeeff.toInt())
inputText.forEachIndexed { index, s ->
- font.draw(batch, s, 10f, appConfig.height - 30f - index * font.lineHeight)
+ font.draw(batch, s, 10f, TEXH - 30f - index * font.lineHeight)
}
batch.end()
+
+ // dump to file
+ if (!screenshotExported) {
+ val pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, frameBuffer.width, frameBuffer.height)
+
+ PixmapIO.writePNG(Gdx.files.local("demo.PNG"), pixmap)
+ pixmap.dispose()
+
+ screenshotExported = true
+ }
+
+
frameBuffer.end()
///////////////
@@ -179,10 +201,9 @@ class FontTestGDX : Game() {
tex = frameBuffer.colorBufferTexture
}
-
batch.begin()
batch.color = Color.WHITE
- batch.draw(tex, 0f, appConfig.height.toFloat(), appConfig.width.toFloat(), -appConfig.height.toFloat())
+ batch.draw(tex, 0f, (TEXH.toFloat()/appConfig.height)*TEXH - scrollOffsetY, TEXW.toFloat(), -(TEXH.toFloat() / appConfig.height) * TEXH.toFloat())
batch.end()
}
@@ -198,16 +219,46 @@ class FontTestGDX : Game() {
override fun dispose() {
font.dispose()
}
+
+ fun scrollAdd(x: Int = 1) {
+ scrollOffsetY -= (TEXH.toFloat() / appConfig.height) * 20f * x
+ }
+
+ fun scrollSub(x: Int = 1) {
+ scrollOffsetY += (TEXH.toFloat() / appConfig.height) * 20f * x
+ }
+
+ class Navigator(val main: FontTestGDX) : InputAdapter() {
+ override fun scrolled(amount: Int): Boolean {
+ if (amount >= 0)
+ main.scrollSub(amount)
+ else
+ main.scrollAdd(-amount)
+
+ return true
+ }
+
+ override fun keyDown(keycode: Int): Boolean {
+ if (keycode == Input.Keys.UP)
+ main.scrollAdd()
+ else if (keycode == Input.Keys.DOWN)
+ main.scrollSub()
+
+ return true
+ }
+ }
}
lateinit var appConfig: LwjglApplicationConfiguration
+const val TEXW = 874
+const val TEXH = 2048
fun main(args: Array) {
appConfig = LwjglApplicationConfiguration()
appConfig.vSyncEnabled = false
appConfig.resizable = false//true;
- appConfig.width = 874
- appConfig.height = 2048
+ appConfig.width = TEXW
+ appConfig.height = 768
appConfig.title = "Terrarum Sans Bitmap Test (GDX)"
LwjglApplication(FontTestGDX(), appConfig)
diff --git a/demo.PNG b/demo.PNG
index 956a6c0..55fadd7 100644
Binary files a/demo.PNG and b/demo.PNG differ
diff --git a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
index 6fb3f86..3bc7267 100644
--- a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
+++ b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
@@ -313,17 +313,19 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
// unpack gz if applicable
if (it.endsWith(".gz")) {
+ val tmpFileName = "tmp_${it.dropLast(7)}.tga"
+
val gzi = GZIPInputStream(Gdx.files.internal(fontParentDir + it).read(8192))
val wholeFile = gzi.readBytes()
gzi.close()
- val fos = BufferedOutputStream(FileOutputStream("tmp_wenquanyi.tga"))
+ val fos = BufferedOutputStream(FileOutputStream(tmpFileName))
fos.write(wholeFile)
fos.flush()
fos.close()
- pixmap = Pixmap(Gdx.files.internal("tmp_wenquanyi.tga"))
+ pixmap = Pixmap(Gdx.files.internal(tmpFileName))
- File("tmp_wenquanyi.tga").delete()
+ File(tmpFileName).delete()
}
else {
pixmap = Pixmap(Gdx.files.internal(fontParentDir + it))