fix: measure the description width instead of estimating it

With left-labels a description is placed by subtracting its width from
desc-x. That width was estimated as half the font size per character,
which undershoots Ubuntu Mono's advance of 0.56em by 12%, so the leader
line struck through the last letter of every label, as it does on the
manual's own cover page. Proportional fonts were off by more.

render is now a context block, so the text can be measured instead. The
font has to be passed explicitly: the set rule at the top of render is
not in scope for a measure further down the same context block.
This commit is contained in:
2026-08-25 14:51:19 +02:00
parent ac759746f3
commit f4c3fc7f61
+8 -3
View File
@@ -190,10 +190,15 @@
if config.left-labels { if config.left-labels {
// desc-x is the right edge of the label when they are on the left, so shift // desc-x is the right edge of the label when they are on the left, so shift
// to its left edge: exactly the box width when wrapping, an estimate from // to its left edge
// the character count otherwise
txt-x -= if config.description-width == none { txt-x -= if config.description-width == none {
range_.description.len() * config.default-font-size / 2pt // the set rule in render is not in scope here, so measure the text with
// the font it will be drawn in
measure(text(
range_.description,
font: config.default-font-family,
size: config.default-font-size
)).width.pt()
} else { } else {
config.description-width config.description-width
} }