diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6a0519f..7057b47 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,8 +46,8 @@ Rightmost vertical column (should be 20 px tall) contains the tags. Tags are def W |= Width of the character W | W -' - m --Is this character lowheight? K -, + K | K |= Tags used by the "Keming Machine" K -' Q ---Compiler Directive (see below) diff --git a/OTFbuild/font_builder.py b/OTFbuild/font_builder.py index 630050c..441b282 100644 --- a/OTFbuild/font_builder.py +++ b/OTFbuild/font_builder.py @@ -370,10 +370,9 @@ def build_font(assets_dir, output_path, no_bitmap=False, no_features=False): x_offset = 0 x_offset -= g.props.nudge_x * SCALE - # For STACK_DOWN marks (below-base diacritics), negative nudge_y - # means "shift content down to below baseline". The sign convention - # is opposite to non-marks where positive nudge_y means shift down. - if g.props.stack_where == SC.STACK_DOWN and g.props.write_on_top >= 0: + # For marks (write_on_top >= 0), positive nudge_y means shift UP + # in the bitmap engine (opposite to non-marks where positive = down). + if g.props.write_on_top >= 0: y_offset = g.props.nudge_y * SCALE else: y_offset = -g.props.nudge_y * SCALE diff --git a/OTFbuild/opentype_features.py b/OTFbuild/opentype_features.py index 948514f..6677e65 100644 --- a/OTFbuild/opentype_features.py +++ b/OTFbuild/opentype_features.py @@ -1878,12 +1878,16 @@ def _generate_mark(glyphs, has): lines.append(f"lookup {mkmk_name} {{") if scat == 'up': - m2y = SC.ASCENT + SC.H_DIACRITICS * SC.SCALE + m2y_base = SC.ASCENT + SC.H_DIACRITICS * SC.SCALE else: # 'dn' - m2y = SC.ASCENT - SC.H_DIACRITICS * SC.SCALE + m2y_base = SC.ASCENT - SC.H_DIACRITICS * SC.SCALE for cp, g in mark_list: mx = mark_anchors.get(cp, 0) + # Cascade nudge_y: the mark2 anchor includes this mark's + # nudge so that the next stacked mark inherits the shift, + # matching the Kotlin engine's nudgeUpwardCounter / nudgeDownwardCounter. + m2y = m2y_base + g.props.nudge_y * SC.SCALE lines.append( f" pos mark {glyph_name(cp)}" f" mark {class_name};" diff --git a/keming_machine.txt b/keming_machine.txt index 07d064a..d404073 100644 --- a/keming_machine.txt +++ b/keming_machine.txt @@ -106,3 +106,5 @@ dot removal for diacritics: - encoding: - RRRRRRRR GGGGGGGG BBBBBBBB +--- Pixel 3 +Unused for now. \ No newline at end of file diff --git a/src/assets/ascii_variable.tga b/src/assets/ascii_variable.tga index 54f2ddc..48ebc2c 100755 --- a/src/assets/ascii_variable.tga +++ b/src/assets/ascii_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a8798ffb6aae629a78b8ea630fe16d3c4e396071e1235251a720d706ba3637a7 +oid sha256:d57e59c924b0fc211f5474b25cb07de345f4f7322ebce8e2fcfcf0dc70203b40 size 327698 diff --git a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt index dea5b6a..f2f12ca 100755 --- a/src/net/torvald/terrarumsansbitmap/GlyphProps.kt +++ b/src/net/torvald/terrarumsansbitmap/GlyphProps.kt @@ -1,5 +1,7 @@ package net.torvald.terrarumsansbitmap +import net.torvald.terrarumsansbitmap.gdx.CodePoint + /** * Created by minjaesong on 2021-11-25. */ @@ -29,6 +31,8 @@ data class GlyphProps( val isKernYtype: Boolean = false, val kerningMask: Int = 255, + val dotRemoval: CodePoint? = null, + val directiveOpcode: Int = 0, // 8-bits wide val directiveArg1: Int = 0, // 8-bits wide val directiveArg2: Int = 0, // 8-bits wide diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index f160c5c..336a3cc 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -921,9 +921,9 @@ class TerrarumSansBitmap( val isLowHeight = (pixmap.getPixel(codeStartX, codeStartY + 5).and(255) != 0) // Keming machine parameters - val kerningBit1 = pixmap.getPixel(codeStartX, codeStartY + 6).tagify() - val kerningBit2 = pixmap.getPixel(codeStartX, codeStartY + 7).tagify() - val kerningBit3 = pixmap.getPixel(codeStartX, codeStartY + 8).tagify() + val kerningBit1 = pixmap.getPixel(codeStartX, codeStartY + 6).tagify() // glyph shape + val kerningBit2 = pixmap.getPixel(codeStartX, codeStartY + 7).tagify() // dot removal + val kerningBit3 = pixmap.getPixel(codeStartX, codeStartY + 8).tagify() // unused var isKernYtype = ((kerningBit1 and 0x80000000.toInt()) != 0) var kerningMask = kerningBit1.ushr(8).and(0xFFFFFF) val hasKernData = kerningBit1 and 255 != 0//(kerningBit1 and 255 != 0 && kerningMask != 0xFFFF) @@ -971,7 +971,9 @@ class TerrarumSansBitmap( GlyphProps.STACK_DONT else (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, IntArray(15), hasKernData, isKernYtype, kerningMask, directiveOpcode, directiveArg1, directiveArg2) + val dotRemoval = if (kerningBit2 == 0) null else kerningBit2.ushr(8) + + glyphProps[code] = GlyphProps(width, isLowHeight, nudgeX, nudgeY, diacriticsAnchors, alignWhere, writeOnTop, stackWhere, IntArray(15), hasKernData, isKernYtype, kerningMask, dotRemoval, directiveOpcode, directiveArg1, directiveArg2) // extra info val extCount = glyphProps[code]?.requiredExtInfoCount() ?: 0 @@ -1533,8 +1535,8 @@ 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 ?: -1) >= 0 && glyphProps[cNext]?.stackWhere == GlyphProps.STACK_UP) { - seq.add(diacriticDotRemoval[c]!!) + else if (glyphProps[c]!!.dotRemoval != null && (glyphProps[cNext]?.writeOnTop ?: -1) >= 0 && glyphProps[cNext]?.stackWhere == GlyphProps.STACK_UP) { + seq.add(glyphProps[c]!!.dotRemoval!!) } // BEGIN of tamil subsystem implementation @@ -2747,11 +2749,6 @@ class TerrarumSansBitmap( 0x20..0x7F, ) - private val diacriticDotRemoval = hashMapOf( - 'i'.toInt() to 0x131, - 'j'.toInt() to 0x237 - ) - internal fun Int.charInfo() = "U+${this.toString(16).padStart(4, '0').toUpperCase()}: ${Character.getName(this)}" const val NQSP = 0x2000 diff --git a/work_files/ascii_variable.psd b/work_files/ascii_variable.psd index 5f638e5..42a0a81 100644 --- a/work_files/ascii_variable.psd +++ b/work_files/ascii_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec9310e21a0b77d2481e69d1650b757072625cbbd2783447c822ac7d6e168288 -size 348791 +oid sha256:fc0afd8ab379aedb3c9e74fe224bad91477d607899dd5670753f96983175dc47 +size 348831