Skip to content

TTF_RenderText_Blended creates textures with unpredictable heights? #607

@loftafi

Description

@loftafi

I am not sure if this is expected behavior, or a bug, or user error. I will try to illustrate the problem I am encountering with an image from my app. Consider these buttons:

Image Image

Both buttons have the same physical on screen height. The text within the buttons are also being rendered with the same on screen physical height.

If I understand correctly, the underlying texture surface that is generated by TTF_RenderText_Blended has a different raw pixel height depending on if the text string contains a descender or an ascender.

The first button text does not have a descender, so it ends up with a smaller underlying texture pixel height.

[debug] option λευκὸν = greek (width=283 height=102)
[debug] option μέλαν = greek (width=238 height=117)

It appears that some kind of compensation must be added when outputting text. i.e. "If the text string is missing descenders add descender pixel padding". "If the text string is missing ascenders, add ascender pixel padding"

But I cant find an API that might allow me to check a string for ascenders/descenders and get the compensation height that is needed.

What is the correct way to RenderText and compensate for the varying pixel/texture height it outputs?

--
In case it is applicable, I am linking on Mac with SDL3_ttf.framework and the header folder inside has a header file saying this is version 3.2.2

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