mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-06-13 17:24:03 +09:00
very crude kerning impl for Ys and Ts and AV-VA pairs
This commit is contained in:
Binary file not shown.
@@ -22,7 +22,7 @@ class FontTestGDX : Game() {
|
|||||||
|
|
||||||
lateinit var camera: OrthographicCamera
|
lateinit var camera: OrthographicCamera
|
||||||
|
|
||||||
private val testing = true
|
private val testing = false
|
||||||
|
|
||||||
private val demotextName = if (testing) "testtext.txt" else "demotext.txt"
|
private val demotextName = if (testing) "testtext.txt" else "demotext.txt"
|
||||||
private val outimageName = if (testing) "testing.PNG" else "demo.PNG"
|
private val outimageName = if (testing) "testing.PNG" else "demo.PNG"
|
||||||
|
|||||||
BIN
demo.PNG
BIN
demo.PNG
Binary file not shown.
|
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 146 KiB |
@@ -1207,13 +1207,37 @@ for c in s:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getKerning(prevChar: CodePoint, thisChar: CodePoint): Int {
|
||||||
|
return if (prevChar in lowHeightLetters) {
|
||||||
|
return if (thisChar in kernTees) kernTee // lh - T
|
||||||
|
else if (thisChar in kernYees) kernYee // lh - Y
|
||||||
|
else 0
|
||||||
|
}
|
||||||
|
else if (prevChar in kernTees) {
|
||||||
|
return if (thisChar in lowHeightLetters) kernTee // T - lh
|
||||||
|
else 0
|
||||||
|
}
|
||||||
|
else if (prevChar in kernYees) {
|
||||||
|
return if (thisChar in lowHeightLetters) kernYee // Y - lh
|
||||||
|
else 0
|
||||||
|
}
|
||||||
|
else if (prevChar in kernAyes) {
|
||||||
|
return if (thisChar in kernVees) kernAV // A - V
|
||||||
|
else 0
|
||||||
|
}
|
||||||
|
else if (prevChar in kernVees) {
|
||||||
|
return if (thisChar in kernAyes) kernAV // V - A
|
||||||
|
else 0
|
||||||
|
}
|
||||||
|
else 0
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* posXbuffer's size is greater than the string, last element marks the width of entire string.
|
* posXbuffer's size is greater than the string, last element marks the width of entire string.
|
||||||
*/
|
*/
|
||||||
private fun buildWidthAndPosBuffers(str: CodepointSequence): Pair<IntArray, IntArray> {
|
private fun buildWidthAndPosBuffers(str: CodepointSequence): Pair<IntArray, IntArray> {
|
||||||
val posXbuffer = IntArray(str.size + 1, { 0 })
|
val posXbuffer = IntArray(str.size + 1) { 0 }
|
||||||
val posYbuffer = IntArray(str.size, { 0 })
|
val posYbuffer = IntArray(str.size) { 0 }
|
||||||
|
|
||||||
|
|
||||||
var nonDiacriticCounter = 0 // index of last instance of non-diacritic char
|
var nonDiacriticCounter = 0 // index of last instance of non-diacritic char
|
||||||
@@ -1237,6 +1261,7 @@ for c in s:
|
|||||||
val thisProp = glyphProps[thisChar] ?: nullProp
|
val thisProp = glyphProps[thisChar] ?: nullProp
|
||||||
val lastNonDiacriticChar = str[nonDiacriticCounter]
|
val lastNonDiacriticChar = str[nonDiacriticCounter]
|
||||||
val itsProp = glyphProps[lastNonDiacriticChar] ?: nullProp
|
val itsProp = glyphProps[lastNonDiacriticChar] ?: nullProp
|
||||||
|
val kerning = getKerning(lastNonDiacriticChar, thisChar)
|
||||||
|
|
||||||
|
|
||||||
//println("char: ${thisChar.charInfo()}\nproperties: $thisProp")
|
//println("char: ${thisChar.charInfo()}\nproperties: $thisProp")
|
||||||
@@ -1259,11 +1284,11 @@ for c in s:
|
|||||||
else if (!thisProp.writeOnTop) {
|
else if (!thisProp.writeOnTop) {
|
||||||
posXbuffer[charIndex] = when (itsProp.alignWhere) {
|
posXbuffer[charIndex] = when (itsProp.alignWhere) {
|
||||||
GlyphProps.ALIGN_RIGHT ->
|
GlyphProps.ALIGN_RIGHT ->
|
||||||
posXbuffer[nonDiacriticCounter] + W_VAR_INIT + alignmentOffset + interchar
|
posXbuffer[nonDiacriticCounter] + W_VAR_INIT + alignmentOffset + interchar + kerning
|
||||||
GlyphProps.ALIGN_CENTRE ->
|
GlyphProps.ALIGN_CENTRE ->
|
||||||
posXbuffer[nonDiacriticCounter] + HALF_VAR_INIT + itsProp.width + alignmentOffset + interchar
|
posXbuffer[nonDiacriticCounter] + HALF_VAR_INIT + itsProp.width + alignmentOffset + interchar + kerning
|
||||||
else ->
|
else ->
|
||||||
posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset + interchar
|
posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset + interchar + kerning
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
testing.PNG
BIN
testing.PNG
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
10
testtext.txt
10
testtext.txt
@@ -1,4 +1,8 @@
|
|||||||
Rotund R
|
|
||||||
|
|
||||||
CURIOUSTOꝚVALD
|
iousTorvald
|
||||||
Curioustoꝛvald
|
iousYorvald
|
||||||
|
iousVorvald
|
||||||
|
iousBorvald
|
||||||
|
|
||||||
|
AVA Online
|
||||||
|
EVE Online
|
||||||
Reference in New Issue
Block a user