Skip to main content

TTF_MeasureString

Function TTF_MeasureString 

Source
pub unsafe extern "C" fn TTF_MeasureString(
    font: *mut TTF_Font,
    text: *const c_char,
    length: usize,
    max_width: c_int,
    measured_width: *mut c_int,
    measured_length: *mut usize,
) -> bool
Expand description

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

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.

Parameter: font the font to query.

Parameter: text text to calculate, in UTF-8 encoding.

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

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

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

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

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

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

Available Since: This function is available since SDL_ttf 3.0.0.