fixed up Thai and Devanagari Anusvara

not perfect but it'll work
This commit is contained in:
minjaesong
2018-08-10 04:20:03 +09:00
parent a0e2cbf756
commit 6300b29ab5
10 changed files with 92 additions and 74 deletions

123
.idea/workspace.xml generated
View File

@@ -11,12 +11,9 @@
<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$/FontTestGDX/src/FontTestGDX.kt" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/ascii_variable.tga" beforeDir="false" afterPath="$PROJECT_DIR$/assets/ascii_variable.tga" 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$/font_drawing_template.png" beforeDir="false" afterPath="$PROJECT_DIR$/font_drawing_template.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>
@@ -35,11 +32,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="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="456">
<caret line="834" column="26" selection-start-line="834" selection-start-column="26" selection-end-line="834" selection-end-column="26" />
<caret line="836" column="26" selection-start-line="836" selection-start-column="26" selection-end-line="836" selection-end-column="26" />
</state>
</provider>
</entry>
@@ -47,13 +44,13 @@
<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="273">
<caret line="21" column="18" lean-forward="true" selection-start-line="21" selection-start-column="18" selection-end-line="21" selection-end-column="18" />
<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="false">
<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>
@@ -74,8 +71,8 @@
<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="820">
<caret line="149" column="24" selection-start-line="149" selection-start-column="24" selection-end-line="149" selection-end-column="24" />
<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>
@@ -83,11 +80,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="demotext.txt" pinned="false" current-in-tab="false">
<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 relative-caret-position="429">
<caret line="33" column="34" selection-start-line="33" selection-start-column="34" selection-end-line="33" selection-end-column="34" />
<state>
<caret column="121" selection-start-column="121" selection-end-column="121" />
</state>
</provider>
</entry>
@@ -95,18 +92,18 @@
<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="443">
<caret line="930" column="21" selection-start-line="930" selection-start-column="21" selection-end-line="930" selection-end-column="21" />
<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="true">
<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="SPLIT">
<first_editor relative-caret-position="454">
<caret line="34" column="313" selection-start-line="34" selection-start-column="313" selection-end-line="34" selection-end-column="313" />
<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 />
@@ -142,7 +139,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find />
<find>getColour</find>
<find>.094</find>
<find>ө</find>
@@ -151,15 +147,15 @@
<find>getSheetT</find>
<find>Unexpected</find>
<find>Unexp</find>
<find />
<find>fun getSh</find>
<find>codeRange</find>
<find>isHangul</find>
<find></find>
<find>toColo</find>
<find />
<find>fun relo</find>
<find>3633</find>
<find>println(</find>
<find />
<find>Width ta</find>
<find>getWidth</find>
<find>glyphWidthBuffer</find>
<find>GlyphProps.LE</find>
@@ -172,6 +168,7 @@
<find>ArrayList&lt;Int&gt;</find>
<find>appConfig.height</find>
<find>textBuffer</find>
<find>no stan</find>
</findStrings>
<replaceStrings>
<replace>.141</replace>
@@ -193,11 +190,11 @@
<option value="$PROJECT_DIR$/LICENSE.md" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/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" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/CONTRIBUTING.md" />
</list>
</option>
</component>
@@ -485,7 +482,7 @@
<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 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.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" />
@@ -862,37 +859,6 @@
</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="273">
<caret line="21" column="18" lean-forward="true" selection-start-line="21" selection-start-column="18" selection-end-line="21" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="820">
<caret line="149" column="24" selection-start-line="149" selection-start-column="24" selection-end-line="149" selection-end-column="24" />
<folding>
<element signature="e#0#384#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/FontTestGDX/demotext.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="429">
<caret line="33" column="34" selection-start-line="33" selection-start-column="34" selection-end-line="33" selection-end-column="34" />
</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="443">
<caret line="930" column="21" selection-start-line="930" selection-start-column="21" selection-end-line="930" selection-end-column="21" />
</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">
@@ -905,14 +871,18 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/demo.PNG">
<provider selected="true" editor-type-id="images" />
<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="SPLIT">
<first_editor relative-caret-position="454">
<caret line="34" column="313" selection-start-line="34" selection-start-column="313" selection-end-line="34" selection-end-column="313" />
<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 />
@@ -920,6 +890,33 @@
</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="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>
</component>
<component name="masterDetails">
<states>

View File

@@ -44,17 +44,24 @@ Green-tinted area (should be 10 px tall) contains the tags. Tags are defined as
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 -+ 0 left 0 right 1 Centre
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) 0 == Diacritics comes befor the glyph
(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.
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.

View File

@@ -90,9 +90,9 @@ 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 Kana Phonetic Extension CJK Unihan Extension A CJK Unihan Hangul Syllables Fullwidth Forms
Kana Supplement
Cyrillic Supplement Armenian Devanagari Thai Georgian Runic Cherokee 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

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.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
demo.PNG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

@@ -25,6 +25,6 @@ data class GlyphProps(
tags.ushr(1).and(15),
tags.and(1) == 1,
tags.ushr(8).and(1) == 1,
tags.ushr(9).and(1) == 1
tags.ushr(5).and(3) == 3
)
}

View File

@@ -469,7 +469,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
GlyphProps.LEFT -> 0
GlyphProps.RIGHT -> thisProp.width - W_VAR_INIT
GlyphProps.CENTRE -> Math.floor((thisProp.width - W_VAR_INIT) / 2.0).toInt()
else -> throw InternalError("Unsupported alignment: ${thisProp.alignWhere} for '$thisChar' (${thisChar.charInfo()})")
else -> 0 // implies "diacriticsBeforeGlyph = true"
}
if (!thisProp.writeOnTop) {
@@ -521,11 +521,13 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
var shadowCol = mainCol.cpy().mul(0.5f,0.5f,0.5f,1f)
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)
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetX}x${sheetY}")
@@ -948,6 +950,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