mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-06-14 01:24:05 +09:00
lemme have some debugging helper
This commit is contained in:
@@ -20,7 +20,7 @@ class FontTestGDX : Game() {
|
|||||||
lateinit var batch: SpriteBatch
|
lateinit var batch: SpriteBatch
|
||||||
|
|
||||||
override fun create() {
|
override fun create() {
|
||||||
font = GameFontBase("./assets", flipY = false) // must test for two cases
|
font = GameFontBase("./assets", flipY = false, errorOnUnknownChar = true) // must test for two flipY cases
|
||||||
|
|
||||||
val inTextFile = Gdx.files.internal("./FontTestGDX/demotext.txt")
|
val inTextFile = Gdx.files.internal("./FontTestGDX/demotext.txt")
|
||||||
val reader = inTextFile.reader()
|
val reader = inTextFile.reader()
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ typealias CodepointSequence = ArrayList<Int>
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2017-06-15.
|
* Created by minjaesong on 2017-06-15.
|
||||||
*/
|
*/
|
||||||
class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Boolean = false, val minFilter: Texture.TextureFilter = Texture.TextureFilter.Nearest, val magFilter: Texture.TextureFilter = Texture.TextureFilter.Nearest) : BitmapFont() {
|
class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Boolean = false, val minFilter: Texture.TextureFilter = Texture.TextureFilter.Nearest, val magFilter: Texture.TextureFilter = Texture.TextureFilter.Nearest, var errorOnUnknownChar: Boolean = false) : BitmapFont() {
|
||||||
|
|
||||||
private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
|
private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
|
||||||
private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
|
private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
|
||||||
@@ -398,6 +398,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
|||||||
|
|
||||||
private lateinit var originalColour: Color
|
private lateinit var originalColour: Color
|
||||||
|
|
||||||
|
private var nullProp = GlyphProps(15, 0)
|
||||||
|
|
||||||
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
|
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
|
||||||
val str = str.toCodePoints()
|
val str = str.toCodePoints()
|
||||||
|
|
||||||
@@ -427,12 +429,16 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
|||||||
// nonDiacriticCounter allows multiple diacritics
|
// nonDiacriticCounter allows multiple diacritics
|
||||||
|
|
||||||
val thisChar = textBuffer[charIndex]
|
val thisChar = textBuffer[charIndex]
|
||||||
if (glyphProps[thisChar] == null) {
|
if (glyphProps[thisChar] == null && errorOnUnknownChar) {
|
||||||
throw InternalError("No props for char '$thisChar' (${thisChar.toString(16)})")
|
val errorGlyphSB = StringBuilder()
|
||||||
|
Character.toChars(thisChar).forEach { errorGlyphSB.append(it) }
|
||||||
|
|
||||||
|
throw InternalError("No GlyphProps for char '$errorGlyphSB' " +
|
||||||
|
"(U+${thisChar.toString(16).toUpperCase()}: ${Character.getName(thisChar)})")
|
||||||
}
|
}
|
||||||
val thisProp = glyphProps[thisChar]!!
|
val thisProp = glyphProps[thisChar] ?: nullProp
|
||||||
val lastNonDiacriticChar = textBuffer[nonDiacriticCounter]
|
val lastNonDiacriticChar = textBuffer[nonDiacriticCounter]
|
||||||
val itsProp = glyphProps[lastNonDiacriticChar]!!
|
val itsProp = glyphProps[lastNonDiacriticChar] ?: nullProp
|
||||||
|
|
||||||
|
|
||||||
//println("char: $thisChar; properties: $thisProp")
|
//println("char: $thisChar; properties: $thisProp")
|
||||||
@@ -649,7 +655,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
|||||||
len[i] = W_LATIN_WIDE
|
len[i] = W_LATIN_WIDE
|
||||||
}
|
}
|
||||||
|
|
||||||
val prop = glyphProps[chr]!!
|
val prop = glyphProps[chr] ?: nullProp
|
||||||
//println("${chr.toInt()} -> $prop")
|
//println("${chr.toInt()} -> $prop")
|
||||||
len[i] = prop.width * (if (prop.writeOnTop) -1 else 1)
|
len[i] = prop.width * (if (prop.writeOnTop) -1 else 1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user