Skip to content

Feature addition: text along path - #1136

Open
philocalyst wants to merge 4 commits into
cetz-package:masterfrom
philocalyst:feature/text-along-path
Open

philocalyst wants to merge 4 commits into
cetz-package:masterfrom
philocalyst:feature/text-along-path

Conversation

@philocalyst

@philocalyst philocalyst commented Sep 9, 2026

Copy link
Copy Markdown

Closes #395

This PR adds rigid text and content placement along named/inline paths.

1

What changed

  • Measures line and Bézier paths by arc length.
  • Supports grapheme-level text placement with preserved styles.
  • Keeps opaque content such as math and boxes intact.
  • Supports alignment, tracking, spacing modes, reversal, upright text, overflow handling, and kerning.
  • Handles sharp corners with padding, skipping, or direct traversal.
  • Reuses draw.content styles and resolved metrics.
  • Adds tests for path measurement, Bézier scaling, corners, overflow, wrappers, and rendering.
  • Adds gallery and manual documentation entries.

My notes on design

I heavily referenced Typst's existing approach of separating measurement form layout, reusing resolved content styles. The arc-length sampler uses adapative subdivision + Newton refinement, which mirrors the spirit of the work done in
Design notes within Typst PR #3847 (typst/typst#3847).

The layout code maintains opaque content rigid, avoiding pretending that independently shaped grapheme clusters can effectively preserve cross-place ligatures.

Now, on the note about FIXED, as of right now Typst doesn't have a general way of doing deeper text pathing manipulation. I looked into doing some WASM black magic, but hey, that's not really what the project is about! So instead I just got a PR up at Typst, which if/when merged will make that part very easy to add.

@johannes-wolf

Copy link
Copy Markdown
Member

Thank you, this is a great addition! I will review the PR soon :).

@philocalyst

Copy link
Copy Markdown
Author

Thank you! Going to go in and fix the CI in the meantime :)

Aside: was hapily surprised how mostly readable the typst code is, this being the first time I tried to write something serious in it, but let me know if any sections are too hard to parse!

@philocalyst

Copy link
Copy Markdown
Author

Okay hm it seems to fail on master too, so you know!

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.

Text along/on a path

2 participants