Add description-width config option #21

Open
dromell wants to merge 1 commits from dromell/rivet-typst:feat/description-width into dev
First-time contributor

Problem

Descriptions and values are drawn as a single line that never wraps. A diagram is
scaled to fit the width it is rendered into, so the longest label is what decides
that scale — one long description makes the whole diagram, bit cells and indices
included, shrink until that line fits.

Beforeconfig.config(), in a document 700pt wide:

before.png

Afterconfig.config(description-width: 460), same schema, same page:

after.png

What the option does

description-width wraps labels at that width, so the length of a description no
longer decides how large the diagram is drawn. Values wrap at the same right edge as
the description they belong to. It composes with left-labels,
force-descs-on-side and ltr-bits.

Wrapping means a label is no longer one line tall, so labels can no longer be spaced
by a fixed line height. Each is now offset by the height it actually occupies,
measured before it is placed. That is why render gained a context block.

Compatibility

The option defaults to none, which keeps the single-line behaviour on the original
code paths.

## Problem Descriptions and values are drawn as a single line that never wraps. A diagram is scaled to fit the width it is rendered into, so the longest label is what decides that scale — one long description makes the whole diagram, bit cells and indices included, shrink until that line fits. **Before** — `config.config()`, in a document 700pt wide: ![before.png](/attachments/901466e1-e6f1-4c8f-ad91-2a1812e50342) **After** — `config.config(description-width: 460)`, same schema, same page: ![after.png](/attachments/52fe356d-336f-4270-9688-96b650d1e985) ## What the option does `description-width` wraps labels at that width, so the length of a description no longer decides how large the diagram is drawn. Values wrap at the same right edge as the description they belong to. It composes with `left-labels`, `force-descs-on-side` and `ltr-bits`. Wrapping means a label is no longer one line tall, so labels can no longer be spaced by a fixed line height. Each is now offset by the height it actually occupies, measured before it is placed. That is why `render` gained a `context` block. ## Compatibility The option defaults to `none`, which keeps the single-line behaviour on the original code paths.
dromell added 1 commit 2026-08-18 12:14:56 +00:00
Descriptions and values are drawn as a single line that never wraps.
Because a diagram is scaled to fit the width it is rendered into, the
longest label is what decides that scale: one long description makes the
whole diagram -- bit cells, indices and every other label with it --
shrink until that line fits. A register whose fields carry a sentence
each is then unreadable at any page width, and since each diagram is
measured on its own, a document full of them renders every one at a
different size.

Setting description-width wraps labels at that width instead, so the
length of a description no longer decides how large the diagram is
drawn. Values wrap at the same right edge as the description they belong
to, and the option composes with left-labels, force-descs-on-side and
ltr-bits.

Wrapping means a label is no longer one line tall, so labels can no
longer be spaced by a fixed line height. Each is now offset by the
height it actually occupies, measured before it is placed, which is why
render gained a context block.

The option defaults to none, which keeps the single-line behaviour on
the original code paths. With it unset every diagram in the gallery
renders byte-identical to before.
HEL added the enhancement label 2026-08-18 12:32:59 +00:00
Author
First-time contributor

Any thoughts on this change?

Any thoughts on this change?
Owner

Yes it looks very nice
I've skimmed the changes and it seems alright to me, I've just been quite busy this week and haven't had the time to review it
Will do asap

Yes it looks very nice I've skimmed the changes and it seems alright to me, I've just been quite busy this week and haven't had the time to review it Will do asap
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u https://git.kb28.ch/dromell/rivet-typst feat/description-width:dromell-feat/description-width
git checkout dromell-feat/description-width
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: HEL/rivet-typst#21