mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-13 22:46:07 +09:00
diacritics bit is now colour-coded
This commit is contained in:
@@ -19,7 +19,7 @@ data class GlyphProps(
|
||||
|
||||
val alignWhere: Int = 0, // ALIGN_LEFT..ALIGN_BEFORE
|
||||
|
||||
val writeOnTop: Boolean = false,
|
||||
val writeOnTop: Int = -1, // -1: false, 0: Type-0, 1: Type-1, etc;
|
||||
|
||||
val stackWhere: Int = 0, // STACK_UP..STACK_UP_N_DOWN
|
||||
|
||||
|
||||
@@ -751,13 +751,19 @@ class TerrarumSansBitmap(
|
||||
|
||||
val alignWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 15).and(255) != 0).toInt() shl y) }
|
||||
|
||||
val writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17).and(255) != 0
|
||||
var writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17) // NO .tagify()
|
||||
if (writeOnTop and 255 == 0) writeOnTop = -1
|
||||
else {
|
||||
writeOnTop = writeOnTop.ushr(8)
|
||||
if (writeOnTop == 0xFFFFFF) writeOnTop = 0
|
||||
}
|
||||
|
||||
val stackWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 18).and(255) != 0).toInt() shl y) }
|
||||
|
||||
glyphProps[code] = GlyphProps(width, isLowHeight, nudgeX, nudgeY, diacriticsAnchors, alignWhere, writeOnTop, stackWhere, GlyphProps.DEFAULT_EXTINFO, hasKernData, isKernYtype, kerningMask)
|
||||
|
||||
// if (nudgingBits != 0) dbgprn("${code.charInfo()} nudgeX=$nudgeX, nudgeY=$nudgeY, nudgingBits=0x${nudgingBits.toString(16)}")
|
||||
// if (writeOnTop >= 0) dbgprn("WriteOnTop: ${code.charInfo()} (Type-${writeOnTop})")
|
||||
|
||||
// extra info
|
||||
val extCount = glyphProps[code]?.requiredExtInfoCount() ?: 0
|
||||
@@ -888,7 +894,7 @@ class TerrarumSansBitmap(
|
||||
if (isHangul(thisChar) && !isHangulChoseong(thisChar) && !isHangulCompat(thisChar)) {
|
||||
posXbuffer[charIndex] = posXbuffer[nonDiacriticCounter]
|
||||
}
|
||||
else if (!thisProp.writeOnTop) {
|
||||
else if (thisProp.writeOnTop < 0) {
|
||||
posXbuffer[charIndex] = -thisProp.nudgeX +
|
||||
when (itsProp.alignWhere) {
|
||||
GlyphProps.ALIGN_RIGHT ->
|
||||
@@ -982,7 +988,7 @@ class TerrarumSansBitmap(
|
||||
(if (errorOnUnknownChar) throw throw InternalError("No GlyphProps for char '${str[nonDiacriticCounter]}' " +
|
||||
"(${str[nonDiacriticCounter].charInfo()})") else nullProp)
|
||||
posXbuffer[posXbuffer.lastIndex] = 1 + posXbuffer[posXbuffer.lastIndex - 1] + // adding 1 to house the shadow
|
||||
if (lastCharProp?.writeOnTop == true) {
|
||||
if (lastCharProp != null && lastCharProp.writeOnTop >= 0) {
|
||||
val realDiacriticWidth = if (lastCharProp.alignWhere == GlyphProps.ALIGN_CENTRE) {
|
||||
(lastCharProp.width).div(2) + penultCharProp.diacriticsAnchors[0].x
|
||||
}
|
||||
@@ -1088,7 +1094,7 @@ class TerrarumSansBitmap(
|
||||
|
||||
}
|
||||
// for lowercase i and j, if cNext is a diacritic that goes on top, remove the dots
|
||||
else if (diacriticDotRemoval.containsKey(c) && glyphProps[cNext]?.writeOnTop == true && glyphProps[cNext]?.stackWhere == GlyphProps.STACK_UP) {
|
||||
else if (diacriticDotRemoval.containsKey(c) && (glyphProps[cNext]?.writeOnTop ?: -1) >= 0 && glyphProps[cNext]?.stackWhere == GlyphProps.STACK_UP) {
|
||||
seq.add(diacriticDotRemoval[c]!!)
|
||||
}
|
||||
// rearrange {letter, before-and-after diacritics} as {letter, before-diacritics, after-diacritics}
|
||||
|
||||
@@ -241,7 +241,9 @@ class TerrarumTypewriterBitmap(
|
||||
|
||||
val alignWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 15).and(255) != 0).toInt() shl y) }
|
||||
|
||||
val writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17).and(255) != 0
|
||||
var writeOnTop = pixmap.getPixel(codeStartX, codeStartY + 17).tagify()
|
||||
if (writeOnTop == 0) writeOnTop = -1
|
||||
else if (writeOnTop == 0xFFFFFF) writeOnTop = 0
|
||||
|
||||
val stackWhere = (0..1).fold(0) { acc, y -> acc or ((pixmap.getPixel(codeStartX, codeStartY + y + 18).and(255) != 0).toInt() shl y) }
|
||||
|
||||
@@ -439,7 +441,7 @@ class TerrarumTypewriterBitmap(
|
||||
}
|
||||
|
||||
|
||||
if (!thisProp.writeOnTop) {
|
||||
if (thisProp.writeOnTop < 0) {
|
||||
posXbuffer[charIndex] = -thisProp.nudgeX +
|
||||
when (itsProp.alignWhere) {
|
||||
GlyphProps.ALIGN_RIGHT ->
|
||||
@@ -456,7 +458,7 @@ class TerrarumTypewriterBitmap(
|
||||
stackDownwardCounter = 0
|
||||
extraWidth = thisProp.nudgeX // NOTE: sign is flipped!
|
||||
}
|
||||
else if (thisProp.writeOnTop && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) {
|
||||
/*else if (thisProp.writeOnTop >= 0 && thisProp.diacriticsAnchors[0].x == GlyphProps.DIA_JOINER) {
|
||||
posXbuffer[charIndex] = when (itsProp.alignWhere) {
|
||||
GlyphProps.ALIGN_RIGHT ->
|
||||
posXbuffer[nonDiacriticCounter] + TerrarumSansBitmap.W_VAR_INIT + alignmentOffset
|
||||
@@ -466,7 +468,7 @@ class TerrarumTypewriterBitmap(
|
||||
posXbuffer[nonDiacriticCounter] + itsProp.width + alignmentOffset
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
else {
|
||||
// set X pos according to alignment information
|
||||
posXbuffer[charIndex] = when (thisProp.alignWhere) {
|
||||
@@ -530,7 +532,7 @@ class TerrarumTypewriterBitmap(
|
||||
val lastCharProp = glyphProps[str.last()]
|
||||
val penultCharProp = glyphProps[str[nonDiacriticCounter]]!!
|
||||
posXbuffer[posXbuffer.lastIndex] = 1 + posXbuffer[posXbuffer.lastIndex - 1] + // adding 1 to house the shadow
|
||||
if (lastCharProp?.writeOnTop == true) {
|
||||
if (lastCharProp != null && lastCharProp.writeOnTop >= 0) {
|
||||
val realDiacriticWidth = if (lastCharProp.alignWhere == GlyphProps.ALIGN_CENTRE) {
|
||||
(lastCharProp.width).div(2) + penultCharProp.diacriticsAnchors[0].x
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user