18 Commits
v1.5 ... v1.6

Author SHA1 Message Date
minjaesong
620794dc57 diacritics overlap artefacts fixed
not as I intended. fuck my life
2018-08-11 00:04:19 +09:00
minjaesong
128eeec6b5 more demotexts (more caps, sanskrit)
about to make substantial changes
2018-08-10 22:18:33 +09:00
minjaesong
33468d5ded impl of georgian mtavruli 2018-08-10 22:00:13 +09:00
minjaesong
96e5bb9a7d bitmap for Georgian Mtavruli (Georgian all-caps) 2018-08-10 21:52:15 +09:00
minjaesong
6300b29ab5 fixed up Thai and Devanagari Anusvara
not perfect but it'll work
2018-08-10 04:20:03 +09:00
minjaesong
a0e2cbf756 Devanagari BETA; broke Thai diacritics again 2018-08-10 01:29:58 +09:00
minjaesong
4a36d3e7f1 bitmap for Devanagari (only) 2018-08-09 21:11:11 +09:00
minjaesong
ab0d483cb1 somehow fixed issue #8 2018-08-09 19:32:30 +09:00
minjaesong
cdd0514ca0 fixed up the test app
- exports the drawn text as demo.PNG
- scrollable with scroll wheels and arrow keys
2018-08-09 17:42:16 +09:00
minjaesong
cf3091421f bringing the shadow back 2018-08-09 15:46:57 +09:00
minjaesong
15fb3d15c0 Kana suppelements and Insular script 2018-08-09 15:34:08 +09:00
minjaesong
45532ca9b7 lemme have some debugging helper 2018-08-09 02:54:43 +09:00
minjaesong
6714bbb510 now everything is converted to UTF-32 internally
- To make working with other planes easier
2018-08-09 02:44:29 +09:00
minjaesong
77f2314b24 stacked diacritics seems working 2018-08-08 13:03:34 +09:00
minjaesong
dcd6390dbf new tagging system (see #5) WIP
- diacritics stacking does not work
- centre align with align-to-this-x-pos is untested
2018-08-08 02:22:40 +09:00
minjaesong
ecac1dc8af contribution guideline on separate md 2018-08-01 08:55:19 +09:00
minjaesong
b3174171c4 Cherokee whitespace adjustments 2018-07-29 07:09:09 +09:00
minjaesong
a0608bf032 README update 2018-07-28 05:48:33 +09:00
20 changed files with 1140 additions and 551 deletions

478
.idea/workspace.xml generated
View File

@@ -2,17 +2,20 @@
<project version="4">
<component name="ArtifactsWorkspaceSettings">
<artifacts-to-build>
<artifact name="FontDemoGDX" />
<artifact name="TerrarumSansBitmap" />
</artifacts-to-build>
</component>
<component name="ChangeListManager">
<list default="true" id="22c5bc80-996c-4846-b173-7dc8c2096fe3" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/FontTestGDX/META-INF/MANIFEST.MF" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/artifacts/FontDemoGDX.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/artifacts/FontDemoGDX.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CONTRIBUTING.md" beforeDir="false" afterPath="$PROJECT_DIR$/CONTRIBUTING.md" afterDir="false" />
<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$/assets/devanagari_bengali_variable.tga" beforeDir="false" afterPath="$PROJECT_DIR$/assets/devanagari_bengali_variable.tga" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/thai_variable.tga" beforeDir="false" afterPath="$PROJECT_DIR$/assets/thai_variable.tga" 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/GlyphProps.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/GlyphProps.kt" 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/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -29,20 +32,34 @@
<splitter split-orientation="horizontal" split-proportion="0.5">
<split-first>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
<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="568">
<caret line="850" column="12" selection-start-line="850" selection-start-column="12" selection-end-line="850" selection-end-column="12" />
<state relative-caret-position="456">
<caret line="836" column="26" selection-start-line="836" selection-start-column="26" selection-end-line="836" selection-end-column="26" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="GlyphProps.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/GlyphProps.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="156">
<caret line="12" column="33" selection-start-line="12" selection-start-column="12" selection-end-line="12" selection-end-column="33" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="demo.PNG" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="523" column="48" selection-start-line="523" selection-start-column="48" selection-end-line="523" selection-end-column="48" />
<state relative-caret-position="299">
<caret line="45" column="67" selection-start-line="45" selection-start-column="67" selection-end-line="45" selection-end-column="67" />
</state>
</provider>
</entry>
@@ -54,20 +71,43 @@
<file leaf-file-name="FontTestGDX.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="483">
<caret line="134" column="40" selection-start-line="134" selection-start-column="40" selection-end-line="134" selection-end-column="40" />
<state relative-caret-position="547">
<caret line="128" column="31" lean-forward="true" selection-start-line="128" selection-start-column="31" selection-end-line="128" selection-end-column="31" />
<folding>
<element signature="e#48#162#0" expanded="true" />
<element signature="e#0#384#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
<file leaf-file-name="demotext.txt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="121" selection-start-column="121" selection-end-column="121" />
</state>
</provider>
</entry>
</file>
<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="-242">
<caret line="277" column="5" selection-start-line="277" selection-start-column="5" selection-end-line="277" selection-end-column="5" />
<state relative-caret-position="547">
<caret line="494" column="101" selection-start-line="494" selection-start-column="101" selection-end-line="494" selection-end-column="101" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="CONTRIBUTING.md" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="402">
<caret line="62" column="132" lean-forward="true" selection-start-line="62" selection-start-column="132" selection-end-line="62" selection-end-column="132" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
@@ -76,8 +116,8 @@
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="631">
<caret line="241" column="171" selection-start-line="241" selection-start-column="171" selection-end-line="241" selection-end-column="171" />
<first_editor relative-caret-position="325">
<caret line="25" column="97" selection-start-line="25" selection-start-column="97" selection-end-line="25" selection-end-column="97" />
</first_editor>
<second_editor>
<js_state />
@@ -99,21 +139,11 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>getG</find>
<find>getWidt</find>
<find>batch.color =</find>
<find>getWidth</find>
<find>f</find>
<find>fun getWidth</find>
<find>fun dispo</find>
<find>xHei</find>
<find>not copy</find>
<find>getColour</find>
<find>.094</find>
<find>ө</find>
<find>ď</find>
<find>ñ</find>
<find>fun relo</find>
<find>getSheetT</find>
<find>Unexpected</find>
<find>Unexp</find>
@@ -122,9 +152,29 @@
<find>isHangul</find>
<find></find>
<find>toColo</find>
<find>fun relo</find>
<find>3633</find>
<find>println(</find>
<find>Width ta</find>
<find>getWidth</find>
<find>glyphWidthBuffer</find>
<find>GlyphProps.LE</find>
<find>buildWidthTable</find>
<find>lastNonDiacriticChar</find>
<find>c.toInt()</find>
<find>har.toInt()</find>
<find>println</find>
<find>!!</find>
<find>ArrayList&lt;Int&gt;</find>
<find>appConfig.height</find>
<find>textBuffer</find>
<find>no stan</find>
</findStrings>
<replaceStrings>
<replace>.141</replace>
<replace>c</replace>
<replace>har</replace>
<replace>TEXH</replace>
</replaceStrings>
</component>
<component name="Git.Settings">
@@ -138,19 +188,21 @@
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/testbed/FontTest.kt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/testbed/FontTestGDX.kt" />
<option value="$PROJECT_DIR$/LICENSE.md" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" />
<option value="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/GlyphProps.kt" />
<option value="$PROJECT_DIR$/CONTRIBUTING.md" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" />
<option value="$PROJECT_DIR$/FontTestGDX/demotext.txt" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1912" />
<option name="y" value="-521" />
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1936" />
<option name="height" value="1176" />
<option name="height" value="1216" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
@@ -158,7 +210,6 @@
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@@ -192,6 +243,7 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -349,17 +401,14 @@
<method />
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<module name="BuildJAR_TerrarumSansBitmap" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="BuildJAR_TerrarumSansBitmap" />
<envs />
<method />
<option name="MAIN_CLASS_NAME" />
<option name="WORKING_DIRECTORY" />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
@@ -416,12 +465,12 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="1912" y="-521" width="1936" height="1176" extended-state="6" />
<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" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.32851636" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.3283859" />
<window_info anchor="right" id="Palette&#9;" order="3" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
<window_info anchor="right" id="Maven Projects" order="3" />
@@ -429,19 +478,43 @@
<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" visible="true" weight="0.12953092" />
<window_info content_ui="combo" id="Project" order="0" weight="0.13859275" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info id="UI Designer" order="2" />
<window_info active="true" anchor="bottom" id="Debug" order="3" visible="true" weight="0.23025048" />
<window_info active="true" anchor="bottom" id="Debug" order="3" visible="true" weight="0.23005566" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32931355" />
</layout>
<layout-to-restore>
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Version Control" order="9" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.1369936" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Run" order="2" weight="0.2591522" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info id="Designer" order="2" />
<window_info id="UI Designer" order="3" />
<window_info active="true" anchor="bottom" id="Debug" order="3" visible="true" weight="0.23005566" />
<window_info anchor="right" id="Palette&#9;" order="4" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Messages" order="10" weight="0.3283859" />
<window_info anchor="right" id="Maven Projects" order="5" />
<window_info id="Favorites" order="4" side_tool="true" />
</layout-to-restore>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
@@ -456,6 +529,110 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="1404">
<caret line="108" selection-start-line="108" selection-end-line="108" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="6071">
<caret line="531" column="21" selection-start-line="531" selection-start-column="21" selection-end-line="531" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="234">
<caret line="18" lean-forward="true" selection-start-line="18" selection-end-line="18" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<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">
<first_editor relative-caret-position="1404">
<caret line="108" lean-forward="true" selection-start-line="108" selection-end-line="108" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="6071">
<caret line="531" column="21" selection-start-line="531" selection-start-column="21" selection-end-line="531" selection-end-column="21" />
</state>
</provider>
</entry>
<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="1495">
<caret line="145" column="17" selection-start-line="145" selection-start-column="17" selection-end-line="145" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SECOND">
<first_editor relative-caret-position="143">
<caret line="11" column="153" selection-start-line="11" selection-start-column="153" selection-end-line="11" selection-end-column="153" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8905">
@@ -477,9 +654,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</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="4940">
@@ -487,9 +661,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</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="5148">
@@ -497,9 +668,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</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="4752">
@@ -507,9 +675,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="7692">
@@ -517,8 +682,12 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8974">
<caret line="704" column="13" selection-start-line="704" selection-start-column="13" selection-end-line="704" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
@@ -527,8 +696,12 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8974">
<caret line="704" column="13" selection-start-line="704" selection-start-column="13" selection-end-line="704" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
@@ -537,9 +710,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8974">
@@ -547,9 +717,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8974">
@@ -557,29 +724,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8974">
<caret line="704" column="13" selection-start-line="704" selection-start-column="13" selection-end-line="704" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8974">
<caret line="704" column="13" selection-start-line="704" selection-start-column="13" selection-end-line="704" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
@@ -608,9 +752,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</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="504">
@@ -618,9 +759,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor" />
</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="532">
@@ -635,13 +773,7 @@
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/slick.jar!/org/newdawn/slick/Color.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="339">
<caret line="76" column="11" selection-start-line="76" selection-start-column="11" selection-end-line="76" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/slick.jar!/org/newdawn/slick/Color.class" />
<entry file="file://$PROJECT_DIR$/LICENSE.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
@@ -654,28 +786,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="523" column="48" selection-start-line="523" selection-start-column="48" selection-end-line="523" selection-end-column="48" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Temp/Ихадоу адаҟьа.URL">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="631">
<caret line="241" column="171" selection-start-line="241" selection-start-column="171" selection-end-line="241" selection-end-column="171" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar!/net/torvald/terrarumsansbitmap/gdx/GameFontBase.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="513">
@@ -683,27 +793,127 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="483">
<caret line="134" column="40" selection-start-line="134" selection-start-column="40" selection-end-line="134" selection-end-column="40" />
<folding>
<element signature="e#48#162#0" expanded="true" />
</folding>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="SPLIT">
<first_editor />
<second_editor>
<js_state />
</second_editor>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
<entry file="jar://$PROJECT_DIR$/lib/gdx.jar!/com/badlogic/gdx/graphics/g2d/GlyphLayout.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="156">
<caret line="23" column="11" selection-start-line="23" selection-start-column="11" selection-end-line="23" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="jar://C:/Program Files/Java/jdk1.8.0_131/src.zip!/java/lang/Character.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="515">
<caret line="4839" column="59" selection-start-line="4837" selection-start-column="15" selection-end-line="4839" selection-end-column="59" />
</state>
</provider>
</entry>
<entry file="jar://C:/Program Files/Java/jdk1.8.0_131/src.zip!/java/lang/CharSequence.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="509">
<caret line="219" column="49" selection-start-line="219" selection-start-column="49" selection-end-line="219" selection-end-column="49" />
</state>
</provider>
</entry>
<entry file="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime-sources.jar!/kotlin/CharSequence.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="91">
<caret line="21" column="17" selection-start-line="21" selection-start-column="17" selection-end-line="21" selection-end-column="17" />
</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" />
</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$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="299">
<caret line="23" lean-forward="true" selection-start-line="23" selection-end-line="23" />
<caret line="45" column="67" selection-start-line="45" selection-start-column="67" selection-end-line="45" selection-end-column="67" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="325">
<caret line="25" column="97" selection-start-line="25" selection-start-column="97" selection-end-line="25" selection-end-column="97" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</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="156">
<caret line="12" column="33" selection-start-line="12" selection-start-column="12" selection-end-line="12" selection-end-column="33" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="402">
<caret line="62" column="132" lean-forward="true" selection-start-line="62" selection-start-column="132" selection-end-line="62" selection-end-column="132" />
</first_editor>
<second_editor>
<js_state />
</second_editor>
</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="-242">
<caret line="277" column="5" selection-start-line="277" selection-start-column="5" selection-end-line="277" selection-end-column="5" />
<state relative-caret-position="547">
<caret line="494" column="101" selection-start-line="494" selection-start-column="101" selection-end-line="494" selection-end-column="101" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="547">
<caret line="128" column="31" lean-forward="true" selection-start-line="128" selection-start-column="31" selection-end-line="128" selection-end-column="31" />
<folding>
<element signature="e#0#384#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="121" selection-start-column="121" selection-end-column="121" />
</state>
</provider>
</entry>

145
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,145 @@
You can contribute to the font by fixing wrong glyphs, suggesting better ones, extending character set (letters for other writing systems or filling in the blanks on the existing ones), or code for other game frameworks (not limited to Java). Please leave pull request for that.
Font Spritesheets are stored in ```assets/graphics/fonts``` directory. Image format must be TGA with Alpha — no PNG. If someone needs PNG, they can batch-convert the font using utils like ImageMagick.
#### Before getting started, you did read our design goals, right? Good. Now you may continue your awesome work.
### Ascenders, descenders, width informations
![Alas, use more modern browser or get better internet connexion!](glyph_height_pos_annotation.png)
Above image is a reference you can use while you draw some letters. Capital B is drawn as a reference. Orange-tinted area is for lowercase, x-height must be the same as that of said tinted area (lowercase Alpha is also drawn for the reference). NOTE THAT x-height is taller than centre bar (capital A is an exception). Height of the ascender of the lowercase letters must be the same as height of capital letters.
Red-tinted area SHOULD NOT CONTAIN any dots, it's emptied for compatibility. (Slick2d—you can define size of "gaps" of the spritesheet, but you can't define horizontal and vertical gap separately)
Blue-tinted area cotains width of the glyph in binary, uppermost dot is the Least Significant Bit.
Green-tinted area contains extra informations, left blank for most cases. We'll call it Glyph Tags.
Tinted-in-magenta shows the height where diacritics should be placed, for both uppercase and lowercase.
Each cell is 16 px wide, and any glyph you draw **must be contained within leftside FIFTEEN pixels**.
### Font Metrics
Although the font is basically a Spritesheet, some of the sheet expects variable widths to be supported. Any sheets with ```_variable``` means it expects variable widths. Anything else expects fixed width (regular Spritesheet behaviour). ```cjkpunct``` has width of 10, ```kana``` and ```hangul_johab``` has width of 12, ```wenquanyi``` has width of 16.
### Parsing glyph widths for variable font sheets
![Sample of Font Spritesheet with annotation](width_bit_encoding_annotated.png)
Width is encoded in binary bits, on pixels. On the font spritesheet, every glyph has vertical dots on their top-right side (to be exact, every (16k - 1)th pixel on x axis). Above image is a sample of the font, with width information coloured in magenta. From top to bottom, each dot represents 1, 2, 4 and 8. For example, in the above image, ! (exclamation mark) has width of 5, " (double quote) has width of 6, # (octothorp) has width of 8, $ (dollar sign) has width of 9.
### Glyph Tagging System
Green-tinted area (should be 10 px tall) contains the tags. Tags are defined as following:
```
(LSB) 0 == RTL
1 -+ 1 | Align to this X pos of prev char,
1 | 2 | only valid if write-on-top is 1
1 | 4 | and is centre-aligned and non-zero
1 -+ 8 | (if this is zero, floorOf(width/2) will be used instead)
0 -+ 0 Align 1 Align 0 Align 1 Align before
1 -+ 0 left 0 right 1 centre 1 the glyph
0 == Write on top of prev chars (e.g. diacritics)
1 == Diacritics stack 0:upward/1:downward
(MSB) X == undefined, should be 0
NOTE: If glyphs are right or centre aligned, they must be aligned in the
same way inside of the bitmap; the program assumes every variable-
width glyphs to have a width of 15, regardless of the tagged width.
If the diacritic is aligned before the glyph, the diacritic itself
is always assumed as left-aligned, as this font will swap position
of said diacritic and the glyph right before it.
```
![Visual representation of left/right/centre align](alignment_illustration.jpg)
(fun fact: it was drawn on Rhodia memopad with Lamy 2000, then photographed and edited on my iPhone. Letter used is a Cherokee WE Ꮺ)
### Implementing the Korean writing system
On this font, Hangul letters are printed by assemblying two or three letter pieces. There are 10 sets of Hangul letter pieces on the font. Top 6 are initials, middle 2 are medials, and bottom 2 are finals. On the rightmost side, there's eight assembled glyphs to help you with (assuming you have basic knowledge on the writing system). Top 6 tells you how to use 6 initials, and bottom 2 tells you how to use 2 finals.
This is a Kotlin-like pseudocode for assembling the glyph:
function getHanChosung(hanIndex: Int) = hanIndex / (21 * 28)
function getHanJungseong(hanIndex: Int) = hanIndex / 28 % 21
function getHanJongseong(hanIndex: Int) = hanIndex % 28
jungseongWide = arrayOf(8, 12, 13, 17, 18, 21)
jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22)
function getHanInitialRow(hanIndex: Int): Int {
val ret: Int
if (isJungseongWide(hanIndex))
ret = 2
else if (isJungseongComplex(hanIndex))
ret = 4
else
ret = 0
return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
}
function isJungseongWide(hanIndex: Int) = jungseongWide.contains(getHanJungseong(hanIndex))
function isJungseongComplex(hanIndex: Int) = jungseongComplex.contains(getHanJungseong(hanIndex))
function getHanInitialRow(hanIndex: Int): Int {
val ret: Int
if (isJungseongWide(hanIndex))
ret = 2
else if (isJungseongComplex(hanIndex))
ret = 4
else
ret = 0
return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
}
function getHanMedialRow(hanIndex: Int) = if (getHanJongseong(hanIndex) == 0) 6 else 7
function getHanFinalRow(hanIndex: Int): Int {
val jungseongIndex = getHanJungseong(hanIndex)
return if (jungseongWide.contains(jungseongIndex))
8
else
9
}
function isHangul(c: Char) = c.toInt() >= 0xAC00 && c.toInt() < 0xD7A4
...
for (each Char on the string) {
if (isHangul(Char)) {
val hIndex = Char.toInt() - 0xAC00
val indexCho = getHanChosung(hIndex)
val indexJung = getHanJungseong(hIndex)
val indexJong = getHanJongseong(hIndex)
val choRow = getHanInitialRow(hIndex)
val jungRow = getHanMedialRow(hIndex)
val jongRow = getHanFinalRow(hIndex)
// get sub image from sprite sheet
val choseongImage = hangulSheet.getSubImage(indexCho, choRow)
val jungseongImage = hangulSheet.getSubImage(indexJung, jungRow)
val jongseongImage = hangulSheet.getSubImage(indexJong, jongRow)
// actual drawing part
draw choseongImage to somewhere you want
draw jungseongImage on top of choseongImage
draw jongseongImage on top of choseongImage
}
...
}

