mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-06-16 02:24:04 +09:00
new tagging system
This commit is contained in:
@@ -1,22 +1,35 @@
|
||||
package net.torvald.terrarumsansbitmap
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-11-25.
|
||||
*/
|
||||
data class DiacriticsAnchor(val type: Int, val x: Int, val y: Int, val xUsed: Boolean, val yUsed: Boolean)
|
||||
/**
|
||||
* Created by minjaesong on 2018-08-07.
|
||||
*/
|
||||
data class GlyphProps(
|
||||
val width: Int,
|
||||
val writeOnTop: Boolean,
|
||||
val alignWhere: Int, // ALIGN_LEFT..ALIGN_BEFORE
|
||||
val alignXPos: Int, // 0..15 or DIA_OVERLAY/DIA_JOINER depends on the context
|
||||
val rtl: Boolean = false,
|
||||
|
||||
val isLowheight: Boolean = false,
|
||||
|
||||
val nudgeX: Int = 0,
|
||||
val nudgeY: Int = 0,
|
||||
|
||||
val diacriticsAnchors: Array<DiacriticsAnchor> = Array(6) { DiacriticsAnchor(it, 0, 0, false, false) },
|
||||
|
||||
val alignWhere: Int = 0, // ALIGN_LEFT..ALIGN_BEFORE
|
||||
|
||||
val writeOnTop: Boolean = false,
|
||||
|
||||
val stackWhere: Int = 0, // STACK_UP..STACK_UP_N_DOWN
|
||||
var nudgeRight: Boolean = false,
|
||||
var extInfo: IntArray? = null,
|
||||
|
||||
val extInfo: IntArray = DEFAULT_EXTINFO,
|
||||
|
||||
val hasKernData: Boolean = false,
|
||||
val isLowheight: Boolean = false,
|
||||
val isKernYtype: Boolean = false,
|
||||
val kerningMask: Int = 255
|
||||
val kerningMask: Int = 255,
|
||||
|
||||
val rtl: Boolean = false,
|
||||
) {
|
||||
companion object {
|
||||
const val ALIGN_LEFT = 0
|
||||
@@ -33,9 +46,11 @@ data class GlyphProps(
|
||||
const val DIA_JOINER = 2
|
||||
|
||||
private fun Boolean.toInt() = if (this) 1 else 0
|
||||
|
||||
val DEFAULT_EXTINFO = IntArray(15)
|
||||
}
|
||||
|
||||
constructor(width: Int, tags: Int) : this(
|
||||
/*constructor(width: Int, tags: Int) : this(
|
||||
width,
|
||||
tags.ushr(7).and(1) == 1,
|
||||
tags.ushr(5).and(3),
|
||||
@@ -59,21 +74,30 @@ data class GlyphProps(
|
||||
isLowheight,
|
||||
isKernYtype,
|
||||
kerningMask
|
||||
)
|
||||
)*/
|
||||
|
||||
fun isOverlay() = writeOnTop && alignXPos == 1
|
||||
// fun isOverlay() = writeOnTop && alignXPos == 1
|
||||
|
||||
override fun hashCode(): Int {
|
||||
val tags = rtl.toInt() or alignXPos.shl(1) or alignWhere.shl(5) or
|
||||
val tags = rtl.toInt() or alignWhere.shl(5) or
|
||||
writeOnTop.toInt().shl(7) or stackWhere.shl(8)
|
||||
|
||||
var hash = -2128831034
|
||||
|
||||
extInfo?.forEach {
|
||||
extInfo.forEach {
|
||||
hash = hash xor it
|
||||
hash = hash * 16777619
|
||||
}
|
||||
|
||||
diacriticsAnchors.forEach {
|
||||
hash = hash xor it.type
|
||||
hash = hash * 16777619
|
||||
hash = hash xor (it.x or (if (it.xUsed) 128 else 0))
|
||||
hash = hash * 16777619
|
||||
hash = hash xor (it.y or (if (it.yUsed) 128 else 0))
|
||||
hash = hash * 16777619
|
||||
}
|
||||
|
||||
hash = hash xor tags
|
||||
hash = hash * 167677619
|
||||
|
||||
|
||||
Reference in New Issue
Block a user