mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-06-06 05:58:30 +09:00
maths ops
This commit is contained in:
30
.claude/settings.local.json
Normal file
30
.claude/settings.local.json
Normal file
@@ -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)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
93
.claude/skills/add-unicode-block/SKILL.md
Normal file
93
.claude/skills/add-unicode-block/SKILL.md
Normal file
@@ -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_<UPPER_SNAKE>_VARW` (e.g. `SHEET_OGHAM_VARW`)
|
||||||
|
- **Kotlin indexY function**: `<camelCase>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_<NAME>_VARW = <INDEX>
|
||||||
|
```
|
||||||
|
|
||||||
|
**b) fileList entry** — find `internal val fileList` array and append before the closing `)`:
|
||||||
|
```kotlin
|
||||||
|
"<tga_filename>",
|
||||||
|
```
|
||||||
|
|
||||||
|
**c) codeRange entry** — find `internal val codeRange` array and append before the closing `)`:
|
||||||
|
```kotlin
|
||||||
|
0x<START>..<0x<END>, // SHEET_<NAME>_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_<NAME>_VARW -> <camelCase>IndexY(ch)
|
||||||
|
```
|
||||||
|
|
||||||
|
**e) indexY function** — find the block of private `*IndexY` functions near the bottom of the companion object and append:
|
||||||
|
```kotlin
|
||||||
|
private fun <camelCase>IndexY(c: CodePoint) = (c - 0x<START>) / 16
|
||||||
|
```
|
||||||
|
|
||||||
|
### Python: `OTFbuild/sheet_config.py`
|
||||||
|
|
||||||
|
**f) Sheet index constant** — find the block of `SHEET_* = <n>` constants (just before `SHEET_UNKNOWN = 254`) and append:
|
||||||
|
```python
|
||||||
|
SHEET_<NAME>_VARW = <INDEX>
|
||||||
|
```
|
||||||
|
|
||||||
|
**g) FILE_LIST entry** — find `FILE_LIST = [` array and append before the closing `]`:
|
||||||
|
```python
|
||||||
|
"<tga_filename>",
|
||||||
|
```
|
||||||
|
|
||||||
|
**h) CODE_RANGE entry** — find `CODE_RANGE = [` array and append before the closing `]`:
|
||||||
|
```python
|
||||||
|
list(range(0x<START>, 0x<END+1>)), # <INDEX>: <ScriptName>
|
||||||
|
```
|
||||||
|
|
||||||
|
**i) index_y lambda** — find the dict in `get_index_y(sheet_index, c)` (just before `SHEET_HANGUL: lambda: 0`) and append:
|
||||||
|
```python
|
||||||
|
SHEET_<NAME>_VARW: lambda: (c - 0x<START>) // 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).
|
||||||
@@ -81,6 +81,7 @@ SHEET_LATIN_EXTG_VARW = 47
|
|||||||
SHEET_OGHAM_VARW = 48
|
SHEET_OGHAM_VARW = 48
|
||||||
SHEET_COPTIC_VARW = 49
|
SHEET_COPTIC_VARW = 49
|
||||||
SHEET_CYRILIC_EXTD_VARW = 50
|
SHEET_CYRILIC_EXTD_VARW = 50
|
||||||
|
SHEET_MATHS1_VARW = 51
|
||||||
|
|
||||||
SHEET_UNKNOWN = 254
|
SHEET_UNKNOWN = 254
|
||||||
|
|
||||||
@@ -136,6 +137,7 @@ FILE_LIST = [
|
|||||||
"ogham_variable.tga",
|
"ogham_variable.tga",
|
||||||
"coptic_variable.tga",
|
"coptic_variable.tga",
|
||||||
"cyrilic_extD_variable.tga",
|
"cyrilic_extD_variable.tga",
|
||||||
|
"maths1_extrawide_variable.tga",
|
||||||
]
|
]
|
||||||
|
|
||||||
CODE_RANGE = [
|
CODE_RANGE = [
|
||||||
@@ -190,6 +192,7 @@ CODE_RANGE = [
|
|||||||
list(range(0x1680, 0x16A0)), # 48: Ogham
|
list(range(0x1680, 0x16A0)), # 48: Ogham
|
||||||
list(range(0x2C80, 0x2D00)), # 49: Coptic
|
list(range(0x2C80, 0x2D00)), # 49: Coptic
|
||||||
list(range(0x1E030, 0x1E090)), # 50: Cyrillic Ext D
|
list(range(0x1E030, 0x1E090)), # 50: Cyrillic Ext D
|
||||||
|
list(range(0x2200, 0x2300)), # 51: Maths1
|
||||||
]
|
]
|
||||||
|
|
||||||
CODE_RANGE_HANGUL_COMPAT = range(0x3130, 0x3190)
|
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_OGHAM_VARW: lambda: (c - 0x1680) // 16,
|
||||||
SHEET_COPTIC_VARW: lambda: (c - 0x2C80) // 16,
|
SHEET_COPTIC_VARW: lambda: (c - 0x2C80) // 16,
|
||||||
SHEET_CYRILIC_EXTD_VARW: lambda: (c - 0x1E030) // 16,
|
SHEET_CYRILIC_EXTD_VARW: lambda: (c - 0x1E030) // 16,
|
||||||
|
SHEET_MATHS1_VARW: lambda: (c - 0x2200) // 16,
|
||||||
SHEET_HANGUL: lambda: 0,
|
SHEET_HANGUL: lambda: 0,
|
||||||
}.get(sheet_index, lambda: c // 16)()
|
}.get(sheet_index, lambda: c // 16)()
|
||||||
|
|||||||
BIN
demo.PNG
BIN
demo.PNG
Binary file not shown.
|
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 179 KiB |
@@ -151,6 +151,7 @@ How multilingual? Real multilingual!
|
|||||||
⁃ Kana Extended-A
|
⁃ Kana Extended-A
|
||||||
⁃ Small Kana Extension
|
⁃ Small Kana Extension
|
||||||
⁃ Letterlike Symbols
|
⁃ Letterlike Symbols
|
||||||
|
⁃ Mathematical Operators
|
||||||
⁃ Number Forms
|
⁃ Number Forms
|
||||||
⁃ Ogham
|
⁃ Ogham
|
||||||
⁃ Optical Character Recognition
|
⁃ Optical Character Recognition
|
||||||
|
|||||||
BIN
src/assets/maths1_extrawide_variable.tga
LFS
Normal file
BIN
src/assets/maths1_extrawide_variable.tga
LFS
Normal file
Binary file not shown.
@@ -884,6 +884,7 @@ class TerrarumSansBitmap(
|
|||||||
SHEET_OGHAM_VARW -> oghamIndexY(ch)
|
SHEET_OGHAM_VARW -> oghamIndexY(ch)
|
||||||
SHEET_COPTIC_VARW -> copticIndexY(ch)
|
SHEET_COPTIC_VARW -> copticIndexY(ch)
|
||||||
SHEET_CYRILIC_EXTD_VARW -> cyrilicExtDIndexY(ch)
|
SHEET_CYRILIC_EXTD_VARW -> cyrilicExtDIndexY(ch)
|
||||||
|
SHEET_MATHS1_VARW -> maths1IndexY(ch)
|
||||||
else -> ch / 16
|
else -> ch / 16
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2618,6 +2619,7 @@ class TerrarumSansBitmap(
|
|||||||
internal const val SHEET_OGHAM_VARW = 48
|
internal const val SHEET_OGHAM_VARW = 48
|
||||||
internal const val SHEET_COPTIC_VARW = 49
|
internal const val SHEET_COPTIC_VARW = 49
|
||||||
internal const val SHEET_CYRILIC_EXTD_VARW = 50
|
internal const val SHEET_CYRILIC_EXTD_VARW = 50
|
||||||
|
internal const val SHEET_MATHS1_VARW = 51
|
||||||
|
|
||||||
internal const val SHEET_UNKNOWN = 254
|
internal const val SHEET_UNKNOWN = 254
|
||||||
|
|
||||||
@@ -2691,6 +2693,7 @@ class TerrarumSansBitmap(
|
|||||||
"ogham_variable.tga",
|
"ogham_variable.tga",
|
||||||
"coptic_variable.tga",
|
"coptic_variable.tga",
|
||||||
"cyrilic_extD_variable.tga",
|
"cyrilic_extD_variable.tga",
|
||||||
|
"maths1_extrawide_variable.tga",
|
||||||
)
|
)
|
||||||
internal val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
|
internal val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
|
||||||
0..0xFF, // SHEET_ASCII_VARW
|
0..0xFF, // SHEET_ASCII_VARW
|
||||||
@@ -2744,6 +2747,7 @@ class TerrarumSansBitmap(
|
|||||||
0x1680..0x169F, // SHEET_OGHAM_VARW
|
0x1680..0x169F, // SHEET_OGHAM_VARW
|
||||||
0x2C80..0x2CFF, // SHEET_COPTIC_VARW
|
0x2C80..0x2CFF, // SHEET_COPTIC_VARW
|
||||||
0x1E030..0x1E08F, // SHEET_CYRILIC_EXTD_VARW
|
0x1E030..0x1E08F, // SHEET_CYRILIC_EXTD_VARW
|
||||||
|
0x2200..0x22FF, // SHEET_MATHS1_VARW
|
||||||
)
|
)
|
||||||
private val codeRangeHangulCompat = 0x3130..0x318F
|
private val codeRangeHangulCompat = 0x3130..0x318F
|
||||||
|
|
||||||
@@ -3105,6 +3109,7 @@ class TerrarumSansBitmap(
|
|||||||
private fun oghamIndexY(c: CodePoint) = (c - 0x1680) / 16
|
private fun oghamIndexY(c: CodePoint) = (c - 0x1680) / 16
|
||||||
private fun copticIndexY(c: CodePoint) = (c - 0x2C80) / 16
|
private fun copticIndexY(c: CodePoint) = (c - 0x2C80) / 16
|
||||||
private fun cyrilicExtDIndexY(c: CodePoint) = (c - 0x1E030) / 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 charsetOverrideDefault = Character.toChars(CHARSET_OVERRIDE_DEFAULT).toSurrogatedString()
|
||||||
val charsetOverrideBulgarian = Character.toChars(CHARSET_OVERRIDE_BG_BG).toSurrogatedString()
|
val charsetOverrideBulgarian = Character.toChars(CHARSET_OVERRIDE_BG_BG).toSurrogatedString()
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user