Skip to content

M7: inline symbols in text - #627

Merged
bflatastic merged 1 commit into
storytold:mainfrom
Haven-King:feat/text-engine/text-inline-graphics
Oct 8, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
Haven-King:feat/text-engine/text-inline-graphics

Conversation

@Haven-King

Copy link
Copy Markdown
Contributor

What and why

Some type needs small pieces of art inside a line, such as icons in instructions, UI glyphs in documentation, or symbols in game and map legends. VectorCraft could only fake this with symbol-font glyphs and separately positioned objects.

  • Model: TextRun.inline: Option<InlineArt> holds the symbol, scale and baseline_shift; the run is a single U+FFFC.
  • Layout:
    • Placement:
      • The art is laid out as one glyph whose advance is the art width plus tracking.
      • It's scaled to scale × the font size and centred on the cap height.
      • Tall art makes its line taller.
    • Interactions:
      • It breaks like a word.
      • It follows bidi reordering in right-to-left text.
      • It counts as a character of its run's size for Character Alignment and Top-to-Top leading.
      • It never hangs as burasagari punctuation.
    • TextLayout.inlines records each placement.
  • Drawing and export:
    • The canvas draws the symbol art inside the text's transparency group.
    • SVG keeps the text live and adds a <use> for each graphic.
    • PDF draws the art as vector paths.
    • A missing symbol keeps an empty one-em slot and is logged once.
  • Editing:
    • Runs never merge into or split an inline run.
    • Backspace and Delete remove a graphic whole; copy keeps it.
    • Create Outlines turns it into a symbol instance.
    • Redefine Symbol resizes it.
  • Translations: the menu item is translated in every catalog (cs, es, it, ja, pt-br, ru, zh-hans, zh-hant).
  • Known gaps:
    • In vertical type the art lies on its side instead of standing upright.
    • symbol.list instance counts and Select All Instances ignore inline uses.
    • The menu item has no dialog for scale or shift.

How it was tested

  • crates/text/src/tests_inline.rs:
    • Advance, placement, shift and tracking; a missing symbol; tall art.
    • Wrapping; type on a path and vertical type; snapping; editing; copy/paste; malformed runs.
    • Right-to-left placement, Character Alignment and Top-to-Top leading.
  • crates/engine/src/tests_inline.rs: the command; junk parameters; Type tool with Backspace and undo; Redefine/Delete Symbol; save/open; Create Outlines.
  • crates/engine/tests/inline_text.rs: canvas pixels and opacity; SVG and PDF export that re-import and render.
  • command_sweep junk cases; native round trip. All symbol art in tests is drawn in code.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm). All 7 steps pass on b843fe8, every test included.
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how). Clippy's no-panic lints pass on b843fe8.
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md (no new assets).

Document symbols placed inline in a run of type (beyond Illustrator; like
InDesign inline anchored objects): TextRun.inline holds the symbol, scale and
shift; the run is one U+FFFC laid out as a glyph sized to the art, centred on
the cap height. text.insertInline and Type > Insert Inline Symbol; editing
keeps the graphic whole; canvas, SVG (<use>) and PDF draw the art; Create
Outlines turns it into a symbol instance.
bflatastic added a commit that referenced this pull request Oct 8, 2026
Land #627 (inline symbols in text) and #628 (comment cleanup)
@bflatastic
bflatastic merged commit f365dc1 into storytold:main Oct 8, 2026
@bflatastic

Copy link
Copy Markdown
Member

Merged via #630, thanks @Haven-King! Inline symbols are a neat addition for instructions, legends and UI docs. Having them flow, wrap and reorder like a glyph, follow symbol edits, and export to SVG and PDF makes them first-class. I inserted a dot symbol into a line with text.insertInline and it rendered in place; undo removed it cleanly.

NoobsDeSroobs pushed a commit to NoobsDeSroobs/vectorcraft that referenced this pull request Oct 8, 2026
…inline field

storytold#627 added TextRun::inline while storytold#631 was open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants