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:
+8
-3
@@ -190,10 +190,15 @@
|
||||
|
||||
if config.left-labels {
|
||||
// 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
|
||||
// the character count otherwise
|
||||
// to its left edge
|
||||
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 {
|
||||
config.description-width
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user