Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

katsuji

活字, movable type. Variable-width font tooling for a816 SNES projects.

Build a project's fonts and strings

katsuji.toml at the project root:

[fonts.dialog]
png = "fonts/vwf.png"
cell = [8, 16]
table = "text/ff4fr.tbl"
output = "assets/font.dat"
widths = { "0xFF" = 3, "0xA0" = -1 }     # negative trims, positive sets
kerning-candidates = ["Ta", "Te", "va"]  # tested for collision kerning
kerning = { "tt" = 2 }                   # hand-tuned: pixels tighter

[fonts.menu]
png = "fonts/8x8vwf.png"
cell = [8, 8]
table = "text/ff4_menus.tbl"
output = "assets/menu_font.dat"
constants = "assets/menu_font.i"         # a816 constants describing the file
spacing = 1                              # optional tracking: each drawn glyph advances 1 more; `widths` win

[strings.items]
font = "menu"
file = "text/items.txt"                  # one string per line (or `texts = [...]`)
bpp = 2
ink = 3
paper = 1
blob = "assets/items_vwf.dat"            # tiles, no string across a bank edge
index = "assets/items_vwf.idx"           # 4 bytes per string: offset lo16, bank, tiles

A font the game reads in its own layout instead of katsuji's VWF file takes a format:

[fonts.menu]
format = "tiles"                         # SNES planar tiles of the PNG's colour indices
png = "fonts/menu.png"                   # palettized: index N is colour N
cell = [8, 8]
bpp = 2
output = "build/menu_font.dat"

[fonts.dialog]
format = "rows16"                        # 1bpp rows, 16 pixels wide, little-endian words (FF6)
png = "fonts/dialog.png"
cell = [12, 11]
first = "0x20"                           # codes written: first .. first + count - 1
count = 224
x-offset = 4                             # glyph drawn 4 pixels into the row
spacing = 1                              # width = ink + spacing, then `widths` overrides
size = 0x1400                            # padded to this many bytes
output = "build/dialog_font.dat"
widths-output = "build/dialog_widths.dat"  # one width byte per code

Bundled fonts: sumi

katsuji ships sumi, the variable-width faces of the French Final Fantasy IV and the translations that followed it: sumi/8 (menus) and sumi/16 (dialog), in regular, plus bold, book, italic and wicked at 16. Every style of a size draws the same characters. A font names one with builtin instead of png, laid onto the game's own table:

[fonts.dialog]
builtin = "sumi/16"                      # family/size[/style], regular by default
table = "text/game.tbl"                  # each text lands on this table's code
overrides = "fonts/icons.png"            # optional: drawn cells here win (icons, game-only glyphs)
blank = ["0xFD"]                         # optional: codes left empty whatever their text (spacers)
output = "assets/font.dat"
widths = { "0x00" = 3 }

A one-character text of the table that neither sumi nor overrides draws is an error; spaces, control codes (<END>) and the blank codes are not. A blank code is for a cell the game keeps empty though its table names it, like ff4's 1-pixel spacer FD=°. Multi-character texts are never checked: a DTE pair, ... or Lv drawn as one glyph must come from overrides.

A glyph wider than a cell takes several codes, as ff4 and Bahamut Lagoon draw theirs: A0A1=œ in the table cuts sumi's œ across A0 and A1, and every code but the last gets the width that makes the next one follow on (the cut less the engine's 1-pixel gap), so no widths entry is needed. A font's own wide glyphs sit in adjacent cells of its PNG, named the same way in its charmap.tbl, sumi/16 draws Œ and œ only wide, in every style: a table must give them two codes. sumi/8, a menu font, also draws them in one cell, which a table with one code for them gets. A run is only cut when none of its codes is used alone or by another run: ff6's 74C0=« beside C0=° writes two glyphs side by side and is left alone. A game's own widths entry for a joined code wins over the join. A run whose character the font lacks is an error like a one-code text, unless it is a kanji or kana (a game's two-byte codes for its own glyph set). katsuji.fonts.bundled("sumi/8").layout(codes) does the same from Python. A tool that measures or bakes text with a section's font takes it from katsuji.build: font_atlas(config) is the section's cells as built (builtin, overrides, blanks), vwf_font(config) the font with its widths and kerning, from katsuji.config.load(path).fonts[name].

sumi/16/italic leans a pixel per two rows above the baseline, three at most. Its glyphs advance by their upright width, the lean overhanging the next glyph (an engine that ORs glyphs into its buffer draws that as is), so italic text takes about the room of regular. The lean is declared in the style's font.toml (slant = { rows = 2, baseline = 11, max = 3 }) and every width is measured with it taken off, cells from overrides included; a game's widths entry still wins. Computed kerning measures upright glyphs, so a slanted font refuses kerning-candidates: give kerning pairs. End an italic run a few pixels early (ff4: spacers in the closing tag) or its last glyph's top leans into the next one.

