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

drawStringMaxWidth doesn't return 0 even though text fits #375

Open
drount opened this issue Sep 11, 2022 · 0 comments
Open

drawStringMaxWidth doesn't return 0 even though text fits #375

drount opened this issue Sep 11, 2022 · 0 comments

Comments

@drount
Copy link

drount commented Sep 11, 2022

if (drawStringResult == 0 || (yMove + lineNumber * lineHeight) >= this->height()) // text did not fit on screen

Hello,

in every drawStringInternal there in an increase in line height so the last check:
(yMove + lineNumber * lineHeight) >= this->height()

will always be true if the texts fill all the lines of the screen.

In order to solve, you can break the loop just after drawing the string:

drawStringResult = drawStringInternal(xMove, yMove + (lineNumber++) * lineHeight , &text[lastDrawnPos], preferredBreakpoint - lastDrawnPos, widthAtBreakpoint, true);
if (drawStringResult == 0) // we are past the display already?
        break;
if (firstLineChars == 0)
       firstLineChars = preferredBreakpoint;

and return:

if ((drawStringResult + lastDrawnPos) < length) {
	return firstLineChars ;
}
return 0;
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