mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-07 20:01:52 +09:00
fixed up the test app
- exports the drawn text as demo.PNG - scrollable with scroll wheels and arrow keys
This commit is contained in:
122
.idea/workspace.xml
generated
122
.idea/workspace.xml
generated
@@ -7,8 +7,10 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="22c5bc80-996c-4846-b173-7dc8c2096fe3" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/FontTestGDX/demotext.txt" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/demotext.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/demo.PNG" beforeDir="false" afterPath="$PROJECT_DIR$/demo.PNG" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
@@ -29,8 +31,8 @@
|
||||
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="287">
|
||||
<caret line="852" lean-forward="true" selection-start-line="852" selection-end-line="852" />
|
||||
<state relative-caret-position="8256">
|
||||
<caret line="865" column="33" lean-forward="true" selection-start-line="865" selection-start-column="33" selection-end-line="865" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -78,26 +80,25 @@
|
||||
<file leaf-file-name="FontTestGDX.kt" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="469">
|
||||
<caret line="173" column="26" lean-forward="true" selection-start-line="173" selection-start-column="26" selection-end-line="173" selection-end-column="26" />
|
||||
<state relative-caret-position="507">
|
||||
<caret line="253" column="21" selection-start-line="253" selection-start-column="21" selection-end-line="253" selection-end-column="21" />
|
||||
<folding>
|
||||
<element signature="e#0#384#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="false">
|
||||
<entry file="jar://$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar!/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="390">
|
||||
<caret line="446" column="21" lean-forward="true" selection-start-line="446" selection-start-column="21" selection-end-line="446" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
<file leaf-file-name="demo.PNG" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/demo.PNG">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="demotext.txt" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="494">
|
||||
<caret line="38" column="5" selection-start-line="38" selection-start-column="5" selection-end-line="38" selection-end-column="5" />
|
||||
<state relative-caret-position="-1">
|
||||
<caret line="41" column="49" lean-forward="true" selection-start-line="41" selection-start-column="49" selection-end-line="41" selection-end-column="49" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -105,8 +106,8 @@
|
||||
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="576">
|
||||
<caret line="583" column="21" lean-forward="true" selection-start-line="583" selection-start-column="21" selection-end-line="583" selection-end-column="21" />
|
||||
<state relative-caret-position="468">
|
||||
<caret line="331" column="13" lean-forward="true" selection-start-line="331" selection-start-column="13" selection-end-line="331" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -138,7 +139,6 @@
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>fun dispo</find>
|
||||
<find>xHei</find>
|
||||
<find>not copy</find>
|
||||
<find>getColour</find>
|
||||
@@ -164,15 +164,17 @@
|
||||
<find>buildWidthTable</find>
|
||||
<find>lastNonDiacriticChar</find>
|
||||
<find>c.toInt()</find>
|
||||
<find>ArrayList<Int></find>
|
||||
<find>har.toInt()</find>
|
||||
<find>println</find>
|
||||
<find>!!</find>
|
||||
<find>ArrayList<Int></find>
|
||||
<find>appConfig.height</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>.141</replace>
|
||||
<replace>c</replace>
|
||||
<replace>har</replace>
|
||||
<replace>TEXH</replace>
|
||||
</replaceStrings>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
@@ -464,7 +466,6 @@
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1936" height="1216" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info anchor="right" id="Palette" order="3" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
@@ -476,7 +477,7 @@
|
||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||
<window_info anchor="bottom" id="Terminal" order="7" />
|
||||
<window_info id="Designer" order="2" />
|
||||
<window_info content_ui="combo" id="Project" order="0" weight="0.13859275" />
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.13859275" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.32931355" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
@@ -527,27 +528,6 @@
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1638">
|
||||
<caret line="134" column="40" selection-start-line="134" selection-start-column="40" selection-end-line="134" selection-end-column="40" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret selection-end-line="1" selection-end-column="43" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1625">
|
||||
<caret line="155" column="48" selection-start-line="155" selection-start-column="48" selection-end-line="155" selection-end-column="48" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="SPLIT">
|
||||
@@ -881,20 +861,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar://$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar!/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="390">
|
||||
<caret line="446" column="21" lean-forward="true" selection-start-line="446" selection-start-column="21" selection-end-line="446" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="494">
|
||||
<caret line="38" column="5" selection-start-line="38" selection-start-column="5" selection-end-line="38" selection-end-column="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/GlyphProps.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="260">
|
||||
@@ -902,17 +868,55 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="576">
|
||||
<caret line="583" column="21" lean-forward="true" selection-start-line="583" selection-start-column="21" selection-end-line="583" selection-end-column="21" />
|
||||
<state relative-caret-position="-1">
|
||||
<caret line="41" column="49" lean-forward="true" selection-start-line="41" selection-start-column="49" selection-end-line="41" selection-end-column="49" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="468">
|
||||
<caret line="331" column="13" lean-forward="true" selection-start-line="331" selection-start-column="13" selection-end-line="331" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar://$PROJECT_DIR$/lib/gdx.jar!/com/badlogic/gdx/graphics/glutils/GLFrameBuffer.class">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2379">
|
||||
<caret line="205" column="13" selection-start-line="205" selection-start-column="13" selection-end-line="205" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="e#7962#7963#0" expanded="true" />
|
||||
<element signature="e#8002#8003#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar://$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar!/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="390">
|
||||
<caret line="448" column="21" lean-forward="true" selection-start-line="448" selection-start-column="21" selection-end-line="448" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar://$PROJECT_DIR$/lib/gdx.jar!/com/badlogic/gdx/utils/ScreenUtils.class">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="38" column="25" selection-start-line="38" selection-start-column="25" selection-end-line="38" selection-end-column="25" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/demo.PNG">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="469">
|
||||
<caret line="173" column="26" lean-forward="true" selection-start-line="173" selection-start-column="26" selection-end-line="173" selection-end-column="26" />
|
||||
<state relative-caret-position="507">
|
||||
<caret line="253" column="21" selection-start-line="253" selection-start-column="21" selection-end-line="253" selection-end-column="21" />
|
||||
<folding>
|
||||
<element signature="e#0#384#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
||||
@@ -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.
|
||||
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.
|
||||
Binary file not shown.
@@ -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<String>) {
|
||||
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)
|
||||
|
||||
BIN
demo.PNG
BIN
demo.PNG
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 131 KiB |
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user