mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-07 20:01:52 +09:00
fix: nbsp not typesetted correctly
This commit is contained in:
BIN
assets/ascii_variable.tga
LFS
BIN
assets/ascii_variable.tga
LFS
Binary file not shown.
@@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.terrarumsansbitmap.gdx.CodePoint
|
||||
import net.torvald.terrarumsansbitmap.gdx.CodepointSequence
|
||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap.Companion.FIXED_BLOCK_1
|
||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap.Companion.getHash
|
||||
import kotlin.math.*
|
||||
import kotlin.properties.Delegates
|
||||
@@ -67,7 +68,7 @@ class MovableType(
|
||||
// println("Paper width: $paperWidth")
|
||||
|
||||
val lines = inputText.tokenise()
|
||||
// lines.debugprint()
|
||||
lines.debugprint()
|
||||
|
||||
lines.forEachIndexed { linenum, it ->
|
||||
// println("Processing input text line ${linenum + 1} (word count: ${it.size})...")
|
||||
@@ -913,6 +914,8 @@ class MovableType(
|
||||
"{SHY}"
|
||||
else if (it == ZWSP)
|
||||
"{ZWSP}"
|
||||
else if (it in FIXED_BLOCK_1..FIXED_BLOCK_1+15)
|
||||
" <block ${it - FIXED_BLOCK_1 + 1}>"
|
||||
else if (it in GLUE_NEGATIVE_ONE..GLUE_POSITIVE_SIXTEEN)
|
||||
" <glue ${it.glueCharToGlueSize()}> "
|
||||
else if (it in 0xF0541..0xF055A) {
|
||||
|
||||
@@ -192,6 +192,7 @@ class TerrarumSansBitmap(
|
||||
|
||||
/** Props of all printable Unicode points. */
|
||||
private val glyphProps = HashMap<CodePoint, GlyphProps>()
|
||||
private val textReplaces = HashMap<CodePoint, CodePoint>()
|
||||
private val sheets: Array<PixmapRegionPack>
|
||||
|
||||
// private var charsetOverride = 0
|
||||
@@ -267,6 +268,8 @@ class TerrarumSansBitmap(
|
||||
buildWidthTableFixed()
|
||||
buildWidthTableInternal()
|
||||
|
||||
setupDynamicTextReplacer()
|
||||
|
||||
glyphProps[0xAD] = GlyphProps(-15) // what the fuck's going on that made this necessary??
|
||||
|
||||
|
||||
@@ -772,6 +775,13 @@ class TerrarumSansBitmap(
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupDynamicTextReplacer() {
|
||||
// replace NBSP into a block of same width
|
||||
val spaceWidth = glyphProps[32]?.width ?: throw IllegalStateException()
|
||||
if (spaceWidth > 16) throw InternalError("Space (U+0020) character is too wide ($spaceWidth)")
|
||||
textReplaces[0xA0] = FIXED_BLOCK_1 + (spaceWidth - 1)
|
||||
}
|
||||
|
||||
fun getWidth(text: String) = getWidthNormalised(text.toCodePoints())
|
||||
fun getWidth(s: CodepointSequence) = getWidthNormalised(s.normalise())
|
||||
|
||||
@@ -1055,9 +1065,14 @@ class TerrarumSansBitmap(
|
||||
|
||||
seq0.add(0)
|
||||
while (i < dis.size) {
|
||||
val c = dis[i]
|
||||
var c = dis[i]
|
||||
val cNext = dis.getOrElse(i+1) { -1 }
|
||||
|
||||
// replace characters in-line
|
||||
textReplaces[c]?.let {
|
||||
c = it
|
||||
}
|
||||
|
||||
// turn Unicode Devanagari consonants into the internal counterpart
|
||||
if (c in 0x0915..0x0939 || c in 0x0958..0x095F)
|
||||
if (cNext == DEVANAGARI_NUQTA) {
|
||||
|
||||
BIN
work_files/ascii_variable.psd
LFS
BIN
work_files/ascii_variable.psd
LFS
Binary file not shown.
Reference in New Issue
Block a user