View File

@@ -22,38 +22,44 @@ No more suffering. This font has everything you need.
How multilingual? Real multilingual!
􌿽Ианҵоуп ақьаад, нусхур аҩырала, ҩ ҽшьаҟакла, иҧшӡоу анапҩырала􀀀
􌿽Գրիչս վայր դրի, վեր կացա և պատրաստվում էի, որ քնեմ, երբ հանկարծ դռանս զանգակը հնչեց􀀀
􌿽Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq􀀀
􌿽󿿹Под южно дърво, цъфтящо в синьо, бягаше малко пухкаво зайче󿿸􀀀
􌿽ᎠᏍᎦᏯᎡᎦᎢᎾᎨᎢᎣᏍᏓᎤᎩᏍᏗᎥᎴᏓᎯᎲᎢᏔᎵᏕᎦᏟᏗᏖᎸᎳᏗᏗᎧᎵᎢᏘᎴᎩ ᏙᏱᏗᏜᏫᏗᏣᏚᎦᏫᏛᏄᏓᎦᏝᏃᎠᎾᏗᎭᏞᎦᎯᎦᏘᏓᏠᎨᏏᏕᏡᎬᏢᏓᏥᏩᏝᎡᎢᎪᎢ􀀀
􌿽ᎠᎦᏂᏗᎮᎢᎫᎩᎬᏩᎴᎢᎠᏆᏅᏛᎫᏊᎾᎥᎠᏁᏙᎲᏐᏈᎵᎤᎩᎸᏓᏭᎷᏤᎢᏏᏉᏯᏌᏊ ᎤᏂᏋᎢᏡᎬᎢᎰᏩᎬᏤᎵᏍᏗᏱᎩᎱᎱᎤᎩᎴᎢᏦᎢᎠᏂᏧᏣᏨᎦᏥᎪᎥᏌᏊᎤᎶᏒᎢᎢᏡᎬᎢ􀀀
􌿽ᎹᎦᎺᎵᏥᎻᎼᏏᎽᏗᏩᏂᎦᏘᎾᎿᎠᏁᎬᎢᏅᎩᎾᏂᎡᎢᏌᎶᎵᏎᎷᎠᏑᏍᏗᏪᎩ ᎠᎴ ᏬᏗᏲᏭᎾᏓᏍᏓᏴᏁᎢᎤᎦᏅᏮᏰᎵᏳᏂᎨᎢ􀀀
􌿽Příliš žluťoučký kůň úpěl ďábelské ódy􀀀
􌿽Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon􀀀
􌿽Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich􀀀
􌿽διαφυλάξτε γενικά τη ζωή σας από βαθειά ψυχικά τραύματα􀀀
􌿽ΔΙΑΦΥΛΆΞΤΕ ΓΕΝΙΚΆ ΤΗ ΖΩΉ ΣΑΣ ΑΠΌ ΒΑΘΕΙΆ ΨΥΧΙΚΆ ΤΡΑΎΜΑΤΑ􀀀
􌿽სწრაფი ყავისფერი მელა გადაახტა ზარმაც ძაღლს􀀀
􌿽Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa􀀀
􌿽Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig􀀀
􌿽とりなくこゑす ゆめさませ みよあけわたる ひんかしを そらいろはえて おきつへに ほふねむれゐぬ もやのうち􀀀
􌿽田居に出で 菜摘むわれをぞ 君召すと 求食り追ひゆく 山城の 打酔へる子ら 藻葉干せよ え舟繋けぬ􀀀
􌿽정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 하얬다 도럄직한 퀡봹퉪헰􀀀
􌿽Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam􀀀
􌿽Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą􀀀
􌿽Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех􀀀
􌿽Щётканы фермд пийшин цувъя. Бөгж зогсч хэльюү􀀀
􌿽Pchnąć w tę łódź jeża lub ośm skrzyń fig􀀀
􌿽Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila􀀀
􌿽Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства􀀀
􌿽󿿺Ајшо, лепото и чежњо, за љубав срца мога дођи у Хаџиће на кафу󿿸􀀀
􌿽Jovencillo emponzoñado de whisky: ¡qué figurota exhibe!􀀀
􌿽นายสังฆภัณฑ์ เฮงพิทักษ์ฝั่ง ผู้เฒ่าซึ่งมีอาชีพเป็นฅนขายฃวด ถูกตำรวจปฏิบัติการจับฟ้องศาล ฐานลักนาฬิกาคุณหญิงฉัตรชฎา ฌานสมาธิ􀀀
􌿽Pijamalı hasta yağız şoföre çabucak güvendi􀀀
􌿽Жебракують філософи при ґанку церкви в Гадячі, ще й шатро їхнє п’яне знаємо􀀀
􌿽Do bạch kim rất quý nên sẽ dùng để lắp vô xương􀀀
􌿽日堀油告観観藤村抄海評業庁経賃室弁市。太撮収改売週法所何都慣次現。価紙一無三洋日話転手治稿載末替付致治。􀀀
􏻬Ианҵоуп ақьаад, нусхур аҩырала, ҩ ҽшьаҟакла, иҧшӡоу анапҩырала􀀀
􏻬գրիչս վայր դրի, վեր կացա և պատրաստվում էի, որ քնեմ, երբ հանկարծ դռանս զանգակը հնչեց􀀀
􏻬ՄՇԱԿԻՉ ԿԱՄ ԿԵՆՏՐՈՆԱԿԱՆ ՄՇԱԿԻՉ ՀԱՆԳՈՒՅՑԸ ՀԱՆԴԻՍԱՆՈՒՄ Է ՀԱՄԱԿԱՐԳՉԻ ՍԱՐՔԱՎՈՐՈՒՄՆԵՐԻՑ􀀀
􏻬Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq􀀀
􏻬󿿹Под южно дърво, цъфтящо в синьо, бягаше малко пухкаво зайче󿿸􀀀
􏻬ᎠᏍᎦᏯᎡᎦᎢᎾᎨᎢᎣᏍᏓᎤᎩᏍᏗᎥᎴᏓᎯᎲᎢᏔᎵᏕᎦᏟᏗᏖᎸᎳᏗᏗᎧᎵᎢᏘᎴᎩ ᏙᏱᏗᏜᏫᏗᏣᏚᎦᏫᏛᏄᏓᎦᏝᏃᎠᎾᏗᎭᏞᎦᎯᎦᏘᏓᏠᎨᏏᏕᏡᎬᏢᏓᏥᏩᏝᎡᎢᎪᎢ􀀀
􏻬ᎠᎦᏂᏗᎮᎢᎫᎩᎬᏩᎴᎢᎠᏆᏅᏛᎫᏊᎾᎥᎠᏁᏙᎲᏐᏈᎵᎤᎩᎸᏓᏭᎷᏤᎢᏏᏉᏯᏌᏊ ᎤᏂᏋᎢᏡᎬᎢᎰᏩᎬᏤᎵᏍᏗᏱᎩᎱᎱᎤᎩᎴᎢᏦᎢᎠᏂᏧᏣᏨᎦᏥᎪᎥᏌᏊᎤᎶᏒᎢᎢᏡᎬᎢ􀀀
􏻬ᎹᎦᎺᎵᏥᎻᎼᏏᎽᏗᏩᏂᎦᏘᎾᎿᎠᏁᎬᎢᏅᎩᎾᏂᎡᎢᏌᎶᎵᏎᎷᎠᏑᏍᏗᏪᎩ ᎠᎴ ᏬᏗᏲᏭᎾᏓᏍᏓᏴᏁᎢᎤᎦᏅᏮᏰᎵᏳᏂᎨᎢ􀀀
􏻬Příliš žluťoučký kůň úpěl ďábelské ódy􀀀
􏻬Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon􀀀
􏻬PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS􀀀
􏻬Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich GROẞEN GROẞE􀀀
􏻬ζαφείρι δέξου πάγκαλο, βαθων ψυχης το σημα􀀀
􏻬ΔΙΑΦΥΛΆΞΤΕ ΓΕΝΙΚΆ ΤΗ ΖΩΉ ΣΑΣ ΑΠΌ ΒΑΘΕΙΆ ΨΥΧΙΚΆ ΤΡΑΎΜΑΤΑ􀀀
􏻬სწრაფი ყავისფერი მელა გადაახტა ზარმაც ძაღლს ᲘᲜᲢᲔᲚ ᲞᲔᲜᲢᲘᲣᲛᲘ ᲛᲘᲙᲠᲝᲞᲠᲝᲪᲔᲡᲝᲠᲘ􀀀
􏻬ऋषियों को सताने वाले दुष्ट राक्षसों के राजा रावण का सर्वनाश करने वाले विष्णुवतार भगवान श्रीराम अयोध्या के महाराज दशरथ के􀀀
􏻬Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa􀀀
􏻬Ꝺꝼuaꞅcail Íoꞅa Úꞃṁac na hÓiᵹe Beannaiꞇe póꞃ Éaḃa aᵹus Áꝺaiṁ􀀀
􏻬Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig􀀀
􏻬あめつちほしそら やまかはみねたに くもきりむろこけ ひといぬうへすゑ ゆわさるおふせよ えの𛀁をなれゐて􀀀
􏻬トリナクコヱス ユメサマセ ミヨアケワタル ヒンカシヲ ソライロハエテ オキツヘニ ホフネムレヰヌ モヤノウチ􀀀
􏻬田居に出で 菜摘むわれをぞ 君召すと 求食り追ひゆく 山城の 打酔へる子ら 藻葉干せよ え舟繋けぬ􀀀
􏻬정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 하얬다 도럄직한 퀡봹퉪헰􀀀
􏻬Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam􀀀
􏻬Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą􀀀
􏻬Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех􀀀
􏻬Щётканы фермд пийшин цувъя. Бөгж зогсч хэльюү􀀀
􏻬Pchnąć w tę łódź jeża lub ośm skrzyń fig􀀀
􏻬कः खगौघाङचिच्छौजा झाञ्ज्ञोऽटौठीडडण्ढणः। तथोदधीन् पफर्बाभीर्मयोऽरिल्वाशिषां सहः॥􀀀
􏻬Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila􀀀
􏻬Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства􀀀
􏻬󿿺Ајшо, лепото и чежњо, за љубав срца мога дођи у Хаџиће на кафу󿿸􀀀
􏻬Jovencillo emponzoñado de whisky: ¡qué figurota exhibe!􀀀
􏻬นายสังฆภัณฑ์ เฮงพิทักษ์ฝั่ง ผู้เฒ่าซึ่งมีอาชีพเป็นฅนขายฃวด ถูกตำรวจปฏิบัติการจับฟ้องศาล ฐานลักนาฬิกาคุณหญิงฉัตรชฎา ฌานสมาธิ􀀀
􏻬Pijamalı hasta yağız şoföre çabucak güvendi􀀀
􏻬Жебракують філософи при ґанку церкви в Гадячі, ще й шатро їхнє п’яне знаємо􀀀
􏻬Do bạch kim rất quý nên sẽ dùng để lắp vô xương􀀀
􏻬日堀油告観観藤村抄海評業庁経賃室弁市。太撮収改売週法所何都慣次現。価紙一無三洋日話転手治稿載末替付致治。􀀀
􏃯Features:􀀀
@@ -86,10 +92,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 Devanagari Thai Georgian Runic Cherokee Georgian Extended
General Punctuations CJK Symbols Kana Kana Phonetic Extension CJK Unihan Extension A CJK Unihan
Hangul Syllables Fullwidth Forms Kana Supplement
GitHubs 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.

