Repository navigation
feat(content): read TextMesh Pro font assets from object tables - #86
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an object-table reader for TextMesh Pro font assets, so product stages can build font data and glyph pages from
unity.exportobject tables (nnnotes.objects/1) without a Unity reader.unity/tmpfont.py: the font code works on a font asset protocol (FontAsset). The character lookup isFontLookup. Font settings records and the table document are shared functions (font_record,load_listed,font_document).export_fontstakes the font lookup alone.unity/export.py: the texel packing ofTexelPackeris shared functions, plusMemoryPacker, which packs textures held in memory and returns the page records with their PNG bytes.content/tmpassets.py:Texture,FontandFontSetread from an object table;build_font_settingsgives the font settings table of the table's font assets;missing_glyph_characterreads the table's TMP Settings resource.tests/content/test_tmpassets.pyon synthetic object tables. The test font builder moves totests/helpers/fonts.py.The existing Exporter-based font settings and font export give the same output as before.
🤖 Generated with Claude Code