support for polytonic greek

This commit is contained in:
minjaesong
2018-09-10 01:26:58 +09:00
parent c3cf795e9a
commit b3bfe6035f
6 changed files with 34 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

BIN
demo.PNG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 138 KiB

View File

@@ -106,8 +106,8 @@ How multilingual? Real multilingual!
􏃯Unicode References:􀀀
Basic Latin Latin-1 Latin Extension A Latin Extionsion B IPA Extension Greek Cyrillic
Cyrillic Supplement Armenian Devanagari Bengali Thai Georgian Hangul Jamo Runic Cherokee
Georgian Extended General Punctuations Superscripts and Subscripts CJK Symbols Kana
Cyrillic Supplement Armenian Devanagari Bengali Thai Georgian Hangul Jamo Cherokee Runic
Georgian Extended Greek Extended General Punctuations Superscripts and Subscripts CJK Symbols Kana
Kana Phonetic Extension CJK Unihan Extension A CJK Unihan Hangul Jamo Extended-A Hangul Syllables
Hangul Jamo Extended-B Fullwidth Forms Kana Supplement

View File

@@ -193,6 +193,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
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 isDiacriticalMarks(c: Int) = c in codeRange[SHEET_DIACRITICAL_MARKS_VARW]
private fun isPolytonicGreek(c: Int) = c in codeRange[SHEET_GREEK_POLY_VARW]
private fun isCaps(c: Int) = Character.isUpperCase(c) || isKartvelianCaps(c)
@@ -265,6 +266,9 @@ 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 fun polytonicGreekIndexX(c: Int) = (c - 0x1F00) % 16
private fun polytonicGreekIndexY(c: Int) = (c - 0x1F00) / 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
@@ -312,7 +316,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
SHEET_INSUAR_VARW,
SHEET_NAGARI_BENGALI_VARW,
SHEET_KARTULI_CAPS_VARW,
SHEET_DIACRITICAL_MARKS_VARW
SHEET_DIACRITICAL_MARKS_VARW,
SHEET_GREEK_POLY_VARW
)
private val autoShiftDownOnLowercase = arrayOf(
SHEET_DIACRITICAL_MARKS_VARW
@@ -344,7 +349,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
"insular_variable.tga",
"devanagari_bengali_variable.tga",
"kartuli_allcaps_variable.tga",
"diacritical_marks_variable.tga"
"diacritical_marks_variable.tga",
"greek_polytonic_xyswap_variable.tga"
)
private val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
0..0xFF,
@@ -371,7 +377,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
0xA770..0xA787, // if it work, don't fix it (yet--wait until Latin Extended C)
0x900..0x9FF,
0x1C90..0x1CBF,
0x300..0x36F
0x300..0x36F,
0x1F00..0x1FFF
)
private val glyphProps: HashMap<Int, GlyphProps> = HashMap()
private val sheets: Array<TextureRegionPack>
@@ -399,11 +406,21 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
if (isVariable) {
if (isXYSwapped) {
println("[TerrarumSansBitmap] loading texture $it [VARIABLE, XYSWAP]")
}
else {
println("[TerrarumSansBitmap] loading texture $it [VARIABLE]")
}
}
else {
if (isXYSwapped) {
println("[TerrarumSansBitmap] loading texture $it [XYSWAP]")
}
else {
println("[TerrarumSansBitmap] loading texture $it")
}
}
// unpack gz if applicable
@@ -803,6 +820,8 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
return SHEET_KARTULI_CAPS_VARW
else if (isDiacriticalMarks(c))
return SHEET_DIACRITICAL_MARKS_VARW
else if (isPolytonicGreek(c))
return SHEET_GREEK_POLY_VARW
else
return SHEET_UNKNOWN
// fixed width
@@ -900,6 +919,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
sheetX = diacriticalMarksIndexX(ch)
sheetY = diacriticalMarksIndexY(ch)
}
SHEET_GREEK_POLY_VARW -> {
sheetX = polytonicGreekIndexX(ch)
sheetY = polytonicGreekIndexY(ch)
}
else -> {
sheetX = ch % 16
sheetY = ch / 16
@@ -1308,6 +1331,7 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
internal val SHEET_NAGARI_BENGALI_VARW=22
internal val SHEET_KARTULI_CAPS_VARW = 23
internal val SHEET_DIACRITICAL_MARKS_VARW = 24
internal val SHEET_GREEK_POLY_VARW = 25
internal val SHEET_UNKNOWN = 254

View File

@@ -77,11 +77,11 @@ class TextureRegionPack(
else {
regions = Array<TextureRegion>(horizontalCount * verticalCount, {
val region = TextureRegion()
val rx = (it % verticalCount * (tileW + hGap)) + hFrame
val ry = (it / verticalCount * (tileH + vGap)) + vFrame
val rx = (it / verticalCount * (tileW + hGap)) + hFrame
val ry = (it % verticalCount * (tileH + vGap)) + vFrame
region.setRegion(texture)
region.setRegion(ry, rx, tileW, tileH)
region.setRegion(rx, ry, tileW, tileH)
region.flip(false, globalFlipY)