View File

@@ -1,11 +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.*
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
/**
@@ -19,8 +18,12 @@ class FontTestGDX : Game() {
lateinit var batch: SpriteBatch
lateinit var frameBuffer: FrameBuffer
lateinit var camera: OrthographicCamera
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 reader = inTextFile.reader()
@@ -131,34 +134,75 @@ class FontTestGDX : Game() {
println("${font.noColorCode}\nEND")
println(font.toColorCode(0xC_FFD))
println(font.toColorCode(0xF_F55))
println(font.toColorCode(0xE_CCC))
println(font.toColorCode(0xF_EEC))
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() {
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.projectionMatrix = camera.combined
batch.begin()
batch.color = Color(0xeeeeeeff.toInt())
inputText.forEachIndexed { index, s ->
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()
///////////////
tex = frameBuffer.colorBufferTexture
}
batch.begin()
batch.color = Color.WHITE
batch.draw(tex, 0f, (TEXH.toFloat()/appConfig.height)*TEXH - scrollOffsetY, TEXW.toFloat(), -(TEXH.toFloat() / appConfig.height) * TEXH.toFloat())
batch.color = Color(0xeeeeeeff.toInt())
inputText.forEachIndexed { index, s ->
font.draw(batch, s, 10f, appConfig.height - 30f - index * font.lineHeight)
}
batch.end()
}
@@ -175,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 = 2060
fun main(args: Array<String>) {
appConfig = LwjglApplicationConfiguration()
appConfig.vSyncEnabled = false
appConfig.resizable = false//true;
appConfig.width = 960
appConfig.height = 2048
appConfig.width = TEXW
appConfig.height = 768
appConfig.title = "Terrarum Sans Bitmap Test (GDX)"
LwjglApplication(FontTestGDX(), appConfig)

127
README.md
View File

@@ -9,8 +9,9 @@ The JAR package is meant to be used with Slick2d (extends ```Font``` class) and
The issue page is open. If you have some issues to submit, or have a question, please leave it on the page.
#### Little notes
- You can't display Bulgarian, Russian and Serbian variants at the same time without some more codes; ```reload()```ing them or creating multiple instances of the font would be the easiest solutions.
- To display Bulgarian/Serbian variants, you need special Control Characters. (GameFontBase.charsetOverrideBulgarian -- U+FFFF9; GameFontBase.charsetOverrideSerbian -- U+FFFFA)
- All Han characters are in Chinese variant, no other variants are to be supported as most Chinese, Japanese and Korean can understand other's variant and to be honest, we don't bother anyway.
- Indian script in general is not perfect: this font will never do the proper ligatures (I can't draw all the 1 224 possible combinations). Hopefully it's still be able to understand without them.
### Design Goals
@@ -22,7 +23,7 @@ The issue page is open. If you have some issues to submit, or have a question, p
## Using on your game
- Firstly, place the .jar to your library path and unzip spritesheets, then:
- Firstly, place the .jar to your library path and assets folder to the main directory of the app, then:
### Using on LibGDX
@@ -107,133 +108,19 @@ On your code (Java):
Color codes are individual unicode characters. While you can somehow make a raw character and paste in on your code, it's certainly not desirable. Fortunately, we're also providing utility functions for the color codes.
GameFontBase.toColorCode(rgba4444: Int) -- returns String
GameFontBase.toColorCode(argb4444: Int) -- returns String
GameFontBase.toColorCode(r: Int, g: Int, b: Int) -- returns String
GameFontBase.toColorCode(r: Int, g: Int, b: Int, a: Int) -- returns String
```rgba4444``` takes whole RGBA as input, that is, from 0x0000 to 0xFFFF. Most significant bits represents Red, and least significant bits represents Alpha (which should be fixed as F for the most time)
```argb4444``` takes whole ARGB (in that order) as input, that is, from 0x0000 to 0xFFFF.
```r, g, b(, a)``` takes RGB and A separately, in the range of 0x0..0xF. Any value exceeding the range **are unchecked and may wreak havoc**, so be careful.
U+100000 is used to disable previously-applied color codes (going back to original colour), although it may seem like RGBA of all zero.
U+100000 is used to disable previously-applied color codes (going back to original colour), even if it looks like ARGB of all zero.
## Contribution guidelines
You can contribute to the font by fixing wrong glyphs, suggesting better ones, extending character set (letters for other writing systems or filling in the blanks on the existing ones), or code for other game frameworks (not limited to Java). Please leave pull request for that.
Font Spritesheets are stored in ```assets/graphics/fonts``` directory. Image format must be TGA with Alpha — no PNG. If someone needs PNG, they can batch-convert the font using utils like ImageMagick.
### Ascenders, descenders, width informations
![Alas, use more modern browser or get better internet connexion!](glyph_height_pos_annotation.png)
Above image is a reference you can use while you draw some letters. Capital B is drawn as a reference. Orange-tinted area is for lowercase, x-height must be the same as that of said tinted area (lowercase Alpha is also drawn for the reference). NOTE THAT x-height is taller than centre bar (capital A is an exception). Height of the ascender of the lowercase letters must be the same as height of capital letters.
Red-tinted area SHOULD NOT CONTAIN any dots, it's emptied for compatibility. (Slick2d—you can define size of "gaps" of the spritesheet, but you can't define horizontal and vertical gap separately)
Blue-tinted area cotains width of the glyph in binary, uppermost dot is the Least Significant Bit.
Green-tinted area contains extra informations, left blank for most cases. (will be expanded later; no standard has been issued yet)
Tinted-in-magenta shows the height where diacritics should be placed, for both uppercase and lowercase.
Each cell is 16 px wide, and any glyph you draw **must be contained within leftside FIFTEEN pixels**.
### Font metrics
Although the font is basically a Spritesheet, some of the sheet expects variable widths to be supported. Any sheets with ```_variable``` means it expects variable widths. Anything else expects fixed width (regular Spritesheet behaviour). ```cjkpunct``` has width of 10, ```kana``` and ```hangul_johab``` has width of 12, ```wenquanyi``` has width of 16.
### Parsing glyph widths for variable font sheets
![Sample of Font Spritesheet with annotation](width_bit_encoding_annotated.png)
Width is encoded in binary bits, on pixels. On the font spritesheet, every glyph has vertical dots on their top-right side (to be exact, every (16k - 1)th pixel on x axis). Above image is a sample of the font, with width information coloured in magenta. From top to bottom, each dot represents 1, 2, 4 and 8. For example, in the above image, ! (exclamation mark) has width of 5, " (double quote) has width of 6, # (octothorp) has width of 8, $ (dollar sign) has width of 9.
### Implementing the Korean writing system
On this font, Hangul letters are printed by assemblying two or three letter pieces. There are 10 sets of Hangul letter pieces on the font. Top 6 are initials, middle 2 are medials, and bottom 2 are finals. On the rightmost side, there's eight assembled glyphs to help you with (assuming you have basic knowledge on the writing system). Top 6 tells you how to use 6 initials, and bottom 2 tells you how to use 2 finals.
This is a Kotlin-like pseudocode for assembling the glyph:
function getHanChosung(hanIndex: Int) = hanIndex / (21 * 28)
function getHanJungseong(hanIndex: Int) = hanIndex / 28 % 21
function getHanJongseong(hanIndex: Int) = hanIndex % 28
jungseongWide = arrayOf(8, 12, 13, 17, 18, 21)
jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22)
function getHanInitialRow(hanIndex: Int): Int {
val ret: Int
if (isJungseongWide(hanIndex))
ret = 2
else if (isJungseongComplex(hanIndex))
ret = 4
else
ret = 0
return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
}
function isJungseongWide(hanIndex: Int) = jungseongWide.contains(getHanJungseong(hanIndex))
function isJungseongComplex(hanIndex: Int) = jungseongComplex.contains(getHanJungseong(hanIndex))
function getHanInitialRow(hanIndex: Int): Int {
val ret: Int
if (isJungseongWide(hanIndex))
ret = 2
else if (isJungseongComplex(hanIndex))
ret = 4
else
ret = 0
return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
}
function getHanMedialRow(hanIndex: Int) = if (getHanJongseong(hanIndex) == 0) 6 else 7
function getHanFinalRow(hanIndex: Int): Int {
val jungseongIndex = getHanJungseong(hanIndex)
return if (jungseongWide.contains(jungseongIndex))
8
else
9
}
function isHangul(c: Char) = c.toInt() >= 0xAC00 && c.toInt() < 0xD7A4
...
for (each Char on the string) {
if (isHangul(Char)) {
val hIndex = Char.toInt() - 0xAC00
val indexCho = getHanChosung(hIndex)
val indexJung = getHanJungseong(hIndex)
val indexJong = getHanJongseong(hIndex)
val choRow = getHanInitialRow(hIndex)
val jungRow = getHanMedialRow(hIndex)
val jongRow = getHanFinalRow(hIndex)
// get sub image from sprite sheet
val choseongImage = hangulSheet.getSubImage(indexCho, choRow)
val jungseongImage = hangulSheet.getSubImage(indexJung, jungRow)
val jongseongImage = hangulSheet.getSubImage(indexJong, jongRow)
// actual drawing part
draw choseongImage to somewhere you want
draw jungseongImage on top of choseongImage
draw jongseongImage on top of choseongImage
}
...
}
Please refer to [CONTRIBUTING.md](https://github.com/minjaesong/Terrarum-sans-bitmap/blob/master/CONTRIBUTING.md)
## Acknowledgement

BIN
TerrarumSansBitmap.jar Normal file

Binary file not shown.

BIN
alignment_illustration.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
demo.PNG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
font_drawing_template.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,30 @@
package net.torvald.terrarumsansbitmap
/**
* Created by minjaesong on 2018-08-07.
*/
data class GlyphProps(
val width: Int,
val writeOnTop: Boolean,
val alignWhere: Int,
val alignXPos: Int,
val rtl: Boolean = false,
val diacriticsStackDown: Boolean = false,
val diacriticsBeforeGlyph: Boolean = false
) {
companion object {
const val LEFT = 0
const val RIGHT = 1
const val CENTRE = 2
}
constructor(width: Int, tags: Int) : this(
width,
tags.ushr(7).and(1) == 1,
tags.ushr(5).and(3),
tags.ushr(1).and(15),
tags.and(1) == 1,
tags.ushr(8).and(1) == 1,
tags.ushr(5).and(3) == 3
)
}

