Skip to content

officecanvas: words of different block-level elements are never one text box - #455

Merged
tannevaled merged 1 commit into
mainfrom
officecanvas-split-boxes
Nov 29, 2026
Merged

tannevaled merged 1 commit into
mainfrom
officecanvas-split-boxes

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Problem

officecanvas.Canvas.Glyphs joined a run to the previous text shape when it was on the same baseline and less than two font sizes away. The items of a flex row on one baseline (a pill, an arrow, a pill) are within that distance, so the arrow's text went into the pill's text box. Found through go-slides' editable PPTX export, where the arrow rendered inside the pill border.

Fix

Canvas implements paint.StructuredCanvas (Mark). It records the nearest non-phrasing element of the node each text belongs to and joins runs only when that element is the same (or unknown: list markers, generated content, artifacts). Inline elements (b, span, a, ...) still flow with their parent, so a line with bold words stays one box.

Known limits: text generated by ::before in the next flex item still joins (artifact marks carry no node); and the mark carries the node, not its style, so a span made a flex item or block by CSS is still taken for inline.

Tests

TestFlexItemsAreSeparateTextBoxes fails without the change (verified by reverting officecanvas.go) and passes with it. go test ./... is green.

🤖 Generated with Claude Code

…ext box

A canvas joined a word to the previous text shape whenever it sat on the
same baseline a short gap away. In a flex row that gap is the pill's
padding, border and the row's gap, so the arrow after a pill joined the
pill's text box and an editable PPTX drew it inside the pill.

Canvas now implements paint.StructuredCanvas, notes the nearest
non-phrasing element of each Mark, and joins only text of the same one.

Known limit: an artifact mark carries no node (paint.Mark), so text a
::before generates in the next flex item still joins the item before it.

handlayout-waiver: not a go-widgets application — officecanvas text-run join condition, existing line plus one clause; false positive reported

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 02a3c91 into main Nov 29, 2026
13 checks passed
@tannevaled
tannevaled deleted the officecanvas-split-boxes branch November 29, 2026 13:47
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.

1 participant