mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-06-08 23:14:05 +09:00
typesetter: extra draw call by line number
This commit is contained in:
@@ -243,17 +243,31 @@ class MovableType(
|
||||
} }
|
||||
|
||||
|
||||
fun draw(batch: Batch, x: Int, y: Int, lineStart: Int = 0, linesToDraw: Int = -1, lineHeight: Int = 24) =
|
||||
draw(batch, x.toFloat(), y.toFloat(), lineStart, linesToDraw, lineHeight)
|
||||
fun draw(batch: Batch, x: Int, y: Int, lineStart: Int = 0, linesToDraw: Int = -1, lineHeight: Int = TerrarumSansBitmap.LINE_HEIGHT, drawJobs: Map<Int, (Float, Float, Int) -> Unit> = HashMap()) =
|
||||
draw(batch, x.toFloat(), y.toFloat(), lineStart, linesToDraw, lineHeight, drawJobs)
|
||||
|
||||
fun draw(batch: Batch, x: Float, y: Float, lineStart: Int = 0, linesToDraw: Int = 2147483647, lineHeight: Int = 24) {
|
||||
fun draw(batch: Batch, x: Int, y: Int, drawJobs: Map<Int, (Float, Float, Int) -> Unit> = HashMap()) =
|
||||
draw(batch, x.toFloat(), y.toFloat(), 0, 2147483647, TerrarumSansBitmap.LINE_HEIGHT, drawJobs)
|
||||
|
||||
fun draw(batch: Batch, x: Float, y: Float, drawJobs: Map<Int, (Float, Float, Int) -> Unit> = HashMap()) =
|
||||
draw(batch, x, y, 0, 2147483647, TerrarumSansBitmap.LINE_HEIGHT, drawJobs)
|
||||
|
||||
/**
|
||||
* @param drawJobs Draw call for specific lines (absolute line). This takes the form of Map from linnumber to draw function,
|
||||
* which has three arguments: (line's top-left position-x, line's top-left position-y, absolute line number)
|
||||
*/
|
||||
fun draw(batch: Batch, x: Float, y: Float, lineStart: Int = 0, linesToDraw: Int = 2147483647, lineHeight: Int = TerrarumSansBitmap.LINE_HEIGHT, drawJobs: Map<Int, (Float, Float, Int) -> Unit> = HashMap()) {
|
||||
if (isNull) return
|
||||
|
||||
typesettedSlugs.subList(lineStart, minOf(typesettedSlugs.size, lineStart + linesToDraw)).forEachIndexed { lineNum, lineBlocks ->
|
||||
// println("Line [${lineNum+1}] anchors: "+ lineBlocks.map { it.posX }.joinToString())
|
||||
|
||||
val absoluteLineNum = lineStart + lineNum
|
||||
|
||||
drawJobs[absoluteLineNum]?.invoke(x, y + lineNum * lineHeight, absoluteLineNum)
|
||||
|
||||
lineBlocks.forEach {
|
||||
batch.draw(it.block.glyphLayout!!.linotype, x + it.posX - 16, y + lineNum * lineHeight)
|
||||
batch.draw(it.block.glyphLayout!!.linotype, x + it.posX - 16, y + lineNum * lineHeight - 8)
|
||||
}
|
||||
|
||||
// font.draw(batch, "I", x, y + lineNum * lineHeight + 14)
|
||||
|
||||
@@ -305,7 +305,7 @@ class TerrarumSansBitmap(
|
||||
glyphProps[0] = GlyphProps(0)
|
||||
}
|
||||
|
||||
override fun getLineHeight(): Float = 24f * scale
|
||||
override fun getLineHeight(): Float = LINE_HEIGHT.toFloat() * scale
|
||||
override fun getXHeight() = 8f * scale
|
||||
override fun getCapHeight() = 12f * scale
|
||||
override fun getAscent() = 3f * scale
|
||||
@@ -2040,6 +2040,8 @@ class TerrarumSansBitmap(
|
||||
|
||||
companion object {
|
||||
|
||||
const val LINE_HEIGHT = 24
|
||||
|
||||
fun CodepointSequence.getHash(): Long {
|
||||
val hashBasis = -3750763034362895579L
|
||||
val hashPrime = 1099511628211L
|
||||
|
||||
Reference in New Issue
Block a user