View File

@@ -1,7 +1,7 @@
/*
* Terrarum Sans Bitmap
*
* Copyright (c) 2017 Minjae Song (Torvald)
* Copyright (c) 2017-2018 Minjae Song (Torvald)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,14 +26,19 @@ package net.torvald.terrarumsansbitmap.gdx
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.*
import com.badlogic.gdx.graphics.glutils.FrameBuffer
import net.torvald.terrarumsansbitmap.GlyphProps
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.util.zip.GZIPInputStream
typealias CodepointSequence = ArrayList<Int>
/**
* LibGDX port of Terrarum Sans Bitmap implementation
*
@@ -72,7 +77,7 @@ import java.util.zip.GZIPInputStream
*
* 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 getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
@@ -108,89 +113,103 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
9
}
private fun isHangul(c: Char) = c.toInt() in codeRange[SHEET_HANGUL]
private fun isAscii(c: Char) = c.toInt() in codeRange[SHEET_ASCII_VARW]
private fun isRunic(c: Char) = c.toInt() in codeRange[SHEET_RUNIC]
private fun isExtA(c: Char) = c.toInt() in codeRange[SHEET_EXTA_VARW]
private fun isExtB(c: Char) = c.toInt() in codeRange[SHEET_EXTB_VARW]
private fun isKana(c: Char) = c.toInt() in codeRange[SHEET_KANA]
private fun isCJKPunct(c: Char) = c.toInt() in codeRange[SHEET_CJK_PUNCT]
private fun isUniHan(c: Char) = c.toInt() in codeRange[SHEET_UNIHAN]
private fun isCyrilic(c: Char) = c.toInt() in codeRange[SHEET_CYRILIC_VARW]
private fun isFullwidthUni(c: Char) = c.toInt() in codeRange[SHEET_FW_UNI]
private fun isUniPunct(c: Char) = c.toInt() in codeRange[SHEET_UNI_PUNCT]
private fun isGreek(c: Char) = c.toInt() in codeRange[SHEET_GREEK_VARW]
private fun isThai(c: Char) = c.toInt() in codeRange[SHEET_THAI_VARW]
private fun isDiacritics(c: Char) = c.toInt() in 0xE34..0xE3A
|| c.toInt() in 0xE47..0xE4E
|| c.toInt() == 0xE31
private fun isCustomSym(c: Char) = c.toInt() in codeRange[SHEET_CUSTOM_SYM]
private fun isArmenian(c: Char) = c.toInt() in codeRange[SHEET_HAYEREN_VARW]
private fun isKartvelian(c: Char) = c.toInt() in codeRange[SHEET_KARTULI_VARW]
private fun isIPA(c: Char) = c.toInt() in codeRange[SHEET_IPA_VARW]
private fun isColourCodeHigh(c: Char) = c.toInt() in 0xDC00..0xDFFF // only works with JVM (which uses UTF-16 internally)
private fun isColourCodeLow(c: Char) = c.toInt() in 0xDBC0..0xDBFF // only works with JVM (which uses UTF-16 internally)
private fun isLatinExtAdd(c: Char) = c.toInt() in 0x1E00..0x1EFF
private fun isCharsetOverrideHigh(c: Char) = c.toInt() in 0xDFF8..0xDFFF // only works with JVM (which uses UTF-16 internally)
private fun isCharsetOverrideLow(c: Char) = c.toInt() == 0xDBBF // only works with JVM (which uses UTF-16 internally)
private fun isBulgarian(c: Char) = c.toInt() in 0x400..0x45F
private fun isCherokee(c: Char) = c.toInt() in codeRange[SHEET_TSALAGI_VARW]
private fun isHangul(c: Int) = c in codeRange[SHEET_HANGUL]
private fun isAscii(c: Int) = c in codeRange[SHEET_ASCII_VARW]
private fun isRunic(c: Int) = c in codeRange[SHEET_RUNIC]
private fun isExtA(c: Int) = c in codeRange[SHEET_EXTA_VARW]
private fun isExtB(c: Int) = c in codeRange[SHEET_EXTB_VARW]
private fun isKana(c: Int) = c in codeRange[SHEET_KANA] || c in 0x31F0..0x31FF || c in 0x1B000..0x1B001
private fun isCJKPunct(c: Int) = c in codeRange[SHEET_CJK_PUNCT]
private fun isUniHan(c: Int) = c in codeRange[SHEET_UNIHAN]
private fun isCyrilic(c: Int) = c in codeRange[SHEET_CYRILIC_VARW]
private fun isFullwidthUni(c: Int) = c in codeRange[SHEET_FW_UNI]
private fun isUniPunct(c: Int) = c in codeRange[SHEET_UNI_PUNCT_VARW]
private fun isGreek(c: Int) = c in codeRange[SHEET_GREEK_VARW]
private fun isThai(c: Int) = c in codeRange[SHEET_THAI_VARW]
/*private fun isDiacritics(c: Int) = c in 0xE34..0xE3A
|| c in 0xE47..0xE4E
|| c == 0xE31*/
private fun isCustomSym(c: Int) = c in codeRange[SHEET_CUSTOM_SYM]
private fun isArmenian(c: Int) = c in codeRange[SHEET_HAYEREN_VARW]
private fun isKartvelian(c: Int) = c in codeRange[SHEET_KARTULI_VARW]
private fun isIPA(c: Int) = c in codeRange[SHEET_IPA_VARW]
private fun isLatinExtAdd(c: Int) = c in 0x1E00..0x1EFF
private fun isBulgarian(c: Int) = c in 0x400..0x45F
private fun isColourCode(c: Int) = c in 0x100000..0x10FFFF
private fun isCharsetOverride(c: Int) = c in 0xFFFF8..0xFFFFF
private fun isCherokee(c: Int) = c in codeRange[SHEET_TSALAGI_VARW]
private fun isInsular(c: Int) = c == 0x1D79 || c in 0xA779..0xA787
private fun isNagariBengali(c: Int) = c in codeRange[SHEET_NAGARI_BENGALI_VARW]
private fun isKartvelianCaps(c: Int) = c in codeRange[SHEET_KARTULI_CAPS_VARW]
private fun extAindexX(c: Char) = (c.toInt() - 0x100) % 16
private fun extAindexY(c: Char) = (c.toInt() - 0x100) / 16
private fun extAindexX(c: Int) = (c - 0x100) % 16
private fun extAindexY(c: Int) = (c - 0x100) / 16
private fun extBindexX(c: Char) = (c.toInt() - 0x180) % 16
private fun extBindexY(c: Char) = (c.toInt() - 0x180) / 16
private fun extBindexX(c: Int) = (c - 0x180) % 16
private fun extBindexY(c: Int) = (c - 0x180) / 16
private fun runicIndexX(c: Char) = (c.toInt() - 0x16A0) % 16
private fun runicIndexY(c: Char) = (c.toInt() - 0x16A0) / 16
private fun runicIndexX(c: Int) = (c - 0x16A0) % 16
private fun runicIndexY(c: Int) = (c - 0x16A0) / 16
private fun kanaIndexX(c: Char) = (c.toInt() - 0x3040) % 16
private fun kanaIndexY(c: Char) = (c.toInt() - 0x3040) / 16
private fun kanaIndexX(c: Int) = (c - 0x3040) % 16
private fun kanaIndexY(c: Int) =
if (c in 0x31F0..0x31FF) 12
else if (c in 0x1B000..0x1B00F) 13
else (c - 0x3040) / 16
private fun cjkPunctIndexX(c: Char) = (c.toInt() - 0x3000) % 16
private fun cjkPunctIndexY(c: Char) = (c.toInt() - 0x3000) / 16
private fun cjkPunctIndexX(c: Int) = (c - 0x3000) % 16
private fun cjkPunctIndexY(c: Int) = (c - 0x3000) / 16
private fun cyrilicIndexX(c: Char) = (c.toInt() - 0x400) % 16
private fun cyrilicIndexY(c: Char) = (c.toInt() - 0x400) / 16
private fun cyrilicIndexX(c: Int) = (c - 0x400) % 16
private fun cyrilicIndexY(c: Int) = (c - 0x400) / 16
private fun fullwidthUniIndexX(c: Char) = (c.toInt() - 0xFF00) % 16
private fun fullwidthUniIndexY(c: Char) = (c.toInt() - 0xFF00) / 16
private fun fullwidthUniIndexX(c: Int) = (c - 0xFF00) % 16
private fun fullwidthUniIndexY(c: Int) = (c - 0xFF00) / 16
private fun uniPunctIndexX(c: Char) = (c.toInt() - 0x2000) % 16
private fun uniPunctIndexY(c: Char) = (c.toInt() - 0x2000) / 16
private fun uniPunctIndexX(c: Int) = (c - 0x2000) % 16
private fun uniPunctIndexY(c: Int) = (c - 0x2000) / 16
private fun unihanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
private fun unihanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
private fun unihanIndexX(c: Int) = (c - 0x3400) % 256
private fun unihanIndexY(c: Int) = (c - 0x3400) / 256
private fun greekIndexX(c: Char) = (c.toInt() - 0x370) % 16
private fun greekIndexY(c: Char) = (c.toInt() - 0x370) / 16
private fun greekIndexX(c: Int) = (c - 0x370) % 16
private fun greekIndexY(c: Int) = (c - 0x370) / 16
private fun thaiIndexX(c: Char) = (c.toInt() - 0xE00) % 16
private fun thaiIndexY(c: Char) = (c.toInt() - 0xE00) / 16
private fun thaiIndexX(c: Int) = (c - 0xE00) % 16
private fun thaiIndexY(c: Int) = (c - 0xE00) / 16
private fun symbolIndexX(c: Char) = (c.toInt() - 0xE000) % 16
private fun symbolIndexY(c: Char) = (c.toInt() - 0xE000) / 16
private fun symbolIndexX(c: Int) = (c - 0xE000) % 16
private fun symbolIndexY(c: Int) = (c - 0xE000) / 16
private fun armenianIndexX(c: Char) = (c.toInt() - 0x530) % 16
private fun armenianIndexY(c: Char) = (c.toInt() - 0x530) / 16
private fun armenianIndexX(c: Int) = (c - 0x530) % 16
private fun armenianIndexY(c: Int) = (c - 0x530) / 16
private fun kartvelianIndexX(c: Char) = (c.toInt() - 0x10D0) % 16
private fun kartvelianIndexY(c: Char) = (c.toInt() - 0x10D0) / 16
private fun kartvelianIndexX(c: Int) = (c - 0x10D0) % 16
private fun kartvelianIndexY(c: Int) = (c - 0x10D0) / 16
private fun ipaIndexX(c: Char) = (c.toInt() - 0x250) % 16
private fun ipaIndexY(c: Char) = (c.toInt() - 0x250) / 16
private fun ipaIndexX(c: Int) = (c - 0x250) % 16
private fun ipaIndexY(c: Int) = (c - 0x250) / 16
private fun latinExtAddX(c: Char) = (c.toInt() - 0x1E00) % 16
private fun latinExtAddY(c: Char) = (c.toInt() - 0x1E00) / 16
private fun latinExtAddX(c: Int) = (c - 0x1E00) % 16
private fun latinExtAddY(c: Int) = (c - 0x1E00) / 16
private fun cherokeeIndexX(c: Char) = (c.toInt() - 0x13A0) % 16
private fun cherokeeIndexY(c: Char) = (c.toInt() - 0x13A0) / 16
private fun cherokeeIndexX(c: Int) = (c - 0x13A0) % 16
private fun cherokeeIndexY(c: Int) = (c - 0x13A0) / 16
private fun getColour(charHigh: Char, charLow: Char): Color { // input: 0x10ARGB, out: RGBA8888
val codePoint = Character.toCodePoint(charHigh, charLow)
private fun insularIndexX(c: Int) =
if (c == 0x1D79) 0 else (c - 0xA770) % 16
private fun insularIndexY(c: Int) =
if (c == 0x1D79) 0 else (c - 0xA770) / 16
private fun nagariIndexX(c: Int) = (c - 0x900) % 16
private fun nagariIndexY(c: Int) = (c - 0x900) / 16
private fun kartvelianCapsIndexX(c: Int) = (c - 0x1C90) % 16
private fun kartvelianCapsIndexY(c: Int) = (c - 0x1C90) / 16
private fun getColour(codePoint: Int): Color { // input: 0x10ARGB, out: RGBA8888
if (colourBuffer.containsKey(codePoint))
return colourBuffer[codePoint]!!
@@ -217,7 +236,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
SHEET_EXTA_VARW,
SHEET_EXTB_VARW,
SHEET_CYRILIC_VARW,
SHEET_UNI_PUNCT,
SHEET_UNI_PUNCT_VARW,
SHEET_GREEK_VARW,
SHEET_THAI_VARW,
SHEET_HAYEREN_VARW,
@@ -226,7 +245,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
SHEET_LATIN_EXT_ADD_VARW,
SHEET_BULGARIAN_VARW,
SHEET_SERBIAN_VARW,
SHEET_TSALAGI_VARW
SHEET_TSALAGI_VARW,
SHEET_INSUAR_VARW,
SHEET_NAGARI_BENGALI_VARW,
SHEET_KARTULI_CAPS_VARW
)
private val fontParentDir = if (fontDir.endsWith('/') || fontDir.endsWith('\\')) fontDir else "$fontDir/"
@@ -251,7 +273,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
"puae000-e0ff.tga",
"cyrilic_bulgarian_variable.tga",
"cyrilic_serbian_variable.tga",
"tsalagi_variable.tga"
"tsalagi_variable.tga",
"insular_variable.tga",
"devanagari_bengali_variable.tga",
"kartuli_allcaps_variable.tga"
)
private val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
0..0xFF,
@@ -274,9 +299,12 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
0xE000..0xE0FF,
0xF00000..0xF0005F, // assign them to PUA
0xF00060..0xF000BF, // assign them to PUA
0x13A0..0x13F5
0x13A0..0x13F5,
0xA770..0xA787,
0x900..0x9FF,
0x1C90..0x1CBF
)
private val glyphWidths: HashMap<Int, Int> = HashMap() // if the value is negative, it's diacritics
private val glyphProps: HashMap<Int, GlyphProps> = HashMap()
private val sheets: Array<TextureRegionPack>
private var charsetOverride = 0
@@ -302,23 +330,27 @@ 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))
}
buildWidthTableFixed()
if (isVariable) {
println("[TerrarumSansBitmap] loading texture $it [VARIABLE]")
buildWidthTable(pixmap, codeRange[index], 16)
@@ -387,13 +419,22 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
private val offsetUnihan = (H - H_UNIHAN) / 2
private val offsetCustomSym = (H - SIZE_CUSTOM_SYM) / 2
private var textBuffer: CharSequence = ""
private var textBWidth = intArrayOf() // absolute posX of glyphs from print-origin
private var textBGSize = intArrayOf() // width of each glyph
private var firstRun = true
private var textBuffer = CodepointSequence(256)
private var oldCharSequence = ""
//private lateinit var textTexture: FrameBuffer
//private val textTexCamera = OrthographicCamera()
private var posXbuffer = intArrayOf() // absolute posX of glyphs from print-origin
private var posYbuffer = intArrayOf() // absolute posY of glyphs from print-origin
private var glyphWidthBuffer = intArrayOf() // width of each glyph
private lateinit var originalColour: Color
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
private var nullProp = GlyphProps(15, 0)
override fun draw(batch: Batch, charSeq: CharSequence, x: Float, y: Float): GlyphLayout? {
val oldProjectionMatrix = batch.projectionMatrix
fun Int.flipY() = this * if (flipY) 1 else -1
@@ -403,172 +444,242 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
val y = Math.round(y).toFloat()
if (textBuffer != str) {
textBuffer = str
val widths = getWidthOfCharSeq(str)
if (charSeq.isNotBlank()) {
if (oldCharSequence != charSeq || firstRun) {
textBuffer = charSeq.toCodePoints()
val str = textBuffer
val widths = getWidthOfCharSeq(str)
val texWidth = widths.sum()
textBGSize = widths
textBWidth = IntArray(str.length, { charIndex ->
if (charIndex == 0)
0
else {
var acc = 0
(0..charIndex - 1).forEach { acc += maxOf(0, widths[it]) } // don't accumulate diacrtics (which has negative value)
/*return*/acc
}
})
}
//if (!firstRun) textTexture.dispose()
//textTexture = FrameBuffer(Pixmap.Format.RGBA8888, texWidth, H, true)
//print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
//textBWidth.forEach { print("$it ") }; println()
glyphWidthBuffer = widths
posXbuffer = IntArray(str.size, { 0 })
posYbuffer = IntArray(str.size, { 0 })
originalColour = batch.color.cpy()
var mainCol = originalColour
var shadowCol = mainCol.cpy().mul(0.5f,0.5f,0.5f,1f)
var nonDiacriticCounter = 0 // index of last instance of non-diacritic char
var stackUpwardCounter = 0
var stackDownwardCounter = 0
for (charIndex in 0 until posXbuffer.size) {
if (charIndex > 0) {
// nonDiacriticCounter allows multiple diacritics
val thisChar = str[charIndex]
if (glyphProps[thisChar] == null && errorOnUnknownChar) {
val errorGlyphSB = StringBuilder()
Character.toChars(thisChar).forEach { errorGlyphSB.append(it) }
throw InternalError("No GlyphProps for char '$errorGlyphSB' " +
"(${thisChar.charInfo()})")
}
val thisProp = glyphProps[thisChar] ?: nullProp
val lastNonDiacriticChar = str[nonDiacriticCounter]
val itsProp = glyphProps[lastNonDiacriticChar] ?: nullProp
var index = 0
while (index <= textBuffer.lastIndex) {
val c = textBuffer[index]
val sheetID = getSheetType(c)
val (sheetX, sheetY) = getSheetwisePosition(c)
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetX}x${sheetY}")
if (isColourCodeLow(c)) {
val cchigh = c
val cclow = textBuffer[index + 1]
if (Character.toCodePoint(cchigh, cclow) == 0x100000) {
mainCol = originalColour
shadowCol = mainCol.cpy().mul(0.5f,0.5f,0.5f,1f)
}
else {
mainCol = getColour(cchigh, cclow)
shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
}
index += 1
}
else if (isCharsetOverrideLow(c)) {
val cchigh = c
val cclow = textBuffer[index + 1]
charsetOverride = Character.toCodePoint(cchigh, cclow) - CHARSET_OVERRIDE_NULL
index += 1
}
else if (isCharsetOverrideHigh(c) || isColourCodeHigh(c)) {
/* do nothing and advance */
}
else if (sheetID == SHEET_HANGUL) {
val hangulSheet = sheets[SHEET_HANGUL]
val hIndex = c.toInt() - 0xAC00
val indexCho = getHanChosung(hIndex)
val indexJung = getHanJungseong(hIndex)
val indexJong = getHanJongseong(hIndex)
val choRow = getHanInitialRow(hIndex)
val jungRow = getHanMedialRow(hIndex)
val jongRow = getHanFinalRow(hIndex)
//println("char: ${thisChar.charInfo()}\nproperties: $thisProp")
if (!noShadow) {
batch.color = shadowCol
val alignmentOffset = when (thisProp.alignWhere) {
GlyphProps.LEFT -> 0
GlyphProps.RIGHT -> thisProp.width - W_VAR_INIT
GlyphProps.CENTRE -> Math.floor((thisProp.width - W_VAR_INIT) / 2.0).toInt()
else -> 0 // implies "diacriticsBeforeGlyph = true"
}
batch.draw(hangulSheet.get(indexCho, choRow ), x + textBWidth[index] + 1, y)
batch.draw(hangulSheet.get(indexCho, choRow ), x + textBWidth[index] , y + if (flipY) 1 else -1)
batch.draw(hangulSheet.get(indexCho, choRow ), x + textBWidth[index] + 1, y + if (flipY) 1 else -1)
if (!thisProp.writeOnTop) {
posXbuffer[charIndex] =
if (itsProp.alignWhere == GlyphProps.RIGHT)
posXbuffer[nonDiacriticCounter] + W_VAR_INIT + alignmentOffset + interchar
else
posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset + interchar
nonDiacriticCounter = charIndex
stackUpwardCounter = 0
stackDownwardCounter = 0
}
else {
// set X pos according to alignment information
posXbuffer[charIndex] = when (thisProp.alignWhere) {
GlyphProps.LEFT -> posXbuffer[nonDiacriticCounter]
GlyphProps.RIGHT -> {
posXbuffer[nonDiacriticCounter] - (W_VAR_INIT - itsProp.width)
}
GlyphProps.CENTRE -> {
val alignXPos = if (itsProp.alignXPos == 0) itsProp.width.div(2) else itsProp.alignXPos
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index] + 1, y)
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index] , y + if (flipY) 1 else -1)
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index] + 1, y + if (flipY) 1 else -1)
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index] + 1, y)
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index] , y + if (flipY) 1 else -1)
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index] + 1, y + if (flipY) 1 else -1)
}
posXbuffer[nonDiacriticCounter] + alignXPos - (W_VAR_INIT - 1).div(2)
}
else -> throw InternalError("Unsupported alignment: ${thisProp.alignWhere}")
}
batch.color = mainCol
batch.draw(hangulSheet.get(indexCho, choRow) , x + textBWidth[index], y)
batch.draw(hangulSheet.get(indexJung, jungRow), x + textBWidth[index], y)
batch.draw(hangulSheet.get(indexJong, jongRow), x + textBWidth[index], y)
}
else {
try {
val offset = if (!isDiacritics(c)) 0 else {
if (index > 0) // LIMITATION: does not support double (or more) diacritics properly
(textBGSize[index] - textBGSize[index - 1]) / 2
else
textBGSize[index]
// set Y pos according to diacritics position
if (thisProp.diacriticsStackDown) {
posYbuffer[charIndex] = H_DIACRITICS * stackDownwardCounter
stackDownwardCounter++
}
else {
posYbuffer[charIndex] = -H_DIACRITICS * stackUpwardCounter
stackUpwardCounter++
}
}
}
}
if (!noShadow) {
batch.color = shadowCol
batch.draw(
sheets[sheetID].get(sheetX, sheetY),
x + textBWidth[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 + textBWidth[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 + textBWidth[index] + 1 + offset,
y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan.flipY() + 1
else if (sheetID == SHEET_CUSTOM_SYM)
offsetCustomSym + 1
else
1).flipY()
)
//print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
//posXbuffer.forEach { print("$it ") }; println()
firstRun = false
}
//textTexCamera.setToOrtho(false, textTexture.width.toFloat(), textTexture.height.toFloat())
//textTexCamera.update()
//batch.projectionMatrix = textTexCamera.combined
originalColour = batch.color.cpy()
var mainCol = originalColour
var shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
//textTexture.begin()
val runs = if (noShadow) 0..0 else 3 downTo 0
for (run in runs) { // 0: Main, 1..3: Shadows
resetHash()
var index = 0
while (index <= textBuffer.lastIndex) {
val c = textBuffer[index]
val sheetID = getSheetType(c)
val (sheetX, sheetY) = getSheetwisePosition(c)
val hash = getHash(c)
if (run == 0) {
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetX}x${sheetY}")
}
batch.color = mainCol
batch.draw(
sheets[sheetID].get(sheetX, sheetY),
x + textBWidth[index] + offset,
y +
if (isColourCode(c)) {
if (c == 0x100000) {
mainCol = originalColour
shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
}
else {
mainCol = getColour(c)
shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
}
}
else if (isCharsetOverride(c)) {
charsetOverride = c - CHARSET_OVERRIDE_NULL
}
else if (sheetID == SHEET_HANGUL) {
val hangulSheet = sheets[SHEET_HANGUL]
val hIndex = c - 0xAC00
val indexCho = getHanChosung(hIndex)
val indexJung = getHanJungseong(hIndex)
val indexJong = getHanJongseong(hIndex)
val choRow = getHanInitialRow(hIndex)
val jungRow = getHanMedialRow(hIndex)
val jongRow = getHanFinalRow(hIndex)
when (run) {
0 -> {
batch.color = mainCol
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index].toFloat(), y)
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index].toFloat(), y)
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index].toFloat(), y)
}
1 -> {
batch.color = shadowCol
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index] + 1, y)
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] + 1, y)
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] + 1, y)
}
2 -> {
batch.color = shadowCol
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index], y + 1.flipY())
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index], y + 1.flipY())
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index], y + 1.flipY())
}
3 -> {
batch.color = shadowCol
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index] + 1, 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 + 1.flipY())
}
}
}
else {
try {
val posY = y + posYbuffer[index].flipY() +
if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan
else if (sheetID == SHEET_CUSTOM_SYM)
offsetCustomSym
else 0
)
}
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
batch.color = mainCol
val posX = x + posXbuffer[index]
val texture = sheets[sheetID].get(sheetX, sheetY)
when (run) {
0 -> {
batch.color = mainCol
batch.draw(texture, posX, posY)
}
1 -> {
batch.color = shadowCol
batch.draw(texture, posX + 1, posY)
}
2 -> {
batch.color = shadowCol
batch.draw(texture, posX, posY + 1.flipY())
}
3 -> {
batch.color = shadowCol
batch.draw(texture, posX + 1, posY + 1.flipY())
}
}
}
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
batch.color = mainCol
}
}
index++
}
}
/*textTexture.end()
batch.color = originalColour
batch.projectionMatrix = oldProjectionMatrix
val textTex = textTexture.colorBufferTexture
batch.draw(textTex, x, y, textTex.width.toFloat(), textTex.height.toFloat())
*/
index += 1
}
batch.color = originalColour
return null
}
private fun Int.charInfo() = "U+${this.toString(16).padStart(4, '0').toUpperCase()}: ${Character.getName(this)}"
override fun dispose() {
super.dispose()
@@ -576,21 +687,23 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
sheets.forEach { it.dispose() }
}
private fun getWidthOfCharSeq(s: CharSequence): IntArray {
val len = IntArray(s.length)
private fun getWidthOfCharSeq(s: CodepointSequence): IntArray {
val len = IntArray(s.size)
for (i in 0..s.lastIndex) {
val chr = s[i]
val ctype = getSheetType(s[i])
if (variableWidthSheets.contains(ctype)) {
if (!glyphWidths.containsKey(chr.toInt())) {
println("[TerrarumSansBitmap] no width data for glyph number ${Integer.toHexString(chr.toInt()).toUpperCase()}")
if (!glyphProps.containsKey(chr)) {
System.err.println("[TerrarumSansBitmap] no width data for glyph number ${Integer.toHexString(chr.toInt()).toUpperCase()}")
len[i] = W_LATIN_WIDE
}
len[i] = glyphWidths[chr.toInt()]!!
val prop = glyphProps[chr] ?: nullProp
//println("${chr.toInt()} -> $prop")
len[i] = prop.width * (if (prop.writeOnTop) -1 else 1)
}
else if (isColourCodeHigh(chr) || isColourCodeLow(chr) || isCharsetOverrideHigh(chr) || isCharsetOverrideLow(chr))
else if (isColourCode(chr) || isCharsetOverride(chr))
len[i] = 0
else if (ctype == SHEET_CJK_PUNCT)
len[i] = W_ASIAN_PUNCT
@@ -612,7 +725,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
return len
}
private fun getSheetType(c: Char): Int {
private fun getSheetType(c: Int): Int {
if (charsetOverride == 1 && isBulgarian(c))
return SHEET_BULGARIAN_VARW
else if (charsetOverride == 2 && isBulgarian(c))
@@ -632,7 +745,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
else if (isCyrilic(c))
return SHEET_CYRILIC_VARW
else if (isUniPunct(c))
return SHEET_UNI_PUNCT
return SHEET_UNI_PUNCT_VARW
else if (isCJKPunct(c))
return SHEET_CJK_PUNCT
else if (isFullwidthUni(c))
@@ -655,13 +768,19 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
return SHEET_LATIN_EXT_ADD_VARW
else if (isCherokee(c))
return SHEET_TSALAGI_VARW
else if (isInsular(c))
return SHEET_INSUAR_VARW
else if (isNagariBengali(c))
return SHEET_NAGARI_BENGALI_VARW
else if (isKartvelianCaps(c))
return SHEET_KARTULI_CAPS_VARW
else
return SHEET_UNKNOWN
// fixed width
// fallback
}
private fun getSheetwisePosition(ch: Char): IntArray {
private fun getSheetwisePosition(ch: Int): IntArray {
val sheetX: Int; val sheetY: Int
when (getSheetType(ch)) {
SHEET_UNIHAN -> {
@@ -692,7 +811,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
sheetX = fullwidthUniIndexX(ch)
sheetY = fullwidthUniIndexY(ch)
}
SHEET_UNI_PUNCT -> {
SHEET_UNI_PUNCT_VARW -> {
sheetX = uniPunctIndexX(ch)
sheetY = uniPunctIndexY(ch)
}
@@ -736,9 +855,21 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
sheetX = cherokeeIndexX(ch)
sheetY = cherokeeIndexY(ch)
}
SHEET_INSUAR_VARW -> {
sheetX = insularIndexX(ch)
sheetY = insularIndexY(ch)
}
SHEET_NAGARI_BENGALI_VARW -> {
sheetX = nagariIndexX(ch)
sheetY = nagariIndexY(ch)
}
SHEET_KARTULI_CAPS_VARW -> {
sheetX = kartvelianCapsIndexX(ch)
sheetY = kartvelianCapsIndexY(ch)
}
else -> {
sheetX = ch.toInt() % 16
sheetY = ch.toInt() / 16
sheetX = ch % 16
sheetY = ch / 16
}
}
@@ -758,30 +889,118 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
val codeStartX = cellX + binaryCodeOffset
val codeStartY = cellY
val tagStartY = codeStartY + 10
var glyphWidth = 0
for (downCtr in 0..3) {
var width = 0
var tags = 0
for (y in 0..3) {
// if ALPHA is not zero, assume it's 1
if (pixmap.getPixel(codeStartX, codeStartY + downCtr).and(0xFF) != 0) {
glyphWidth = glyphWidth or (1 shl downCtr)
if (pixmap.getPixel(codeStartX, codeStartY + y).and(0xFF) != 0) {
width = width or (1 shl y)
}
}
val isDiacritics = pixmap.getPixel(codeStartX, codeStartY + H - 1).and(0xFF) != 0
if (isDiacritics)
glyphWidth = -glyphWidth
for (y in 0..9) {
// if ALPHA is not zero, assume it's 1
if (pixmap.getPixel(codeStartX, tagStartY + y).and(0xFF) != 0) {
tags = tags or (1 shl y)
}
}
glyphWidths[code] = glyphWidth
//println("$code: Width $width, tags $tags")
/*val isDiacritics = pixmap.getPixel(codeStartX, codeStartY + H - 1).and(0xFF) != 0
if (isDiacritics)
glyphWidth = -glyphWidth*/
glyphProps[code] = GlyphProps(width, tags)
}
}
fun buildWidthTableFixed() {
// fixed-width props
this.codeRange[SHEET_CJK_PUNCT].forEach { glyphProps[it] = GlyphProps(W_ASIAN_PUNCT, 0) }
this.codeRange[SHEET_CUSTOM_SYM].forEach { glyphProps[it] = GlyphProps(20, 0) }
this.codeRange[SHEET_FW_UNI].forEach { glyphProps[it] = GlyphProps(W_UNIHAN, 0) }
this.codeRange[SHEET_HANGUL].forEach { glyphProps[it] = GlyphProps(W_HANGUL, 0) }
this.codeRange[SHEET_KANA].forEach { glyphProps[it] = GlyphProps(W_KANA, 0) }
this.codeRange[SHEET_RUNIC].forEach { glyphProps[it] = GlyphProps(9, 0) }
this.codeRange[SHEET_UNIHAN].forEach { glyphProps[it] = GlyphProps(W_UNIHAN, 0) }
(0xD800..0xDFFF).forEach { glyphProps[it] = GlyphProps(0, 0) }
(0x100000..0x10FFFF).forEach { glyphProps[it] = GlyphProps(0, 0) }
(0xFFFF8..0xFFFFF).forEach { glyphProps[it] = GlyphProps(0, 0) }
// manually build width table of Kana Supplements
(0x31F0..0x31FF).forEach { glyphProps[it] = GlyphProps(W_KANA, 0) }
(0x1B000..0x1B001).forEach { glyphProps[it] = GlyphProps(W_KANA, 0) }
// manually add width of one orphan insular letter
// WARNING: glyphs in 0xA770..0xA778 has invalid data, further care is required
glyphProps[0x1D79] = GlyphProps(9, 0)
}
private val glyphLayout = GlyphLayout()
fun getWidth(text: String): Int {
return getWidthOfCharSeq(text).sum()
return getWidthOfCharSeq(text.toCodePoints()).sum()
}
/** UTF-16 to ArrayList of Int. UTF-16 is because of Java
* Note: CharSequence IS a String. java.lang.String implements CharSequence.
*/
private fun CharSequence.toCodePoints(): CodepointSequence {
val seq = ArrayList<Int>()
var i = 0
while (i < this.length) {
val c = this[i]
if (i < this.lastIndex && c.isHighSurrogate()) {
val cNext = this[i + 1]
if (!cNext.isLowSurrogate())
throw IllegalArgumentException("Malformed UTF-16 String: High surrogate must be paired with low surrogate")
val H = c
val L = cNext
seq.add(Character.toCodePoint(H, L))
i++ // skip next char (guaranteed to be Low Surrogate)
}
else {
seq.add(c.toInt())
}
i++
}
// swap position of {letter, diacritics that comes before the letter}
i = 1
while (i <= seq.lastIndex) {
if ((glyphProps[seq[i]] ?: nullProp).diacriticsBeforeGlyph) {
val t = seq[i - 1]
seq[i - 1] = seq[i]
seq[i] = t
}
i++
}
return seq
}
/** High surrogate comes before the low. */
private fun Char.isHighSurrogate() = (this.toInt() in 0xD800..0xDBFF)
/** CodePoint = 0x10000 + (H - 0xD800) * 0x400 + (L - 0xDC00) */
private fun Char.isLowSurrogate() = (this.toInt() in 0xDC00..0xDFFF)
var interchar = 0
var scale = 1
@@ -798,6 +1017,18 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
val charsetOverrideBulgarian = Character.toChars(CHARSET_OVERRIDE_BG_BG)
val charsetOverrideSerbian = Character.toChars(CHARSET_OVERRIDE_SR_SR)
private val hashBasis = -3750763034362895579L
private val hashPrime = 1099511628211L
private var hashAccumulator = hashBasis
fun getHash(char: Int): Long {
hashAccumulator = hashAccumulator xor char.toLong()
hashAccumulator *= hashPrime
return hashAccumulator
}
fun resetHash() {
hashAccumulator = hashBasis
}
companion object {
internal val JUNG_COUNT = 21
internal val JONG_COUNT = 28
@@ -807,13 +1038,15 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
internal val W_KANA = 12
internal val W_UNIHAN = 16
internal val W_LATIN_WIDE = 9 // width of regular letters
internal val W_VAR_INIT = 15
internal val W_VAR_INIT = 15 // it assumes width of 15 regardless of the tagged width
internal val HGAP_VAR = 1
internal val H = 20
internal val H_UNIHAN = 16
internal val H_DIACRITICS = 3
internal val SIZE_CUSTOM_SYM = 18
internal val SHEET_ASCII_VARW = 0
@@ -825,7 +1058,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
internal val SHEET_UNIHAN = 6
internal val SHEET_CYRILIC_VARW = 7
internal val SHEET_FW_UNI = 8
internal val SHEET_UNI_PUNCT = 9
internal val SHEET_UNI_PUNCT_VARW = 9
internal val SHEET_GREEK_VARW = 10
internal val SHEET_THAI_VARW = 11
internal val SHEET_HAYEREN_VARW = 12
@@ -837,6 +1070,9 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
internal val SHEET_BULGARIAN_VARW = 18
internal val SHEET_SERBIAN_VARW = 19
internal val SHEET_TSALAGI_VARW = 20
internal val SHEET_INSUAR_VARW = 21
internal val SHEET_NAGARI_BENGALI_VARW=22
internal val SHEET_KARTULI_CAPS_VARW = 23
internal val SHEET_UNKNOWN = 254

View File

@@ -24,7 +24,7 @@
package net.torvald.terrarumsansbitmap.slick2d
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
/*import net.torvald.terrarumsansbitmap.gdx.GameFontBase
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.JUNG_COUNT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.JONG_COUNT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_ASIAN_PUNCT
@@ -46,7 +46,7 @@ import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_CJK_PUNCT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_UNIHAN
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_CYRILIC_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_FW_UNI
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_UNI_PUNCT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_UNI_PUNCT_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_GREEK_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_THAI_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_HAYEREN_VARW
@@ -144,7 +144,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
private fun isUniHan(c: Char) = c.toInt() in codeRange[SHEET_UNIHAN]
private fun isCyrilic(c: Char) = c.toInt() in codeRange[SHEET_CYRILIC_VARW]
private fun isFullwidthUni(c: Char) = c.toInt() in codeRange[SHEET_FW_UNI]
private fun isUniPunct(c: Char) = c.toInt() in codeRange[SHEET_UNI_PUNCT]
private fun isUniPunct(c: Char) = c.toInt() in codeRange[SHEET_UNI_PUNCT_VARW]
private fun isGreek(c: Char) = c.toInt() in codeRange[SHEET_GREEK_VARW]
private fun isThai(c: Char) = c.toInt() in codeRange[SHEET_THAI_VARW]
private fun isDiacritics(c: Char) = c.toInt() in 0xE34..0xE3A
@@ -238,7 +238,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
SHEET_EXTA_VARW,
SHEET_EXTB_VARW,
SHEET_CYRILIC_VARW,
SHEET_UNI_PUNCT,
SHEET_UNI_PUNCT_VARW,
SHEET_GREEK_VARW,
SHEET_THAI_VARW,
SHEET_HAYEREN_VARW,
@@ -628,7 +628,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
else if (isCyrilic(c))
return SHEET_CYRILIC_VARW
else if (isUniPunct(c))
return SHEET_UNI_PUNCT
return SHEET_UNI_PUNCT_VARW
else if (isCJKPunct(c))
return SHEET_CJK_PUNCT
else if (isFullwidthUni(c))
@@ -686,7 +686,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
sheetX = fullwidthUniIndexX(ch)
sheetY = fullwidthUniIndexY(ch)
}
SHEET_UNI_PUNCT -> {
SHEET_UNI_PUNCT_VARW -> {
sheetX = uniPunctIndexX(ch)
sheetY = uniPunctIndexY(ch)
}
@@ -787,4 +787,4 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
val noColorCode = toColorCode(0x0000)
}
}
}*/