Skip to content

feat(content): read TextMesh Pro font assets from object tables - #86

Merged
nichinichisou0609 merged 3 commits into
redesign/depotfrom
redesign/tmp-assets
Oct 15, 2026
Merged

nichinichisou0609 merged 3 commits into
redesign/depotfrom
redesign/tmp-assets

Conversation

@nichinichisou0609

Copy link
Copy Markdown
Collaborator

Adds an object-table reader for TextMesh Pro font assets, so product stages can build font data and glyph pages from unity.export object tables (nnnotes.objects/1) without a Unity reader.

  • unity/tmpfont.py: the font code works on a font asset protocol (FontAsset). The character lookup is FontLookup. Font settings records and the table document are shared functions (font_record, load_listed, font_document). export_fonts takes the font lookup alone.
  • unity/export.py: the texel packing of TexelPacker is shared functions, plus MemoryPacker, which packs textures held in memory and returns the page records with their PNG bytes.
  • content/tmpassets.py: Texture, Font and FontSet read from an object table; build_font_settings gives the font settings table of the table's font assets; missing_glyph_character reads the table's TMP Settings resource.
  • Tests: tests/content/test_tmpassets.py on synthetic object tables. The test font builder moves to tests/helpers/fonts.py.

The existing Exporter-based font settings and font export give the same output as before.

🤖 Generated with Claude Code

nichinichisou0609 and others added 3 commits October 16, 2026 02:50
The TextMesh Pro font code now works on any font asset that has the
fields it reads, not only on assets read through an Exporter:

- tmpfont.FontAsset is the protocol of a font asset; FontLookup holds
  the character lookup over a fallback chain, and FontSet (Exporter)
  builds on it.
- font_cmap reads a source font's character map and variation
  sequences; font_record, listed_fonts, load_listed and font_document
  build the font settings table from any FontSettings that records the
  path ids it reads (BuiltFontSettings).
- text_material_records takes the material lookup as a function;
  text_materials keeps the Exporter form. export_fonts takes the font
  lookup alone and reads each font's default material from the asset.
- export.py splits TexelPacker.build into texel_rows, pack_group,
  texture_block and array_block, and adds MemoryPacker: the same
  packing over textures held in memory, returning the page records and
  their PNG bytes.

The test font builder moves to tests/helpers/fonts.py. Outputs of the
existing font settings and font export paths are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
content/tmpassets.py reads the font data of an object table
(nnnotes.objects/1) with the records the Exporter path gives:

- Texture: a Texture2D's record and its RGBA texels from its PNG image.
- Font and FontSet: a TMP_FontAsset with its atlas pages, source font
  file, default material and fallback chain, with the TMP character
  lookup of tmpfont.FontLookup.
- TableFontSettings and build_font_settings: the font settings table
  (fontsettings.FORMAT) of the listed font assets of the table.
- missing_glyph_character: the missing glyph character of the table's
  TMP Settings resource.

The glyph tables and runtime glyphs come from tmpfont.export_fonts with
an export.MemoryPacker, so a product stage can build glyph pages
without a Unity reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synthetic object tables check the texture records and texels, the font
asset fields, fallback chains and lookup, the material records, the
font settings table, the missing glyph character and unresolved
references, and the block layout and page bytes of MemoryPacker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nichinichisou0609
nichinichisou0609 merged commit 0a240ce into redesign/depot Oct 15, 2026
8 checks passed
@nichinichisou0609
nichinichisou0609 deleted the redesign/tmp-assets branch October 15, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant