mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
font update
This commit is contained in:
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/kana_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/kana_variable.tga
LFS
Normal file
Binary file not shown.
BIN
lib/TerrarumSansBitmap.jar
LFS
BIN
lib/TerrarumSansBitmap.jar
LFS
Binary file not shown.
@@ -24,8 +24,8 @@ class BTeXDocViewer(val doc: BTeXDocument) {
|
||||
else
|
||||
currentPage = page
|
||||
}
|
||||
fun gotoIndex(id: String) {
|
||||
gotoPage(doc.indexTable[id]!!)
|
||||
fun getPageOfIndex(id: String): Int {
|
||||
return doc.indexTable[id]!!
|
||||
}
|
||||
|
||||
fun currentPageStr(): String {
|
||||
|
||||
@@ -227,7 +227,7 @@ class BTeXDocument : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
fun serialise(archiveFile: File) {
|
||||
fun serialise(viewer: BTeXDocViewer,archiveFile: File) {
|
||||
if (!isFinalised) throw IllegalStateException("Document must be finalised before being serialised")
|
||||
|
||||
val diskFile = ClusteredFormatDOM.createNewArchive(archiveFile, Common.CHARSET, "", 0x7FFFF)
|
||||
@@ -252,6 +252,26 @@ class BTeXDocument : Disposable {
|
||||
it.writeBytes(json.encodeToByteArray())
|
||||
}
|
||||
|
||||
val json2 = StringBuilder(); json2.append("{\n")
|
||||
pages.forEachIndexed { index, page ->
|
||||
if (page.clickableElements.isNotEmpty()) {
|
||||
json2.append("\"$index\":[")
|
||||
page.clickableElements.forEach {
|
||||
val objStr = "{\"x\":${it.posX},\"y\":${it.posY},\"w\":${it.width},\"h\":${it.height},\"a\":${it.getTargetPage(viewer)}},"
|
||||
json2.append(objStr)
|
||||
}
|
||||
json2.deleteCharAt(json2.length - 1)
|
||||
json2.append("],\n")
|
||||
}
|
||||
}
|
||||
if (json2.length > 5) json2.deleteCharAt(json2.length - 2) // delete , but not \n
|
||||
json2.append("}")
|
||||
|
||||
Clustfile(DOM, "hrefs.json").also {
|
||||
it.createNewFile()
|
||||
it.writeBytes(json2.toString().encodeToByteArray())
|
||||
}
|
||||
|
||||
pagePixmaps.forEachIndexed { index, pixmap ->
|
||||
Clustfile(DOM, "$index.png").also { file ->
|
||||
file.createNewFile()
|
||||
@@ -346,7 +366,7 @@ class BTeXDocument : Disposable {
|
||||
|
||||
data class BTeXClickable(
|
||||
var posX: Int, var posY: Int, val width: Int, val height: Int, val drawUnderline: Boolean = true,
|
||||
val onClick: (BTeXDocViewer) -> Unit,
|
||||
val getTargetPage: (BTeXDocViewer) -> Int,
|
||||
// val onHover: () -> Unit = {}
|
||||
) {
|
||||
var deltaX = 0
|
||||
@@ -424,7 +444,10 @@ class BTeXPage(
|
||||
// filter clickable elements that are under the cursor
|
||||
clickableElements.filter {
|
||||
it.pointInHitbox(doc, pageRelX, pageRelY)
|
||||
}.lastOrNull()?.let { it.onClick(viewer) }
|
||||
}.lastOrNull()?.let {
|
||||
val target = it.getTargetPage(viewer)
|
||||
viewer.gotoPage(target)
|
||||
}
|
||||
}
|
||||
|
||||
fun isEmpty() = drawCalls.isEmpty()
|
||||
|
||||
@@ -375,6 +375,7 @@ object BTeXParser {
|
||||
|
||||
if (str.isNotEmpty()) {
|
||||
|
||||
// printdbg(str)
|
||||
|
||||
// rising/falling edge of the hrefId
|
||||
if (currentHrefId != oldHrefTarget) {
|
||||
@@ -1676,7 +1677,7 @@ object BTeXParser {
|
||||
var hrefY = hrefObj.y; if (objectIsSplit) hrefY += doc.lineHeightInPx
|
||||
|
||||
val clickable = BTeXClickable(hrefX, hrefY, getFont().getWidth(substr), doc.lineHeightInPx, false) { viewer ->
|
||||
viewer.gotoIndex(hrefObj.hrefTarget)
|
||||
viewer.getPageOfIndex(hrefObj.hrefTarget)
|
||||
}
|
||||
doc.appendClickable(doc.pages[pageNum], clickable); clickables.add(clickable)
|
||||
|
||||
@@ -1751,7 +1752,7 @@ object BTeXParser {
|
||||
var hrefY = hrefObj.y; if (objectIsSplit) hrefY += doc.lineHeightInPx
|
||||
|
||||
val clickable = BTeXClickable(hrefX, hrefY, getFont().getWidth(substr), doc.lineHeightInPx) { viewer ->
|
||||
viewer.gotoIndex(hrefObj.hrefTarget)
|
||||
viewer.getPageOfIndex(hrefObj.hrefTarget)
|
||||
}
|
||||
doc.appendClickable(doc.pages[pageNum], clickable); clickables.add(clickable)
|
||||
|
||||
@@ -1939,8 +1940,7 @@ object BTeXParser {
|
||||
val thePage = call.pageObject
|
||||
|
||||
thePage.appendClickable(BTeXClickable(boxx, boxy, boxw, boxh, false) {
|
||||
// printdbg("Goto page p. ${target+1}")
|
||||
it.gotoPage(target)
|
||||
target
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ import kotlin.system.measureTimeMillis
|
||||
class BTeXTest : ApplicationAdapter() {
|
||||
|
||||
// val filePath = "btex.xml"
|
||||
val filePath = "btex_ko.xml"
|
||||
// val filePath = "btex_ko.xml"
|
||||
// val filePath = "test.xml"
|
||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||
// val filePath = "literature/koKR/yisang_nalgae.xml"
|
||||
// val filePath = "literature/koKR/yisang_geonchukmuhanyukmyeongakche.xml"
|
||||
val filePath = "literature/koKR/yisang_geonchukmuhanyukmyeongakche.xml"
|
||||
|
||||
|
||||
private lateinit var document: BTeXDocument
|
||||
|
||||
Reference in New Issue
Block a user