diff --git a/font_test_3.PNG b/font_test_3.PNG index 82edea1..447b8e6 100644 Binary files a/font_test_3.PNG and b/font_test_3.PNG differ diff --git a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt index cf27a71..8409aec 100644 --- a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt @@ -748,6 +748,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)") } + fun toColorCode(rgba4444: Int): String = GameFontBase.toColorCode(rgba4444) + fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a) + val noColorCode = toColorCode(0x0000) + companion object { internal val JUNG_COUNT = 21 internal val JONG_COUNT = 28 @@ -785,6 +789,13 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo internal val SHEET_CUSTOM_SYM = 16 internal val SHEET_UNKNOWN = 254 + + + fun toColorCode(rgba4444: Int): String = Character.toChars(0x100000 + rgba4444).toColCode() + fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a) + private fun CharArray.toColCode(): String = "${this[0]}${this[1]}" + + val noColorCode = toColorCode(0x0000) } } \ No newline at end of file diff --git a/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt b/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt index 9d2bad9..ad670ec 100644 --- a/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt +++ b/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt @@ -753,5 +753,15 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font { else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)") } + fun toColorCode(rgba4444: Int): String = GameFontBase.toColorCode(rgba4444) + fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a) + val noColorCode = toColorCode(0x0000) + companion object { + fun toColorCode(rgba4444: Int): String = Character.toChars(0x100000 + rgba4444).toColCode() + fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a) + private fun CharArray.toColCode(): String = "${this[0]}${this[1]}" + + val noColorCode = toColorCode(0x0000) + } } \ No newline at end of file