Skip to content

Textboxes - #598

Merged
teunbrand merged 8 commits into
posit-dev:mainfrom
teunbrand:textbox
Nov 10, 2026
Merged

teunbrand merged 8 commits into
posit-dev:mainfrom
teunbrand:textbox

Conversation

@teunbrand

Copy link
Copy Markdown
Collaborator

This PR aims to fix an entry in #530.

It adds a new colour aesthetic to text layer: box.
This new name avoids the colour propagation rule to stroke / fill, and keeps fill for the glyphs as before.
We avoid this rule because having the same box background and glyph fill is unreadable.
stroke has separate purposes in boxless and boxed layers: in boxless layers it remains the glyph outline, in boxed layers it becomes the border colour.
This means that colour => 'red' will simultaneously set the glyph paint and border stroke.
This was done deliberately because glyph outlines and text boxes both solve the same problem of contrasting text against a background so it remains readable, and having both a textbox and outline is likely an accident (or niche deliberate choice I don't understand).

Also coming with boxes is a linewidth for the borders, deliberately chosen to be a setting instead of a mappable aesthetic.
There is also padding and radius to control the spacing of the text to borders and corner rounding. I'd like to have these support relative metrics as well, but it'd have to be supported by hephaestus first.

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly, fine but some questions around naming and how it gets resolved

Comment thread doc/syntax/layer/type/text.qmd Outdated
* `stroke` The colour of the contour lines of glyphs or text box borders. Typically kept blank.
* `fill` The colour of the glyphs.
* `colour` Shorthand for setting `stroke` and `fill` simultaneously.
* `box` The colour of the text box. Setting this aesthetic switches on text boxes. Setting `null` (the default) does not draw text boxes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe background fits better with the upcoming table PR?

Also, we discussed having all of this resolved by the alias mechanism in color. Can you put some words on whether you tried that and why it didn't work

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with using background instead of box.
I'm opposed to including it in the aliasing mechanism: you invariably want the box to have a different colour than the text. If color sets both, you're in for pain because you cannot distinguish the text from the background. Currently color sets the text glyph colour and their outline (in regular text mode) or textbox border (in textbox mode). The reason why stroke changes meaning depending on the mode is because both outlines and textboxes are different solutions to the same problem (distinguishing text from whatever is behind the text). Stacking these solutions by having both an outline and a textbox does more bad than good, so forcing one or the other (or neither) is intended behaviour.

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand
teunbrand merged commit 0361918 into posit-dev:main Nov 10, 2026
23 checks passed
@teunbrand
teunbrand deleted the textbox branch November 10, 2026 11:28
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