Skip to content

TTF_GetTextSize defaults to wrapping width for any multiline text #576

@lightspeedlucas

Description

@lightspeedlucas

For any TTF_Text that includes line breaks and uses a non-zero wrapping width, its total width as reported by TTF_GetTextSize will always be equal to the wrapping width, regardless of actual text size. Example:

TTF_Text* text = TTF_CreateText(text_engine, font, "a\nb\nc", 0);
TTF_SetTextWrapWidth(text, 999999);

int width = 0;
int height = 0;
TTF_GetTextSize(text, &width, &height);

assert(width == 999999);

It seems this branch based on wrap_width is the culprit, as it ends up assuming all multiline wrapping texts must've reached the wrapping width, which isn't always true.

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