diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..71cdf0f --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,30 @@ +{ + "permissions": { + "allow": [ + "WebFetch(domain:github.com)", + "WebSearch", + "Bash(head:*)", + "WebFetch(domain:gitlab.com)", + "Bash(java:*)", + "Bash(ls:*)", + "Bash(jar tf:*)", + "Bash(chmod +x:*)", + "WebFetch(domain:fontforge.org)", + "WebFetch(domain:fonttools.readthedocs.io)", + "Bash(grep:*)", + "Bash(tail:*)", + "Bash(python3:*)", + "Bash(make:*)", + "Bash(git stash:*)", + "Bash(./autokem*)", + "Bash(cmp:*)", + "Bash(wc:*)", + "Bash(pip3:*)", + "Bash(pip install:*)", + "Bash(.venv/bin/python3:*)", + "Bash(.venv/bin/python:*)", + "Bash(find:*)", + "Skill(update-config)" + ] + } +} diff --git a/.claude/skills/add-unicode-block/SKILL.md b/.claude/skills/add-unicode-block/SKILL.md new file mode 100644 index 0000000..3917a5c --- /dev/null +++ b/.claude/skills/add-unicode-block/SKILL.md @@ -0,0 +1,93 @@ +--- +name: add-unicode-block +description: Add a new Unicode script/block to the Terrarum Sans Bitmap font engine. +--- +# Add Unicode Block + +## Required inputs + +The user must supply: +- **Script name** — human-readable name used in constant/function names (e.g. `Ogham`, `LatinExtE`) +- **TGA filename** — the sprite sheet filename without path (e.g. `ogham_variable.tga`) +- **Unicode range** — start and end codepoints inclusive (e.g. `U+1680..U+169F`) + +If any of these are missing, ask for them before proceeding. + +## Step 1 — Determine the next sheet index + +Read the sheet index constants from both files to find the current highest index (excluding `SHEET_UNKNOWN = 254`): + +- Kotlin: `src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt` — grep for `internal const val SHEET_` +- Python: `OTFbuild/sheet_config.py` — grep for `^SHEET_` + +The new index = highest existing index + 1. + +## Step 2 — Derive identifiers + +From the script name, derive: +- **Kotlin constant**: `SHEET__VARW` (e.g. `SHEET_OGHAM_VARW`) +- **Kotlin indexY function**: `IndexY` (e.g. `oghamIndexY`) +- **Python constant**: same as Kotlin constant +- **Range start hex**: the lower bound codepoint as a `0x`-prefixed Kotlin/Python literal + +## Step 3 — Edit both files + +Make all 6 edits. Read each section before editing. + +### Kotlin: `src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt` + +**a) Sheet index constant** — find the block of `internal const val SHEET_*` constants (just before `SHEET_UNKNOWN = 254`) and append: +```kotlin +internal const val SHEET__VARW = +``` + +**b) fileList entry** — find `internal val fileList` array and append before the closing `)`: +```kotlin +"", +``` + +**c) codeRange entry** — find `internal val codeRange` array and append before the closing `)`: +```kotlin +0x..<0x, // SHEET__VARW +``` +Use `+` to combine non-contiguous ranges if needed. + +**d) getSheetwisePosition when-branch** — find the `when` block that dispatches to indexY functions (just before `else -> ch / 16`) and append: +```kotlin +SHEET__VARW -> IndexY(ch) +``` + +**e) indexY function** — find the block of private `*IndexY` functions near the bottom of the companion object and append: +```kotlin +private fun IndexY(c: CodePoint) = (c - 0x) / 16 +``` + +### Python: `OTFbuild/sheet_config.py` + +**f) Sheet index constant** — find the block of `SHEET_* = ` constants (just before `SHEET_UNKNOWN = 254`) and append: +```python +SHEET__VARW = +``` + +**g) FILE_LIST entry** — find `FILE_LIST = [` array and append before the closing `]`: +```python +"", +``` + +**h) CODE_RANGE entry** — find `CODE_RANGE = [` array and append before the closing `]`: +```python +list(range(0x, 0x)), # : +``` + +**i) index_y lambda** — find the dict in `get_index_y(sheet_index, c)` (just before `SHEET_HANGUL: lambda: 0`) and append: +```python +SHEET__VARW: lambda: (c - 0x) // 16, +``` + +## Step 4 — Verify + +After all edits, confirm: +1. The Kotlin constant, fileList, codeRange, when-branch, and indexY function are all present and consistent. +2. The Python constant, FILE_LIST, CODE_RANGE, and index_y lambda are all present and consistent. +3. The indices in both files match. +4. The range end in `CODE_RANGE` is `end + 1` (Python `range` is exclusive). diff --git a/OTFbuild/sheet_config.py b/OTFbuild/sheet_config.py index 2f08b27..5fda15a 100644 --- a/OTFbuild/sheet_config.py +++ b/OTFbuild/sheet_config.py @@ -81,6 +81,7 @@ SHEET_LATIN_EXTG_VARW = 47 SHEET_OGHAM_VARW = 48 SHEET_COPTIC_VARW = 49 SHEET_CYRILIC_EXTD_VARW = 50 +SHEET_MATHS1_VARW = 51 SHEET_UNKNOWN = 254 @@ -136,6 +137,7 @@ FILE_LIST = [ "ogham_variable.tga", "coptic_variable.tga", "cyrilic_extD_variable.tga", + "maths1_extrawide_variable.tga", ] CODE_RANGE = [ @@ -190,6 +192,7 @@ CODE_RANGE = [ list(range(0x1680, 0x16A0)), # 48: Ogham list(range(0x2C80, 0x2D00)), # 49: Coptic list(range(0x1E030, 0x1E090)), # 50: Cyrillic Ext D + list(range(0x2200, 0x2300)), # 51: Maths1 ] CODE_RANGE_HANGUL_COMPAT = range(0x3130, 0x3190) @@ -575,5 +578,6 @@ def index_y(sheet_index, c): SHEET_OGHAM_VARW: lambda: (c - 0x1680) // 16, SHEET_COPTIC_VARW: lambda: (c - 0x2C80) // 16, SHEET_CYRILIC_EXTD_VARW: lambda: (c - 0x1E030) // 16, + SHEET_MATHS1_VARW: lambda: (c - 0x2200) // 16, SHEET_HANGUL: lambda: 0, }.get(sheet_index, lambda: c // 16)() diff --git a/demo.PNG b/demo.PNG index 5fc40d9..1aae8c9 100644 Binary files a/demo.PNG and b/demo.PNG differ diff --git a/demotext_unaligned.txt b/demotext_unaligned.txt index 09628b8..bd3d088 100755 --- a/demotext_unaligned.txt +++ b/demotext_unaligned.txt @@ -151,6 +151,7 @@ How multilingual? Real multilingual! ⁃ Kana Extended-A ⁃ Small Kana Extension ⁃ Letterlike Symbols +⁃ Mathematical Operators ⁃ Number Forms ⁃ Ogham ⁃ Optical Character Recognition diff --git a/src/assets/maths1_extrawide_variable.tga b/src/assets/maths1_extrawide_variable.tga new file mode 100644 index 0000000..4baa626 --- /dev/null +++ b/src/assets/maths1_extrawide_variable.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb9757e6efb9b8008d93c53b5b09060833e2676863f38cc71485a4c5908f2251 +size 655378 diff --git a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt index d68f45c..bb43d8b 100755 --- a/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt +++ b/src/net/torvald/terrarumsansbitmap/gdx/TerrarumSansBitmap.kt @@ -884,6 +884,7 @@ class TerrarumSansBitmap( SHEET_OGHAM_VARW -> oghamIndexY(ch) SHEET_COPTIC_VARW -> copticIndexY(ch) SHEET_CYRILIC_EXTD_VARW -> cyrilicExtDIndexY(ch) + SHEET_MATHS1_VARW -> maths1IndexY(ch) else -> ch / 16 } @@ -2618,6 +2619,7 @@ class TerrarumSansBitmap( internal const val SHEET_OGHAM_VARW = 48 internal const val SHEET_COPTIC_VARW = 49 internal const val SHEET_CYRILIC_EXTD_VARW = 50 + internal const val SHEET_MATHS1_VARW = 51 internal const val SHEET_UNKNOWN = 254 @@ -2691,6 +2693,7 @@ class TerrarumSansBitmap( "ogham_variable.tga", "coptic_variable.tga", "cyrilic_extD_variable.tga", + "maths1_extrawide_variable.tga", ) internal val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!! 0..0xFF, // SHEET_ASCII_VARW @@ -2744,6 +2747,7 @@ class TerrarumSansBitmap( 0x1680..0x169F, // SHEET_OGHAM_VARW 0x2C80..0x2CFF, // SHEET_COPTIC_VARW 0x1E030..0x1E08F, // SHEET_CYRILIC_EXTD_VARW + 0x2200..0x22FF, // SHEET_MATHS1_VARW ) private val codeRangeHangulCompat = 0x3130..0x318F @@ -3105,6 +3109,7 @@ class TerrarumSansBitmap( private fun oghamIndexY(c: CodePoint) = (c - 0x1680) / 16 private fun copticIndexY(c: CodePoint) = (c - 0x2C80) / 16 private fun cyrilicExtDIndexY(c: CodePoint) = (c - 0x1E030) / 16 + private fun maths1IndexY(c: CodePoint) = (c - 0x2200) / 16 val charsetOverrideDefault = Character.toChars(CHARSET_OVERRIDE_DEFAULT).toSurrogatedString() val charsetOverrideBulgarian = Character.toChars(CHARSET_OVERRIDE_BG_BG).toSurrogatedString() diff --git a/work_files/maths1_extrawide_variable.kra b/work_files/maths1_extrawide_variable.kra index e6581e5..2cf0aeb 100644 --- a/work_files/maths1_extrawide_variable.kra +++ b/work_files/maths1_extrawide_variable.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7cd07e6efd7098989ae181c8b190a70ef717f0d8576a07c845050a93d8c17d72 -size 94381 +oid sha256:f199fc279dcd98488fd2df8c389074f4dcfdd3001b1e19a7920db462e8e52f7d +size 131408