Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyphenation is wrong on 'styled' letters #3037

Open
sandercox opened this issue Jan 14, 2025 · 0 comments
Open

Hyphenation is wrong on 'styled' letters #3037

sandercox opened this issue Jan 14, 2025 · 0 comments

Comments

@sandercox
Copy link

I'm working on a project where I'm styling individual chars of a single word. I do not need any hyphenation and prefer just to break between words on whitespace. But as I want to color individual characters I need to break up words in my text like this:

<Text>This is a great arti<Text style={{ color: "red" }}>c</Text>le</Text>

The hyphenation callbacks currently would get "This", "is", "a", "great", "arti", "c", "le". And would potentially add a break in the middle of the word. In my case I don't want that.

Not the best screenshot but it gives some idea:
image
This is a PDF viewer where you see the hyphenation appear and on top is the same rendered in HTML

(In case you're curious, this is all rendered as wrapped containers (per letter or sometimes combination). For this to work I've been tinkering with React-PDF to add margin/padding support for sub containers. So far it seems to be working quite nicely. Also applying border radius on background of a sub container - once I'm more in a finished state with this I'll create a PR with that code)

Desktop (please complete the following information):

  • OS: Windows
  • Browser Edge
  • React-pdf version latest master
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

No branches or pull requests

1 participant