logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

TTF_MeasureString - Calculate how much of a UTF-8 string will fit in a given width.

Availability

       This function is available since SDL_ttf 3.0.0.

SDL_ttf                                           SDL_ttf 3.2.2                             TTF_MeasureString(3)

Description

       This reports the number of characters that can be rendered before reaching max_width .

       This does not need to render the string to do this calculation.

Function Parameters

font   the font to query.

       text   text to calculate, in UTF-8 encoding.

       length the length of the text, in bytes, or 0 for null terminated text.

       max_width
              maximum width, in pixels, available for the string, or 0 for unbounded width.

       measured_width
              a pointer filled in with the width, in pixels, of the string that will fit, may be NULL.

       measured_length
              a pointer filled in with the length, in bytes, of the string that will fit, may be NULL.

Header File

       Defined in SDL3_ttf/SDL_ttf.h

Name

       TTF_MeasureString - Calculate how much of a UTF-8 string will fit in a given width.

Return Value

       Returns true on success or false on failure; call SDL_GetError() for more information.

Synopsis

#include"SDL3_ttf/SDL_ttf.h"boolTTF_MeasureString(TTF_Font*font,constchar*text,size_tlength,intmax_width,int*measured_width,size_t*measured_length);

Thread Safety

       This function should be called on the thread that created the font.

See Also