sumi/8 draws no accented capitals: an 8x8 cell has no room for them. A table that gives them codes (one shared by the menu and the dialog font) gets the base letter's glyph there, É drawn as E; a glyph in overrides wins. A table that leaves them out writes the base letter instead (É as E, Ç as C), as encoding does for any accented character a table lacks and whose base letter it has. Folding keeps the text's length, so a check for missing characters can't compare lengths: Table.to_bytes(text, strict=True) raises for any character the table lacks instead.

katsuji remap fonts/menu.png --table old.tbl --to new.tbl --cell 8x8 -o fonts/menu_new.png

moves a font's glyphs to the codes another table gives the same texts, keeping a palettized PNG's colours.

katsuji build            # writes every output, paths relative to katsuji.toml
katsuji banner "Tarot" --table text/ff4fr.tbl --font assets/font.dat

Library

  • Atlas: a font drawn as a PNG grid of cells.
  • find_kerning / pair_kerning: pair kerning by collision (one diagonal touch, never side by side).
  • VwfFont: the font file the a816 VWF runtime reads (1bpp rows + width per glyph, kerning pairs, height).
  • render / measure: text set at build time exactly as the runtime sets it.
  • Wrapper: word wrap by pixel width, the game's control codes as data.
  • Window / WindowBuilder: fill text windows; a game's script rules drive them.
  • windows / Paragraph: a game's paragraphs, cut by its script rules, laid out by TextLayout into Windows.
  • katsuji.flow: how well windows read. Judge finds what breaks a window (faults) and counts what reads badly (flaws: turns mid-sentence, a turn for a word or two, lone and half-empty windows, ragged tails), weighed into one cost; Report totals a script, ranks its worst messages and diffs against a saved run.
  • break_by_cost: a sentence filled over lines the way TeX fills a paragraph, short words kept off a line's end (TextLayout(fill=True)).
  • TextLayout / TableMeasure: dialog reflowed to its window; TableMeasure measures script text through its .tbl and font, tags (names) at fixed widths.
  • encode_tiles / colourize: SNES 2bpp / 4bpp planar tiles.
  • text_tiles / pack_runs: static strings pre-rendered to a bank-safe blob.
  • katsuji.script: .tbl text tables (Table), pointer tables and their XML (pointers), pointer formulas (formulas, given the bus mapping by the caller). Moved from a816's script package; a816 reads its .table directive through it. Imports neither numpy nor pillow.
  • katsuji.codecs.sdd1: the S-DD1 decompressor and a compressor whose streams it reads back.
  • katsuji.codecs.lzss: Lzss(...), one flag-byte LZSS per parameter set (window, reference layout, ring buffer, flag order, search, padding); star_ocean's text, dq6's credits and bahamut_lagoon's rooms and graphics are such sets.
  • katsuji.codecs.huffman: trees from counts, canonical codes, bit-packed encode/decode, and nodes / from_children so a game writes and reads its tree in its own table layout (dq6's twin tables).

Grown from ff4's tooling: its five fonts rebuild byte for byte, its wrapping and dialog goldens pass.

uv sync
make check

Metadata

Release files for katsuji 0.7.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for katsuji 0.7.0a1
File Size Uploaded Provenance Actions
katsuji-0.7.0a1.tar.gz 216.2 kB Without provenance Details for katsuji-0.7.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for katsuji 0.7.0a1
File Interpreter ABI Platform Actions
katsuji-0.7.0a1-py3-none-any.whl Python 3 none any Details for katsuji-0.7.0a1-py3-none-any.whl

Total release size: 337.0 kB

Release files / katsuji-0.7.0a1.tar.gz

Download URL katsuji-0.7.0a1.tar.gz
Size 216.2 kB
Tags Source
SHA-256 checksum
How to use checksums
868866979a7e78ed2d31dc0b8086dc88cf3442ed9d0a17b51d469ccdaac8c06e
BLAKE2b-256 checksum
How to use checksums
aa70b5c615c7462004830e981e2f2200d37d2fcd72a5590ad0f7d9c70d214a58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":true,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"7.0.0-1020-azure"}} HTTPX2/2.16.2

Release files / katsuji-0.7.0a1-py3-none-any.whl

Download URL katsuji-0.7.0a1-py3-none-any.whl
Size 120.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad0949acb9abd9e4257a3e838f0d088546bee1be698e0d2ce627a51b803cb712
BLAKE2b-256 checksum
How to use checksums
b75d0d5de73c91fd63a9956dc5cb88ea26160602510f4f91dc096a3d12d527f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":true,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"7.0.0-1020-azure"}} HTTPX2/2.16.2

Security for katsuji 0.7.0a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page