Skip to content

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

Open
@drount

Description

@drount

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions