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

Add backward-compatible wordBreak option that follows css word-break rules #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mkhatib
Copy link

@mkhatib mkhatib commented Apr 12, 2021

Not sure if this will go in, the project doesn't seem to be active. But sending this anyway in case others ran into the same problem with clipping words as I did.

Also for those who wants to use this functionality I've published my own npm package. You can

npm i @mkhatib/layout-bmfont-text
# And if you use this through three-bmfont-text I've also published a version of that that uses this change.
npm i @mkhatib/three-bmfont-text

What kind of change does this PR introduce? (check at least one)

  • Bugfix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Code style update
  • Refactor (refactoring or adding test which isn't a fix or add a feature)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Did you test your solution?

  • I lightly tested it in one browser
  • Also tested it within a project I was already using the package in with no problems
  • I deeply tested it in several browsers
  • I wrote tests around it (unit tests, integration tests, E2E tests)

Problem Description

The library defaulted to break-all behavior when it ran out of space on the line. So A paragraph like this:

Hello World today is going to be beautiful

Would break into:

Hello W
orld tod
ay is goi
ng to be
beautiful

Solution Description

I've added an option users can pass (that defaults to the old break-all behavior so not to break others. But now you can this can render like:

Would break into this with normal:

Hello 
World
today
is
going
to be
beautiful

Would break into this with break-word (only breaks the word if it can't fit on a line by itself):

Hello 
World
today
is
going
to be
beaut
iful

Side Effects, Risks, Impact

  • N/A

Aditional comments:

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