Skip to content

Fix non-breaking space (U+00A0) handling in text justification#1473

Merged
andreasrosdal merged 3 commits intomasterfrom
copilot/fix-issue-1454
Feb 16, 2026
Merged

Fix non-breaking space (U+00A0) handling in text justification#1473
andreasrosdal merged 3 commits intomasterfrom
copilot/fix-issue-1454

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Description of the new Feature/Bugfix

Non-breaking spaces (U+00A0) were treated as regular characters during justification, remaining fixed width while only regular spaces (U+0020) stretched with setSpaceCharRatio > 1. This broke Polish typesetting conventions where single-letter words must use non-breaking spaces.

Changes:

  • PdfLine.numberOfSpaces(): Count both U+0020 and U+00A0
  • PdfDocument.indexOfSpace(): New helper to locate both space types
  • PdfDocument.writeLineToContent(): Use indexOfSpace() for CJK/special encoding chunks

Both space types now stretch uniformly during justification.

Unit-Tests for the new Feature/Bugfix

  • Unit-Tests added to reproduce the bug
  • Unit-Tests added to the added feature

Three test cases covering: non-breaking spaces only, mixed spaces, and high ratio scenarios.

Compatibilities Issues

None. Changes are additive to space character detection logic.

Your real name

Copilot SWE Agent

Testing details

Run NonBreakingSpaceJustificationTest - generates PDFs in target/ showing proper stretching of non-breaking spaces under justification.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: andreasrosdal <259156774+andreasrosdal@users.noreply.github.com>
@andreasrosdal andreasrosdal changed the title [WIP] Fix issue with incorrect PDF rendering Fix non-breaking space (U+00A0) not being stretched during text justification when using ColumnText.setSpaceCharRatio Feb 16, 2026
Co-authored-by: andreasrosdal <259156774+andreasrosdal@users.noreply.github.com>
@sonarqubecloud
Copy link

Copilot AI changed the title Fix non-breaking space (U+00A0) not being stretched during text justification when using ColumnText.setSpaceCharRatio Fix non-breaking space (U+00A0) handling in text justification Feb 16, 2026
Copilot AI requested a review from andreasrosdal February 16, 2026 10:52
@andreasrosdal andreasrosdal marked this pull request as ready for review February 16, 2026 10:52
@andreasrosdal andreasrosdal merged commit a9710ba into master Feb 16, 2026
14 checks passed
@andreasrosdal andreasrosdal deleted the copilot/fix-issue-1454 branch February 16, 2026 10:57
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

Comments