8000 Fix preceding char getting cut off during word wrap and add option to disable word wrapping by miguelblix99 · Pull Request #1274 · HeapsIO/heaps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix preceding char getting cut off during word wrap and add option to disable word wrapping #1274

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 i 8000 n to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

miguelblix99
Copy link

This will solve the issue where a word gets broken into a new line and the previous char on the new line gets skipped. There is also now the option to disable mid word splitting.

h2d/Text.hx Outdated
@@ -371,10 +382,11 @@ class Text extends Drawable {
}
else wLastSep = size;
}
else if( (x + esize + letterSpacing) - wLastSep > maxWidth ) {
else if( (x + esize + letterSpacing) - wLastSep > (maxWidth-esize) && wordWrap ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should reverse the order of checks, and put wordWrap first, as first check becomes redundant when it's off.

Comment on lines +388 to +389
restPos = i;
x -= esize + letterSpacing;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iirc it was i+1 because word wrap was triggering on spaces, and during wrap we want to skip the space character. There should be a charset.isSpace check to determine if character should be skipped or not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure i follow entirely as this is still handled in the previous condition, which means that no spaces will be included in the lines array during a linebreak as stated here:

if( lineBreak && (size > maxWidth || (!breakFound && size + afterData > maxWidth)) ) {
					newline = true;
					if( font.charset.isSpace(cc) ){
						lines.push(text.substr(restPos, i - restPos));
						e = null;
					}else{
						lines.push(text.substr(restPos, i + 1 - restPos));
					}
					restPos = i + 1;
				}

What i modified is part of the else block where the character is not a space nor any other break character.

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
0