diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8d80387..cc81e4b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -8,10 +8,16 @@
+
+
+
+
+
+
@@ -32,26 +38,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -59,17 +47,22 @@
-
-
+
+
+
+
+
+
+
-
-
+
+
@@ -81,8 +74,8 @@
-
-
+
+
@@ -90,25 +83,34 @@
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -116,9 +118,9 @@
-
-
-
+
+
+
@@ -140,7 +142,7 @@
- not copy
+ getColour.094ө
@@ -149,15 +151,15 @@
getSheetTUnexpectedUnexp
- fun getSh
+ codeRangeisHangulᏵtoColo
- fun relo
+ 3633println(
- Width ta
+ getWidthglyphWidthBufferGlyphProps.LE
@@ -189,13 +191,13 @@
+
+
+
+
+
-
-
-
-
-
@@ -210,7 +212,6 @@
-
@@ -245,6 +246,7 @@
+
@@ -480,29 +482,29 @@
-
-
+
+
-
-
+
-
+
+
@@ -511,7 +513,7 @@
-
+
@@ -811,18 +813,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -844,33 +834,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -890,35 +857,66 @@
-
-
+
+
-
-
-
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6f43e9f..3c48884 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -15,7 +15,7 @@ Red-tinted area SHOULD NOT CONTAIN any dots, it's emptied for compatibility. (Sl
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)
+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.
@@ -24,7 +24,7 @@ Each cell is 16 px wide, and any glyph you draw **must be contained within lefts
-### Font metrics
+### 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.
@@ -34,6 +34,27 @@ Although the font is basically a Spritesheet, some of the sheet expects variable
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 -+ 0 left 0 right 1 Centre
+ 0 == Write on top of prev chars (e.g. diacritics)
+ 1 == Diacritics stack 0:upward/1:downward
+(MSB) 0 == Diacritics comes befor the glyph
+
+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.
+```
+
### 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.
diff --git a/FontTestGDX/demotext.txt b/FontTestGDX/demotext.txt
index 9da4a90..73e3f92 100644
--- a/FontTestGDX/demotext.txt
+++ b/FontTestGDX/demotext.txt
@@ -22,40 +22,41 @@ 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
- Ꝺꝼ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
- 日堀油告観観藤村抄海評業庁経賃室弁市。太撮収改売週法所何都慣次現。価紙一無三洋日話転手治稿載末替付致治。
+ Ианҵоуп ақьаад, нусхур аҩырала, ҩ ҽшьаҟакла, иҧшӡоу анапҩырала
+ Գրիչս վայր դրի, վեր կացա և պատրաստվում էի, որ քնեմ, երբ հանկարծ դռանս զանգակը հնչեց
+ 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
+ Ꝺꝼ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:
diff --git a/FontTestGDX/lib/TerrarumSansBitmap.jar b/FontTestGDX/lib/TerrarumSansBitmap.jar
index 113684b..2709fd2 100644
Binary files a/FontTestGDX/lib/TerrarumSansBitmap.jar and b/FontTestGDX/lib/TerrarumSansBitmap.jar differ
diff --git a/FontTestGDX/src/FontTestGDX.kt b/FontTestGDX/src/FontTestGDX.kt
index 3cd9eda..77be297 100644
--- a/FontTestGDX/src/FontTestGDX.kt
+++ b/FontTestGDX/src/FontTestGDX.kt
@@ -134,9 +134,7 @@ 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)
diff --git a/README.md b/README.md
index 2e263e9..4b0d395 100644
--- a/README.md
+++ b/README.md
@@ -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
-- To display Bulgarian/Serbian variants, you need special Control Characters. (GameFontBase.charsetOverrideBulgarian; GameFontBase.charsetOverrideSerbian)
+- 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
diff --git a/assets/ascii_variable.tga b/assets/ascii_variable.tga
index 2c2cd6f..67967d2 100644
Binary files a/assets/ascii_variable.tga and b/assets/ascii_variable.tga differ
diff --git a/assets/devanagari_bengali_variable.tga b/assets/devanagari_bengali_variable.tga
index 56ea66d..bf32353 100644
Binary files a/assets/devanagari_bengali_variable.tga and b/assets/devanagari_bengali_variable.tga differ
diff --git a/demo.PNG b/demo.PNG
index d7a7e08..07f29c7 100644
Binary files a/demo.PNG and b/demo.PNG differ
diff --git a/font_drawing_template.png b/font_drawing_template.png
index abf1921..d763760 100644
Binary files a/font_drawing_template.png and b/font_drawing_template.png differ
diff --git a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt
index f8bef20..98bb607 100644
--- a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt
+++ b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt
@@ -9,7 +9,8 @@ data class GlyphProps(
val alignWhere: Int,
val alignXPos: Int,
val rtl: Boolean = false,
- val diacriticsStackDown: Boolean = false
+ val diacriticsStackDown: Boolean = false,
+ val diacriticsBeforeGlyph: Boolean = false
) {
companion object {
const val LEFT = 0
@@ -23,6 +24,7 @@ data class GlyphProps(
tags.ushr(5).and(3),
tags.ushr(1).and(15),
tags.and(1) == 1,
- tags.ushr(8).and(1) == 1
+ tags.ushr(8).and(1) == 1,
+ tags.ushr(9).and(1) == 1
)
}
\ No newline at end of file
diff --git a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
index 277a630..7bbfb73 100644
--- a/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
+++ b/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt
@@ -455,25 +455,29 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
Character.toChars(thisChar).forEach { errorGlyphSB.append(it) }
throw InternalError("No GlyphProps for char '$errorGlyphSB' " +
- "(U+${thisChar.toString(16).toUpperCase()}: ${Character.getName(thisChar)})")
+ "(${thisChar.charInfo()})")
}
val thisProp = glyphProps[thisChar] ?: nullProp
val lastNonDiacriticChar = textBuffer[nonDiacriticCounter]
val itsProp = glyphProps[lastNonDiacriticChar] ?: nullProp
- //println("char: $thisChar; properties: $thisProp")
+ //println("char: ${thisChar.charInfo()}\nproperties: $thisProp")
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 -> throw InternalError("Unsupported alignment: ${thisProp.alignWhere}")
+ else -> throw InternalError("Unsupported alignment: ${thisProp.alignWhere} for '$thisChar' (${thisChar.charInfo()})")
}
if (!thisProp.writeOnTop) {
- posXbuffer[charIndex] = posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset + interchar
+ 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
@@ -506,13 +510,12 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
}
}
+
+
+ //print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
+ //posXbuffer.forEach { print("$it ") }; println()
}
-
- //print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
- //posXbuffer.forEach { print("$it ") }; println()
-
-
originalColour = batch.color.cpy()
var mainCol = originalColour
var shadowCol = mainCol.cpy().mul(0.5f,0.5f,0.5f,1f)
@@ -612,6 +615,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
return null
}
+ private fun Int.charInfo() = "U+${this.toString(16).padStart(4, '0').toUpperCase()}: ${Character.getName(this)}"
+
override fun dispose() {
super.dispose()
@@ -815,7 +820,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
val codeStartX = cellX + binaryCodeOffset
val codeStartY = cellY
- val tagStartY = codeStartY + 11
+ val tagStartY = codeStartY + 10
var width = 0
var tags = 0
@@ -827,7 +832,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
}
- for (y in 0..8) {
+ 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)
@@ -874,7 +879,9 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
}
- /** UTF-16 to ArrayList of Int. UTF-16 is because of Java */
+ /** 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()
@@ -902,40 +909,24 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
i++
}
- return seq
- }
- /** As CharSequence is just an Interface, copy-pasting the code would be the fastest way */
- private fun String.toCodePoints(): CodepointSequence {
- val seq = ArrayList()
-
- var i = 0
- while (i < this.length) {
- val c = this[i]
-
- if (i < this.lastIndex) {
- if (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())
+ // 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) */