full support of old hangul

This commit is contained in:
minjaesong
2018-08-29 00:35:46 +09:00
parent 32290dd504
commit b8963cd3a9
11 changed files with 246 additions and 151 deletions

193
.idea/workspace.xml generated
View File

@@ -8,13 +8,12 @@
<component name="ChangeListManager">
<list default="true" id="22c5bc80-996c-4846-b173-7dc8c2096fe3" name="Default" comment="">
<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/lib/TerrarumSansBitmap.jar" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PUA_allocation_chart.xlsx" beforeDir="false" afterPath="$PROJECT_DIR$/PUA_allocation_chart.xlsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/LatinExtA_variable.tga" beforeDir="false" afterPath="$PROJECT_DIR$/assets/LatinExtA_variable.tga" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/ascii_variable.tga" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/assets/hangul_johab.tga" beforeDir="false" afterPath="$PROJECT_DIR$/assets/hangul_johab.tga" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/ipa_ext_variable.tga" beforeDir="false" afterPath="$PROJECT_DIR$/assets/ipa_ext_variable.tga" afterDir="false" />
<change beforePath="$PROJECT_DIR$/demo.PNG" beforeDir="false" afterPath="$PROJECT_DIR$/demo.PNG" afterDir="false" />
<change beforePath="$PROJECT_DIR$/demotext.txt" beforeDir="false" afterPath="$PROJECT_DIR$/demotext.txt" 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" />
<change beforePath="$PROJECT_DIR$/testing.PNG" beforeDir="false" afterPath="$PROJECT_DIR$/testing.PNG" afterDir="false" />
@@ -35,11 +34,11 @@
<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="false">
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="533">
<caret line="383" column="30" selection-start-line="383" selection-start-column="30" selection-end-line="383" selection-end-column="30" />
<state relative-caret-position="507">
<caret line="136" column="36" selection-start-line="136" selection-start-column="36" selection-end-line="136" selection-end-column="36" />
</state>
</provider>
</entry>
@@ -56,31 +55,21 @@
<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="234">
<state relative-caret-position="6084">
<caret line="490" selection-start-line="490" selection-end-line="490" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="demo.PNG" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="testing.PNG" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/testing.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
</leaf>
</split-first>
<split-second>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="FontTestGDX.kt" pinned="false" current-in-tab="true">
<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="455">
<caret line="41" column="44" selection-start-line="41" selection-start-column="44" selection-end-line="41" selection-end-column="44" />
<state relative-caret-position="234">
<caret line="25" column="40" selection-start-line="25" selection-start-column="40" selection-end-line="25" selection-end-column="40" />
<folding>
<element signature="e#0#384#0" expanded="true" />
</folding>
@@ -88,29 +77,39 @@
</provider>
</entry>
</file>
<file leaf-file-name="testtext.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/testtext.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="13">
<caret line="1" column="12" selection-start-line="1" selection-start-column="12" selection-end-line="1" selection-end-column="12" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="demotext.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="547">
<caret line="79" column="34" selection-start-line="79" selection-start-column="34" selection-end-line="79" selection-end-column="34" />
</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="108">
<caret line="912" selection-start-line="912" selection-end-line="912" />
<state relative-caret-position="555">
<caret line="611" column="24" selection-start-line="611" selection-start-column="24" selection-end-line="611" selection-end-column="24" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="testtext.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/testtext.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="4" selection-start-column="4" selection-end-column="4" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="testing.PNG" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/testing.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="demo.PNG" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="demotext.txt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="572">
<caret line="68" selection-start-line="68" selection-end-line="68" />
</state>
</provider>
</entry>
@@ -119,7 +118,7 @@
<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="429">
<first_editor relative-caret-position="699">
<caret line="94" column="176" selection-start-line="94" selection-start-column="176" selection-end-line="94" selection-end-column="176" />
</first_editor>
<second_editor>
@@ -165,8 +164,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>fun relo</find>
<find>3633</find>
<find>println(</find>
<find>Width ta</find>
<find>getWidth</find>
@@ -195,6 +192,8 @@
<find>pro</find>
<find>system</find>
<find>this font</find>
<find>posXbuffer</find>
<find>U+</find>
</findStrings>
<replaceStrings>
<replace>.141</replace>
@@ -220,25 +219,25 @@
<option value="$PROJECT_DIR$/CONTRIBUTORS.txt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/GlyphProps.kt" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/demotext.txt" />
<option value="$PROJECT_DIR$/testtext.txt" />
<option value="$PROJECT_DIR$/CONTRIBUTING.md" />
<option value="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" />
<option value="$PROJECT_DIR$/testtext.txt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" />
<option value="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" />
<option value="$PROJECT_DIR$/demotext.txt" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1936" />
<option name="height" value="1216" />
<option name="x" value="-7" />
<option name="width" value="1932" />
<option name="height" value="1167" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
@@ -280,7 +279,6 @@
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -349,16 +347,6 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<module name="BuildJAR_TerrarumSansBitmap" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" />
<option name="WORKING_DIRECTORY" />
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType" factoryName="Kotlin script">
<option name="filePath" />
<option name="vmParameters" />
@@ -449,6 +437,16 @@
<envs />
<method />
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<module name="BuildJAR_TerrarumSansBitmap" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" />
<option name="WORKING_DIRECTORY" />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
@@ -505,11 +503,10 @@
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1216" extended-state="6" />
<editor active="true" />
<layout>
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.3283859" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.32745826" />
<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" />
@@ -517,11 +514,11 @@
<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.12313433" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.12633263" />
<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.23005566" />
<window_info active="true" anchor="bottom" id="Debug" order="3" visible="true" weight="0.2773655" />
<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" />
@@ -534,13 +531,13 @@
<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 anchor="bottom" id="Message" order="0" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.122068234" />
<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" weight="0.32931355" />
<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" />
@@ -549,7 +546,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="Find" order="1" weight="0.32931355" />
<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" />
@@ -854,13 +851,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CONTRIBUTORS.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="23" selection-start-column="23" selection-end-column="23" />
</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">
@@ -875,7 +865,7 @@
</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="234">
<state relative-caret-position="6084">
<caret line="490" selection-start-line="490" selection-end-line="490" />
</state>
</provider>
@@ -887,24 +877,17 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/testtext.txt">
<entry file="file://$PROJECT_DIR$/CONTRIBUTORS.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="13">
<caret line="1" column="12" selection-start-line="1" selection-start-column="12" selection-end-line="1" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="547">
<caret line="79" column="34" selection-start-line="79" selection-start-column="34" selection-end-line="79" selection-end-column="34" />
<state>
<caret column="23" selection-start-column="23" selection-end-column="23" />
</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="429">
<first_editor relative-caret-position="699">
<caret line="94" column="176" selection-start-line="94" selection-start-column="176" selection-end-line="94" selection-end-column="176" />
</first_editor>
<second_editor>
@@ -913,29 +896,43 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/testtext.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="4" selection-start-column="4" selection-end-column="4" />
</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="555">
<caret line="611" column="24" selection-start-line="611" selection-start-column="24" selection-end-line="611" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/testing.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="455">
<caret line="41" column="44" selection-start-line="41" selection-start-column="44" selection-end-line="41" selection-end-column="44" />
<state relative-caret-position="234">
<caret line="25" column="40" selection-start-line="25" selection-start-column="40" selection-end-line="25" selection-end-column="40" />
<folding>
<element signature="e#0#384#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
<entry file="file://$PROJECT_DIR$/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="533">
<caret line="383" column="30" selection-start-line="383" selection-start-column="30" selection-end-line="383" selection-end-column="30" />
<state relative-caret-position="572">
<caret line="68" selection-start-line="68" selection-end-line="68" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/testing.PNG">
<provider selected="true" editor-type-id="images" />
</entry>
</component>
<component name="masterDetails">
<states>

View File

@@ -23,8 +23,8 @@ class FontTestGDX : Game() {
lateinit var camera: OrthographicCamera
private val demotextName = "testtext.txt"
private val outimageName = "testing.png"
private val demotextName = "demotext.txt"
private val outimageName = "demo.png"
override fun create() {
font = GameFontBase("./assets", flipY = false, errorOnUnknownChar = false) // must test for two flipY cases

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

BIN
demo.PNG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View File

@@ -45,7 +45,7 @@ How multilingual? Real multilingual!
􏻬あめつちほしそら やまかはみねたに くもきりむろこけ ひといぬうへすゑ ゆわさるおふせよ えの𛀁をなれゐて􀀀
􏻬トリナクコヱス ユメサマセ ミヨアケワタル ヒンカシヲ ソライロハエテ オキツヘニ ホフネムレヰヌ モヤノウチ􀀀
􏻬田居に出で 菜摘むわれをぞ 君召すと 求食り追ひゆく 山城の 打酔へる子ら 藻葉干せよ え舟繋けぬ􀀀
􏻬정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 하얬다 도럄직한 퀡봹퉪헰􀀀
􏻬정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 하얬다 도럄직한 퀡봹퉪헰ꥸᅦퟗꥸᅦퟗᄋힳᆫ􀀀
􏻬Č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ą􀀀
􏻬Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех􀀀
@@ -61,6 +61,7 @@ How multilingual? Real multilingual!
􏻬Жебракують філософи при ґанку церкви в Гадячі, ще й шатро їхнє п’яне знаємо􀀀
􏻬Do bạch kim rất quý nên sẽ dùng để lắp vô xương􀀀
􏻬日堀油告観観藤村抄海評業庁経賃室弁市。太撮収改売週法所何都慣次現。価紙一無三洋日話転手治稿載末替付致治。􀀀
􏻬[pʰnɣɬɥi.m͡ŋχɫʍɨnaɸ.cθʊɫɯ.ɹɨɫʏ͡ɛx.ɯ͡ɣaxɲaɣɫ.ɸtʰɑɣɴ]􀀀
􏃯Features:􀀀

View File

@@ -83,46 +83,93 @@ typealias CodepointSequence = ArrayList<Int>
*/
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
private fun getHanJongseong(hanIndex: Int) = hanIndex % JONG_COUNT
// Hangul Implementation Specific //
private val jungseongWide = arrayOf(8, 12, 13, 17, 18, 21)
private val jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22)
private fun getWanseongHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
private fun getWanseongHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
private fun getWanseongHanJongseong(hanIndex: Int) = hanIndex % JONG_COUNT
private fun isJungseongWide(hanIndex: Int) = jungseongWide.contains(getHanJungseong(hanIndex))
private fun isJungseongComplex(hanIndex: Int) = jungseongComplex.contains(getHanJungseong(hanIndex))
private val jungseongWide: Array<Int> = arrayOf(9,13,14,18,19,34,35,39,45,51,53,54,62,64,66,80,83)
private val jungseongComplex: Array<Int> = arrayOf(10,11,12,15,16,17,20) + (22..33).toList() + arrayOf(36,37,38) + (40..44).toList() + arrayOf(46,47,48,49,50,52) + (55..60).toList() + arrayOf(63,65) + (67..79).toList() + arrayOf(81,82) + (84..93).toList()
private fun getHanInitialRow(hanIndex: Int): Int {
val ret: Int
private fun isJungseongWide(hanIndex: Int) = jungseongWide.binarySearch(hanIndex) >= 0
private fun isJungseongComplex(hanIndex: Int) = jungseongComplex.binarySearch(hanIndex) >= 0
if (isJungseongWide(hanIndex))
ret = 2
else if (isJungseongComplex(hanIndex))
ret = 4
else
ret = 0
/**
* @param i Initial (Chosung)
* @param p Peak (Jungseong)
* @param f Final (Jongseong)
*/
private fun getHanInitialRow(i: Int, p: Int, f: Int): Int {
val ret =
if (isJungseongWide(p)) 2
else if (isJungseongComplex(p)) 4
else 0
return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
return if (f == 0) ret else ret + 1
}
private fun getHanMedialRow(hanIndex: Int) = if (getHanJongseong(hanIndex) == 0) 6 else 7
private fun getHanMedialRow(i: Int, p: Int, f: Int) = if (f == 0) 6 else 7
private fun getHanFinalRow(hanIndex: Int): Int {
val jungseongIndex = getHanJungseong(hanIndex)
private fun getHanFinalRow(i: Int, p: Int, f: Int): Int {
return if (jungseongWide.contains(jungseongIndex))
return if (isJungseongWide(p))
8
else
9
}
private fun isHangulChosung(c: Int) = c in (0x1100..0x115F) || c in (0xA960..0xA97F)
private fun isHangulJungseong(c: Int) = c in (0x1160..0x11A7) || c in (0xD7B0..0xD7C6)
private fun isHangulJongseong(c: Int) = c in (0x11A8..0x11FF) || c in (0xD7CB..0xD7FB)
private fun toHangulChosungIndex(c: Int) =
if (!isHangulChosung(c)) throw IllegalArgumentException("This Hangul sequence does not begin with Chosung (${c.toHex()})")
else if (c in 0x1100..0x115F) c - 0x1100
else c - 0xA960 + 96
private fun toHangulJungseongIndex(c: Int) =
if (!isHangulJungseong(c)) 0
else if (c in 0x1160..0x11A7) c - 0x1160
else c - 0xD7B0 + 72
private fun toHangulJongseongIndex(c: Int) =
if (!isHangulJongseong(c)) 0
else if (c in 0x11A8..0x11FF) c - 0x11A8 + 1
else c - 0xD7CB + 88 + 1
/**
* X-position in the spritesheet
*
* @param iCP Code point for Initial (Chosung)
* @param pCP Code point for Peak (Jungseong)
* @param fCP Code point for Final (Jongseong
*/
private fun toHangulIndex(iCP: Int, pCP: Int, fCP: Int): IntArray {
val indexI = toHangulChosungIndex(iCP)
val indexP = toHangulJungseongIndex(pCP)
val indexF = toHangulJongseongIndex(fCP)
return intArrayOf(indexI, indexP, indexF)
}
private fun toHangulIndexAndRow(iCP: Int, pCP: Int, fCP: Int): Pair<IntArray, IntArray> {
val (indexI, indexP, indexF) = toHangulIndex(iCP, pCP, fCP)
val rowI = getHanInitialRow(indexI, indexP, indexF)
val rowP = getHanMedialRow(indexI, indexP, indexF)
val rowF = getHanFinalRow(indexI, indexP, indexF)
return intArrayOf(indexI, indexP, indexF) to intArrayOf(rowI, rowP, rowF)
}
// END Hangul //
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 isKana(c: Int) = c in codeRange[SHEET_KANA]
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]
@@ -218,7 +265,6 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
private fun diacriticalMarksIndexX(c: Int) = (c - 0x300) % 16
private fun diacriticalMarksIndexY(c: Int) = (c - 0x300) / 16
private val lowHeightLetters = "acegijmnopqrsuvwxyzɱɳʙɾɽʒʂʐʋɹɻɥɟɡɢʛȵɲŋɴʀɕʑçʝxɣχʁʜʍɰʟɨʉɯuʊøɘɵɤəɛœɜɞʌɔæɐɶɑɒɚɝɩɪʅʈʏʞ".toSortedSet()
/**
* lowercase AND the height is equal to x-height (e.g. lowercase B, D, F, H, K, L, ... does not count
@@ -302,10 +348,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
)
private val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
0..0xFF,
0xAC00..0xD7A3,
(0x1100..0x11FF) + (0xA960..0xA97F) + (0xD7B0..0xD7FF), // Hangul Jamo, because Hangul Syllables are disassembled prior to the render
0x100..0x17F,
0x180..0x24F,
0x3040..0x30FF,
(0x3040..0x30FF) + (0x31F0..0x31FF) + (0x1B000..0x1B001),
0x3000..0x303F,
0x3400..0x9FFF,
0x400..0x52F,
@@ -322,7 +368,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
0xF00000..0xF0005F, // assign them to PUA
0xF00060..0xF000BF, // assign them to PUA
0x13A0..0x13F5,
0xA770..0xA787,
0xA770..0xA787, // if it work, don't fix it (yet--wait until Latin Extended C)
0x900..0x9FF,
0x1C90..0x1CBF,
0x300..0x36F
@@ -510,6 +556,11 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
//textTexture.begin()
//textBuffer.forEach { print("${it.toHex()} ") }
//println()
val runs = if (noShadow) 0..0 else 3 downTo 0
for (run in runs) { // 0: Main, 1..3: Shadows
resetHash()
@@ -517,7 +568,9 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
while (index <= textBuffer.lastIndex) {
val c = textBuffer[index]
val sheetID = getSheetType(c)
val (sheetX, sheetY) = getSheetwisePosition(c)
val (sheetX, sheetY) =
if (index == 0) getSheetwisePosition(0, c)
else getSheetwisePosition(textBuffer[index - 1], c)
val hash = getHash(c)
if (run == 0) {
@@ -539,16 +592,27 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
charsetOverride = c - CHARSET_OVERRIDE_DEFAULT
}
else if (sheetID == SHEET_HANGUL) {
// FIXME input text is normalised as Initial-Peak-Final
// requires lookahead for {I, P, F}
val cNext = if (index + 1 <= textBuffer.size) textBuffer[index + 1] else 0
val cNextNext = if (index + 2 <= textBuffer.size) textBuffer[index + 2] else 0
val hangulLength = if (isHangulJongseong(cNextNext)) 3 else 2
val (indices, rows) = toHangulIndexAndRow(c, cNext, cNextNext)
val (indexCho, indexJung, indexJong) = indices
val (choRow, jungRow, jongRow) = rows
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)
println("${c.toHex()} ${cNext.toHex()} ${cNextNext.toHex()}")
println("I: $indexCho,\t$choRow")
println("P: $indexJung,\t$jungRow")
println("F: $indexJong,\t$jongRow")
println("skip: $hangulLength")
println("====")
when (run) {
@@ -579,6 +643,9 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
}
index += hangulLength - 1
}
else {
try {
@@ -742,7 +809,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
// fallback
}
private fun getSheetwisePosition(ch: Int): IntArray {
private fun getSheetwisePosition(cPrev: Int, ch: Int): IntArray {
val sheetX: Int; val sheetY: Int
when (getSheetType(ch)) {
SHEET_UNIHAN -> {
@@ -842,7 +909,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
return intArrayOf(sheetX, sheetY)
}
fun buildWidthTable(pixmap: Pixmap, codeRange: IntRange, cols: Int = 16) {
fun buildWidthTable(pixmap: Pixmap, codeRange: Iterable<Int>, cols: Int = 16) {
val binaryCodeOffset = W_VAR_INIT
val cellW = W_VAR_INIT + 1
@@ -850,8 +917,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
for (code in codeRange) {
val cellX = ((code - codeRange.start) % cols) * cellW
val cellY = ((code - codeRange.start) / cols) * cellH
val cellX = ((code - codeRange.first()) % cols) * cellW
val cellY = ((code - codeRange.first()) / cols) * cellH
val codeStartX = cellX + binaryCodeOffset
val codeStartY = cellY
@@ -917,10 +984,6 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
(0xFFFA0..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)
@@ -981,7 +1044,14 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
else -> 0 // implies "diacriticsBeforeGlyph = true"
}
if (!thisProp.writeOnTop) {
if (isHangul(thisChar) && !isHangulChosung(thisChar)) {
posXbuffer[charIndex] = if (isHangulChosung(lastNonDiacriticChar))
posXbuffer[nonDiacriticCounter]
else
posXbuffer[nonDiacriticCounter] + W_HANGUL
}
else if (!thisProp.writeOnTop) {
posXbuffer[charIndex] = when (itsProp.alignWhere) {
GlyphProps.ALIGN_RIGHT ->
posXbuffer[nonDiacriticCounter] + W_VAR_INIT + alignmentOffset + interchar
@@ -1065,8 +1135,12 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
/** UTF-16 to ArrayList of Int. UTF-16 is because of Java
/** Takes input string, do normalisation, and returns sequence of codepoints (Int)
*
* UTF-16 to ArrayList of Int. UTF-16 is because of Java
* Note: CharSequence IS a String. java.lang.String implements CharSequence.
*
* Note to Programmer: DO NOT USE CHAR LITERALS, CODE EDITORS WILL CHANGE IT TO SOMETHING ELSE !!
*/
private fun CharSequence.toCodePoints(): CodepointSequence {
val seq = ArrayList<Int>()
@@ -1075,12 +1149,15 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
while (i < this.length) {
val c = this[i]
// LET THE NORMALISATION BEGIN //
// check UTF-16 surrogates
if (i < this.lastIndex && c.isHighSurrogate()) {
val cNext = this[i + 1]
if (!cNext.isLowSurrogate()) {
// replace with Unicode replacement char
seq.add(0xFFFD)
seq.add(0x7F) // 0x7F in used internally to display <??> character
}
else {
val H = c
@@ -1091,6 +1168,23 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
i++ // skip next char (guaranteed to be Low Surrogate)
}
}
// disassemble Hangul Syllables into Initial-Peak-Final encoding
else if (c in 0xAC00.toChar()..0xD7A3.toChar()) {
val cInt = c.toInt() - 0xAC00
val indexCho = getWanseongHanChosung(cInt)
val indexJung = getWanseongHanJungseong(cInt)
val indexJong = getWanseongHanJongseong(cInt) - 1 // no Jongseong will be -1
// these magic numbers only makes sense if you look at the Unicode chart of Hangul Jamo
// https://www.unicode.org/charts/PDF/U1100.pdf
seq.add(0x1100 + indexCho)
seq.add(0x1161 + indexJung)
if (indexJong >= 0) seq.add(0x11A8 + indexJong)
}
// normalise CJK Compatibility area because fuck them
else if (c in 0x3300.toChar()..0x33FF.toChar()) {
seq.add(0x7F) // fuck them
}
// rearrange {letter, before-and-after diacritics} as {letter, before-diacritics, after-diacritics}
// {letter, before-diacritics} part will be dealt with swapping code below
// DOES NOT WORK if said diacritics has codepoint > 0xFFFF
@@ -1104,8 +1198,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
// U+007F is DEL originally, but this font stores bitmap of Replacement Character (U+FFFD)
// to this position. This line will replace U+FFFD into U+007F.
else if (c == '<27>') {
seq.add(0x7F)
else if (c == 0xFFFD.toChar()) {
seq.add(0x7F) // 0x7F in used internally to display <??> character
}
else {
seq.add(c.toInt())
@@ -1164,6 +1258,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
hashAccumulator = hashBasis
}
private fun Int.toHex() = "U+${this.toString(16).padStart(4, '0').toUpperCase()}"
companion object {
internal val JUNG_COUNT = 21
internal val JONG_COUNT = 28
@@ -1218,8 +1314,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
// custom codepoints
internal val RICH_TEXT_MODIFIER_RUBY_MASTER = 0xFFFA0
internal val RICH_TEXT_MODIFIER_RUBY_SLAVE = 0xFFFA0
internal val RICH_TEXT_MODIFIER_TAG_END = 0xFFFA0
internal val RICH_TEXT_MODIFIER_RUBY_SLAVE = 0xFFFA1
internal val RICH_TEXT_MODIFIER_SUPERSCRIPT = 0xFFFA2
internal val RICH_TEXT_MODIFIER_SUBSCRIPT = 0xFFFA3
internal val RICH_TEXT_MODIFIER_TAG_END = 0xFFFBF
internal val CHARSET_OVERRIDE_DEFAULT = 0xFFFC0
internal val CHARSET_OVERRIDE_BG_BG = 0xFFFC1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,2 +1 @@
Nijntje Pluis
Nijntje Pluis
ᄋힳᆫ ꥼᆢᇹ