Skip to content

Respect charSpace when wrapping text with maxWidth#3996

Open
cycsmail wants to merge 1 commit into
parallax:masterfrom
cycsmail:charspace-maxwidth
Open

Respect charSpace when wrapping text with maxWidth#3996
cycsmail wants to merge 1 commit into
parallax:masterfrom
cycsmail:charspace-maxwidth

Conversation

@cycsmail

Copy link
Copy Markdown

When maxWidth is set, doc.text() wraps via splitTextToSize(), but the per-call charSpace never reached the width measurement used for wrapping, so text wrapped as if charSpace were 0 and then overflowed maxWidth once the spacing was rendered.

  • Forward charSpace from text() into splitTextToSize()
  • Thread it through the per-paragraph options and add charSpace / fontSize per character in the standard-font width branch (same units the embedded-font branch already uses)
  • Add a spec asserting wrapped lines fit within maxWidth and that a wider charSpace wraps into more lines

No public API change, so types/index.d.ts is untouched. The new spec fails without the fix and passes with it; npm run test-node passes (468 specs, 4 pre-existing pending) and prettier is clean on the changed files.

Fixes #3299

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.

charSpace and maxWidth in doc.text() : charSpace > 0 and maxWidth is not respected

1 participant