diacritics bit is now colour-coded

This commit is contained in:
minjaesong
2021-11-26 10:59:30 +09:00
parent 2fa867ce44
commit 94a40a4a87
14 changed files with 31 additions and 18 deletions

View File

@@ -58,7 +58,7 @@ Rightmost vertical column (should be 20 px tall) contains the tags. Tags are def
X -'
A -,_ 0 Align 1 Align 0 Align 1 Align before
A -' 0 left 0 right 1 centre 1 the glyph
D --write-on-top, usually it's diatritics but not always (e.g. devanagari vowel sign O)
D --Diacritics Type Bit (see below; not all diacritics are marked as one on the spritesheet)
S -,_ 0 Stack 1 Stack 0 Before 1 Up &
(MSB) S -' 0 up 0 down 1 &After 1 Down (e.g. U+0C48)
@@ -66,10 +66,10 @@ TODO:
c - Nudging
Y - Anchor point Y for undefined, undefined, undefined
X - Anchor point X for undefined, undefined, undefined
Y - Anchor point Y for centre-aligned diacritics, undefined, undefined
X - Anchor point X for centre-aligned diacritics, undefined, undefined
Y - Anchor point Y for (unused), undefined, undefined
X - Anchor point X for Type-0 (centre-aligned) diacritics, undefined, undefined
* Nudging Bits encoding:
* Nudging Bits Encoding:
<MSB,Red> SXXXXXXX SYYYYYYY 00000000 <LSB,Blue>
@@ -83,7 +83,15 @@ Y-positive: nudges towards up
<MSB,Red> 1X1X1X1X 1X2X2X2X 1X3X3X3X <LSB,Blue>
where Red is first, Green is second, Blue is the third diacritics.
MSB for each word must be set to indicate the value is being used.
MSB for each word must be set so that the pixel would appear brighter on the image editor.
(the font program will only read low 7 bits for each RGB channel)
* Diacritics Type Bit Encoding:
<MSB,Red> FFFFFFFF FFFFFFFF FFFFFFFF <LSB,Blue> (For Type-0)
<MSB,Red> TTTT0000 00000000 00000000 <LSB,Blue> (For Type-1 to Type-15)
Right now, only the type-0 diacritics and its anchor point is used by the font.
-= NOTE =-
@@ -94,9 +102,6 @@ Interpretation:
DIA_OVERLAY = 1
DIA_JOINER = 2
Right now, only the type-0 diacritics anchor point is used by the font.
TODO: use D-bit to give each diacritic a type
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

View File

@@ -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

View File

@@ -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}

View File

@@ -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
}

Binary file not shown.

Binary file not shown.

Binary file not shown.