Skip to content

Conversation

Solpatium
Copy link
Contributor

This solves #2564. When user provides a hyphenation logic that splits text on existing text, an additional hyphen is added currently.

Before - hyphens are duplicated:
Duplicated hyphens

After - hyphens are not duplicated:
No duplicated hyphens

Issue reproduction.

I've tested it manually. I don't see existing unit tests for linebreaker.index logic (only for bestFit) and creating them without full understanding of the flow would take me some time.

Copy link

changeset-bot bot commented May 4, 2024

⚠️ No Changeset found

Latest commit: 9d4a161

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

carlobeltrame added a commit to carlobeltrame/react-pdf that referenced this pull request Jul 3, 2025
WIP
Fixes diegomura#3018, was broken since diegomura#2600
Fixes diegomura#1642
Fixes diegomura#2456
Fixes diegomura#2564
Fixes diegomura#2739
Enables better solutions for diegomura#1238, diegomura#1380, diegomura#1416, diegomura#1662

The hyphenation algorithm may change the string (e.g. by removing some characters, namely soft hyphens).
Therefore, calculating the glyphs must come after hyphenation, so that the glyphs match the final string.
-> change to the order of text layout engines in textkit

Hyphenation algorithm should be able to leave soft hyphens in, to indicate that a hyphen should be placed there if the word breaks there.
-> change to the default word hyphenation algorithm in textkit, to split after soft hyphens, but leave the soft hyphens in the syllables

The line breaking algorithm needs to distinguish syllables which end with a soft hyphen from syllables that do not, and only mark a syllable for adding a hyphen in the former case.
-> change to how hyphenated syllables are detected for the linebreaker algorithms in textkit

For the line breaking algorithm, soft hyphens should be considered to have a width of zero, since they are never printed directly (they can only lead to an inserted hyphen if at the end of a line).
-> change to distinguish soft hyphens from hyphens in font, this results the glyph to get a zero advanceWidth

In the best fit line breaking algorithm, the width of the hyphen must be taken into account, in case one is to be inserted at the end of the line.
-> change to the bestFit algorithm in textkit

Soft hyphens in the text should not be rendered as hyphens
-> change to remove all soft hyphens after linebreaking in linebreaker in textkit
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