diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d571c65..7d13a63 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,11 +7,8 @@
-
-
-
-
+
@@ -32,8 +29,8 @@
-
-
+
+
@@ -78,11 +75,11 @@
-
+
-
-
+
+
@@ -90,8 +87,8 @@
-
-
+
+
@@ -105,11 +102,11 @@
-
+
-
-
+
+
@@ -193,9 +190,9 @@
-
+
@@ -844,13 +841,6 @@
-
-
-
-
-
-
-
@@ -893,15 +883,8 @@
-
-
-
-
-
-
-
-
-
+
+
@@ -912,10 +895,24 @@
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
diff --git a/FontTestGDX/lib/TerrarumSansBitmap.jar b/FontTestGDX/lib/TerrarumSansBitmap.jar
index 5dc7bc5..4ec5919 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 b2fb49f..518ffc0 100644
--- a/FontTestGDX/src/FontTestGDX.kt
+++ b/FontTestGDX/src/FontTestGDX.kt
@@ -5,7 +5,10 @@ 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.g2d.SpriteBatch
+import com.badlogic.gdx.graphics.glutils.FrameBuffer
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
/**
@@ -19,6 +22,8 @@ class FontTestGDX : Game() {
lateinit var batch: SpriteBatch
+ lateinit var frameBuffer: FrameBuffer
+
override fun create() {
font = GameFontBase("./assets", flipY = false, errorOnUnknownChar = true) // must test for two flipY cases
@@ -135,6 +140,7 @@ class FontTestGDX : Game() {
println(font.toColorCode(0xF_F55))
println(font.toColorCode(0xE_CCC))
+ frameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, appConfig.width, appConfig.height, true)
}
override fun getScreen(): Screen? {
@@ -144,22 +150,39 @@ class FontTestGDX : Game() {
override fun setScreen(screen: Screen?) {
}
+ var tex: Texture? = null
+
override fun render() {
- Gdx.gl.glClearColor(.141f, .141f, .141f, 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)
+ if (tex == null) {
+ frameBuffer.begin()
+
+ Gdx.gl.glClearColor(.141f, .141f, .141f, 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)
+
+ batch.begin()
+
+ batch.color = Color(0xeeeeeeff.toInt())
+ inputText.forEachIndexed { index, s ->
+ font.draw(batch, s, 10f, appConfig.height - 30f - index * font.lineHeight)
+ }
+
+ batch.end()
+
+ frameBuffer.end()
+
+ ///////////////
+
+ tex = frameBuffer.colorBufferTexture
+ }
batch.begin()
-
- batch.color = Color(0xeeeeeeff.toInt())
- inputText.forEachIndexed { index, s ->
- font.draw(batch, s, 10f, appConfig.height - 30f - index * font.lineHeight)
- }
-
+ batch.color = Color.WHITE
+ batch.draw(tex, 0f, appConfig.height.toFloat(), appConfig.width.toFloat(), -appConfig.height.toFloat())
batch.end()
}
@@ -183,7 +206,7 @@ fun main(args: Array) {
appConfig = LwjglApplicationConfiguration()
appConfig.vSyncEnabled = false
appConfig.resizable = false//true;
- appConfig.width = 960
+ appConfig.width = 874
appConfig.height = 2048
appConfig.title = "Terrarum Sans Bitmap Test (GDX)"
diff --git a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
index 31b3cc1..6fb3f86 100644
--- a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
+++ b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
@@ -544,16 +544,16 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
batch.color = shadowCol
batch.draw(hangulSheet.get(indexCho, choRow ), x + posXbuffer[index] + 1, y)
- batch.draw(hangulSheet.get(indexCho, choRow ), x + posXbuffer[index] , y + if (flipY) 1 else -1)
- batch.draw(hangulSheet.get(indexCho, choRow ), x + posXbuffer[index] + 1, y + if (flipY) 1 else -1)
+ batch.draw(hangulSheet.get(indexCho, choRow ), x + posXbuffer[index] , y + 1.flipY())
+ batch.draw(hangulSheet.get(indexCho, choRow ), x + posXbuffer[index] + 1, y + 1.flipY())
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] + 1, y)
- batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] , y + if (flipY) 1 else -1)
- batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] + 1, y + if (flipY) 1 else -1)
+ batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] , y + 1.flipY())
+ batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] + 1, y + 1.flipY())
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] + 1, y)
- batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] , y + if (flipY) 1 else -1)
- batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] + 1, y + if (flipY) 1 else -1)
+ batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] , y + 1.flipY())
+ batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] + 1, y + 1.flipY())
}
@@ -564,61 +564,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
else {
try {
- /*val offset = if (!isDiacritics(c)) 0 else {
- if (index > 0) // LIMITATION: does not support double (or more) diacritics properly
- (glyphWidthBuffer[index] - glyphWidthBuffer[index - 1]) / 2
- else
- glyphWidthBuffer[index]
- }
- if (!noShadow) {
- batch.color = shadowCol
- batch.draw(
- sheets[sheetID].get(sheetX, sheetY),
- x + posXbuffer[index] + 1 + offset,
- y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan.flipY()
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym
- else
- 0) * if (flipY) 1 else -1
- )
- batch.draw(
- sheets[sheetID].get(sheetX, sheetY),
- x + posXbuffer[index] + offset,
- y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan.flipY() + 1
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym + 1
- else
- 1) * if (flipY) 1 else -1
- )
- batch.draw(
- sheets[sheetID].get(sheetX, sheetY),
- x + posXbuffer[index] + 1 + offset,
- y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan.flipY() + 1
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym + 1
- else
- 1).flipY()
- )
- }
-
-
- batch.color = mainCol
- batch.draw(
- sheets[sheetID].get(sheetX, sheetY),
- x + posXbuffer[index] + offset,
- y +
- if (sheetID == SHEET_UNIHAN) // evil exceptions
- offsetUnihan
- else if (sheetID == SHEET_CUSTOM_SYM)
- offsetCustomSym
- else 0
- )*/
-
- batch.color = mainCol
val posY = y + posYbuffer[index].flipY() +
if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan
@@ -629,6 +575,15 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
val posX = x + posXbuffer[index]
val texture = sheets[sheetID].get(sheetX, sheetY)
+
+ if (!noShadow) {
+ batch.color = shadowCol
+ batch.draw(texture, posX + 1, posY + 1.flipY())
+ batch.draw(texture, posX , posY + 1.flipY())
+ batch.draw(texture, posX + 1, posY)
+ }
+
+ batch.color = mainCol
batch.draw(texture, posX, posY)
}
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {