-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Difference with text wrapping betwen 1.1.9 -> 1.2.0 and 1.3.0 #5081
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already. |
This was introduced in #4712 fixing #4652. I think the current behaviour is too excessive, causing hyphens to appear on almost every single line. Not to mention, as @westriel here experienced, being a breaking change. I'd prefer it if the hyphenation only works on single words longer than the width of the bounding box. That being said, I'm open to adding an extra parameter for hyphenation (single word longer than bounding box only) and revert the default behaviour to what it was in 1.1.9. An extra note, hyphenation is only one of the mechanisms for achieving justified text, without adjusting word spacing it will look like the provided example here where every line ends in hyphen and the hyphen breaks occur in weird places. Hyphenation in typesetting should also only happen in specific place in a word and not just trim off excess to the next line. |
I'd like to work on this as a first issue :) I think adding two new typography functions, textHyphens() and textWrap() would cover both of these cases. textWrap() can take the constants LINEBREAK or WORDBREAK, with LINEBREAK breaking the line before a word that would overflow (as seen in 1.1.9), and WORDBREAK breaking the word if it would overflow (as in 1.2.0 and 1.3.0). textHyphens() can take a boolean for true or false and control whether a hyphen is inserted or not when a word is broken. I personally had a project where I noticed the hyphens appearing in the latest version and was actually printing binary code as text, so hyphenation made no sense but breaking that long string of 0s and 1s and wrapping it without a grammatically sensible break was totally fine for me. Since determining hyphen placement is so tricky across languages, at least being able to control hyphen-on-break or no-hyphen-on-break should provide a good amount of flexibility from the current version. |
I think as a quick fix, we can revert to behaviour in 1.1.9 first to address the breaking change then we can explore alternative solutions to the original problem. @lawreka Being able to control whether to add hyphens or not is a good idea especially when considering languages that does not use spaces to separate words, those languages will have hyphens at the end of every line now. |
@limzykenneth I've opened a PR for the simple text wrap reversion, and will work on adding the hyphenation and text wrapping options as separate improvements – I might actually finish them before release of 1.3.1 if it's not going to happen until March 21. |
gonna reopen this since there's more work planned here! |
How would this new feature help increase access to p5.js?
I believe that this feature would help allow the text function to do what the programmer wants it to do and relieve programmers from confusion about differences in p5 sketches, as I myself was making something along with a friend. I had made my sketch before version 1.2.0 was released and my friend after, we did very similar things and our code was producing different output and confused us for quite a while.
Most appropriate sub-area of p5.js?
Feature enhancement details:
There is a difference between p5's text function when using 5 parameters to create a textbox so that the text wraps along multiple lines.
In p5 version 1.1.9 the text wrapping works on a word by word basis (will always create a line break on a whitespace and not in the middle of a word), example here.
In versions 1.2.0 and 1.3.0 this functionality changed and now the text wrapping will split in the middle of the text, creating a hyphen on the end of the line, examples here for 1.2.0 and here for 1.3.0.
My request for feature enhancement would be a way to switch between these two modes of text wrapping. Perhaps add another parameter to the text function? This seems like a kind of clunky solution but at the moment I can't think of anything better. Does this feature already exist? If so how would I switch between the modes? Thanks for your consideration!
The text was updated successfully, but these errors were encountered: