From 69300de296af1ea577e70b2b96ee63467fbc6008 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2024 02:42:09 -0700 Subject: [PATCH] Cleanup and polish on the new TTF_Text API * showfont uses the API to show the caption * showfont now has an -editbox command line option to show the editbox * TTF_MeasureString() returns width in pixels and max_length in bytes * Removed TTF_CreateText_Wrapped() * TTF_SetTextWrapping() has been renamed TTF_SetTextWrapWidth() * TTF_GetTextWrapping() has been renamed TTF_GetTextWrapWidth() Fixes https://github.com/libsdl-org/SDL_ttf/issues/418 --- examples/editbox.c | 5 +- examples/showfont.c | 113 ++++++++------- examples/testapp.c | 6 +- include/SDL3_ttf/SDL_ttf.h | 219 +++++++++++++---------------- src/SDL_ttf.c | 273 ++++++++++++++++--------------------- src/SDL_ttf.sym | 5 +- 6 files changed, 274 insertions(+), 347 deletions(-) diff --git a/examples/editbox.c b/examples/editbox.c index f5f701a9..53f1449a 100644 --- a/examples/editbox.c +++ b/examples/editbox.c @@ -335,7 +335,7 @@ EditBox *EditBox_Create(SDL_Window *window, SDL_Renderer *renderer, TTF_TextEngi edit->window = window; edit->renderer = renderer; edit->font = font; - edit->text = TTF_CreateText_Wrapped(engine, font, NULL, 0, (int)SDL_floorf(rect->w)); + edit->text = TTF_CreateText(engine, font, NULL, 0); if (!edit->text) { EditBox_Destroy(edit); return NULL; @@ -344,6 +344,9 @@ EditBox *EditBox_Create(SDL_Window *window, SDL_Renderer *renderer, TTF_TextEngi edit->highlight1 = -1; edit->highlight2 = -1; + /* Wrap the editbox text within the editbox area */ + TTF_SetTextWrapWidth(edit->text, (int)SDL_floorf(rect->w)); + /* Show the whitespace when wrapping, so it can be edited */ TTF_SetTextWrapWhitespaceVisible(edit->text, true); diff --git a/examples/showfont.c b/examples/showfont.c index 9ff9c6d0..b8944356 100644 --- a/examples/showfont.c +++ b/examples/showfont.c @@ -40,7 +40,7 @@ #define TTF_SHOWFONT_USAGE \ -"Usage: %s [-textengine surface|renderer] [-shaded] [-blended] [-wrapped] [-b] [-i] [-u] [-s] [-outline size] [-hintlight|-hintmono|-hintnone] [-nokerning] [-wrap] [-align left|center|right] [-fgcol r,g,b,a] [-bgcol r,g,b,a] .ttf [ptsize] [text]\n" +"Usage: %s [-textengine surface|renderer] [-shaded] [-blended] [-wrapped] [-b] [-i] [-u] [-s] [-outline size] [-hintlight|-hintmono|-hintnone] [-nokerning] [-wrap] [-align left|center|right] [-fgcol r,g,b,a] [-bgcol r,g,b,a] [-editbox] .ttf [ptsize] [text]\n" typedef enum { @@ -61,8 +61,8 @@ typedef struct { SDL_Surface *window_surface; SDL_Renderer *renderer; TTF_Font *font; - SDL_Texture *caption; - SDL_FRect captionRect; + TTF_Text *caption; + SDL_Rect captionRect; SDL_Texture *message; SDL_FRect messageRect; TextEngine textEngine; @@ -96,7 +96,17 @@ static void DrawScene(Scene *scene) EditBox_Draw(scene->edit); } - SDL_RenderTexture(renderer, scene->caption, NULL, &scene->captionRect); + switch (scene->textEngine) { + case TextEngineSurface: + /* Flush the renderer so we can draw directly to the window surface */ + SDL_FlushRenderer(renderer); + TTF_DrawSurfaceText(scene->caption, scene->captionRect.w, scene->captionRect.h, scene->window_surface); + break; + case TextEngineRenderer: + TTF_DrawRendererText(scene->caption, (float)scene->captionRect.x, (float)scene->captionRect.y); + break; + } + SDL_RenderTexture(renderer, scene->message, NULL, &scene->messageRect); SDL_RenderPresent(renderer); @@ -269,26 +279,20 @@ int main(int argc, char *argv[]) SDL_Color *backcol; SDL_Event event; TTF_TextEngine *engine = NULL; - TextRenderMethod rendermethod; - int renderstyle; - int outline; - int hinting; - int kerning; - int wrap; + TextRenderMethod rendermethod = TextRenderShaded; + int renderstyle = TTF_STYLE_NORMAL; + int outline = 0; + int hinting = TTF_HINTING_NORMAL; + int kerning = 1; + bool wrap = false; TTF_HorizontalAlignment align = TTF_HORIZONTAL_ALIGN_LEFT; - int dump; + bool editbox = false; + bool dump = false; char *message, string[128]; - /* Look for special execution mode */ - dump = 0; - /* Look for special rendering types */ SDL_zero(scene); - rendermethod = TextRenderShaded; - renderstyle = TTF_STYLE_NORMAL; - outline = 0; - hinting = TTF_HINTING_NORMAL; - kerning = 1; - wrap = 0; + scene.textEngine = TextEngineRenderer; + /* Default is black and white */ forecol = &black; backcol = &white; @@ -341,7 +345,7 @@ int main(int argc, char *argv[]) kerning = 0; } else if (SDL_strcmp(argv[i], "-wrap") == 0) { - wrap = 1; + wrap = true; } else if (SDL_strcmp(argv[i], "-align") == 0 && argv[i+1]) { ++i; @@ -356,9 +360,6 @@ int main(int argc, char *argv[]) return (1); } } else - if (SDL_strcmp(argv[i], "-dump") == 0) { - dump = 1; - } else if (SDL_strcmp(argv[i], "-fgcol") == 0 && argv[i+1]) { int r, g, b, a = SDL_ALPHA_OPAQUE; if (SDL_sscanf(argv[++i], "%d,%d,%d,%d", &r, &g, &b, &a) < 3) { @@ -380,6 +381,12 @@ int main(int argc, char *argv[]) backcol->g = (Uint8)g; backcol->b = (Uint8)b; backcol->a = (Uint8)a; + } else + if (SDL_strcmp(argv[i], "-editbox") == 0) { + editbox = true; + } else + if (SDL_strcmp(argv[i], "-dump") == 0) { + dump = true; } else { SDL_Log(TTF_SHOWFONT_USAGE, argv0); return(1); @@ -467,25 +474,33 @@ int main(int argc, char *argv[]) Cleanup(2); } - /* Show which font file we're looking at */ - SDL_snprintf(string, sizeof(string), "Font file: %s", argv[0]); /* possible overflow */ - switch (rendermethod) { - case TextRenderShaded: - text = TTF_RenderText_Shaded(font, string, 0, *forecol, *backcol); + switch (scene.textEngine) { + case TextEngineSurface: + engine = TTF_CreateSurfaceTextEngine(); + if (!engine) { + SDL_Log("Couldn't create surface text engine: %s\n", SDL_GetError()); + Cleanup(2); + } break; - case TextRenderBlended: - text = TTF_RenderText_Blended(font, string, 0, *forecol); + case TextEngineRenderer: + engine = TTF_CreateRendererTextEngine(scene.renderer); + if (!engine) { + SDL_Log("Couldn't create renderer text engine: %s\n", SDL_GetError()); + Cleanup(2); + } + break; + default: break; - } - if (text != NULL) { - scene.captionRect.x = 4.0f; - scene.captionRect.y = 4.0f; - scene.captionRect.w = (float)text->w; - scene.captionRect.h = (float)text->h; - scene.caption = SDL_CreateTextureFromSurface(scene.renderer, text); - SDL_DestroySurface(text); } + /* Show which font file we're looking at */ + SDL_snprintf(string, sizeof(string), "Font file: %s", argv[0]); /* possible overflow */ + scene.caption = TTF_CreateText(engine, font, string, 0); + TTF_SetTextColor(scene.caption, forecol->r, forecol->g, forecol->b, forecol->a); + scene.captionRect.x = 4; + scene.captionRect.y = 4; + TTF_GetTextSize(scene.caption, &scene.captionRect.w, &scene.captionRect.h); + /* Render and center the message */ if (argc > 2) { message = argv[2]; @@ -521,23 +536,7 @@ int main(int argc, char *argv[]) SDL_Log("Font is generally %d big, and string is %d big\n", TTF_GetFontHeight(font), text->h); - switch (scene.textEngine) { - case TextEngineSurface: - engine = TTF_CreateSurfaceTextEngine(); - if (!engine) { - SDL_Log("Couldn't create surface text engine: %s\n", SDL_GetError()); - } - break; - case TextEngineRenderer: - engine = TTF_CreateRendererTextEngine(scene.renderer); - if (!engine) { - SDL_Log("Couldn't create renderer text engine: %s\n", SDL_GetError()); - } - break; - default: - break; - } - if (engine) { + if (editbox) { scene.textRect.x = 8.0f; scene.textRect.y = scene.captionRect.y + scene.captionRect.h + 4.0f; scene.textRect.w = WIDTH / 2 - scene.textRect.x * 2; @@ -601,7 +600,7 @@ int main(int argc, char *argv[]) default: break; } - SDL_DestroyTexture(scene.caption); + TTF_DestroyText(scene.caption); SDL_DestroyTexture(scene.message); Cleanup(0); diff --git a/examples/testapp.c b/examples/testapp.c index 7950b276..57cd4590 100644 --- a/examples/testapp.c +++ b/examples/testapp.c @@ -1064,9 +1064,11 @@ int main(void) break; } } else if (textengine_mode == 1) { - text_obj = TTF_CreateText_Wrapped(engine_surface, font, text, 0, wrap_size); + text_obj = TTF_CreateText(engine_surface, font, text, 0); + TTF_SetTextWrapWidth(text_obj, wrap_size); } else { - text_obj = TTF_CreateText_Wrapped(engine_renderer, font, text, 0, wrap_size); + text_obj = TTF_CreateText(engine_renderer, font, text, 0); + TTF_SetTextWrapWidth(text_obj, wrap_size); } if (print_elapsed_ticks) { diff --git a/include/SDL3_ttf/SDL_ttf.h b/include/SDL3_ttf/SDL_ttf.h index 3671fd08..43043c50 100644 --- a/include/SDL3_ttf/SDL_ttf.h +++ b/include/SDL3_ttf/SDL_ttf.h @@ -993,15 +993,15 @@ extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSize(TTF_Font *font, const char *t * specified string will take to fully render. * * Text is wrapped to multiple lines on line endings and on word boundaries if - * it extends beyond `wrapLength` in pixels. + * it extends beyond `wrap_width` in pixels. * - * If wrapLength is 0, this function will only wrap on newline characters. + * If wrap_width is 0, this function will only wrap on newline characters. * * \param font the font to query. * \param text text to calculate, in UTF-8 encoding. * \param length the length of the text, in bytes, or 0 for null terminated * text. - * \param wrapLength the maximum width or 0 to wrap on newline characters. + * \param wrap_width the maximum width or 0 to wrap on newline characters. * \param w will be filled with width, in pixels, on return. * \param h will be filled with height, in pixels, on return. * \returns true on success or false on failure; call SDL_GetError() for more @@ -1012,13 +1012,13 @@ extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSize(TTF_Font *font, const char *t * * \since This function is available since SDL_ttf 3.0.0. */ -extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSizeWrapped(TTF_Font *font, const char *text, size_t length, int wrapLength, int *w, int *h); +extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSizeWrapped(TTF_Font *font, const char *text, size_t length, int wrap_width, int *w, int *h); /** * 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 - * `measure_width`. + * `max_width`. * * This does not need to render the string to do this calculation. * @@ -1026,10 +1026,9 @@ extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSizeWrapped(TTF_Font *font, const * \param text text to calculate, in UTF-8 encoding. * \param length the length of the text, in bytes, or 0 for null terminated * text. - * \param measure_width maximum width, in pixels, available for the string. - * \param extent on return, filled with latest calculated width. - * \param count on return, filled with number of characters that can be - * rendered. + * \param max_width maximum width, in pixels, available for the string, or 0 for unbounded width. + * \param measured_width a pointer filled in with the width, in pixels, of the string that will fit, may be NULL. + * \param 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. * @@ -1038,7 +1037,7 @@ extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSizeWrapped(TTF_Font *font, const * * \since This function is available since SDL_ttf 3.0.0. */ -extern SDL_DECLSPEC bool SDLCALL TTF_MeasureString(TTF_Font *font, const char *text, size_t length, int measure_width, int *extent, int *count); +extern SDL_DECLSPEC bool SDLCALL TTF_MeasureString(TTF_Font *font, const char *text, size_t length, int max_width, int *measured_width, size_t *measured_length); /** * Render UTF-8 text at high quality to a new 8-bit surface. @@ -1083,9 +1082,9 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font, * surface, or NULL if there was an error. * * Text is wrapped to multiple lines on line endings and on word boundaries if - * it extends beyond `wrapLength` in pixels. + * it extends beyond `wrap_width` in pixels. * - * If wrapLength is 0, this function will only wrap on newline characters. + * If wrap_width is 0, this function will only wrap on newline characters. * * \param font the font to render with. * \param text text to render, in UTF-8 encoding. @@ -1093,7 +1092,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font, * text. * \param fg the foreground color for the text. * \param bg the background color for the text. - * \param wrapLength the maximum width of the text surface or 0 to wrap on + * \param wrap_width the maximum width of the text surface or 0 to wrap on * newline characters. * \returns a new 8-bit, palettized surface, or NULL if there was an error. * @@ -1106,7 +1105,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font, * \sa TTF_RenderText_LCD_Wrapped * \sa TTF_RenderText_Shaded */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrapLength); +extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width); /** * Render a single UNICODE codepoint at high quality to a new 8-bit surface. @@ -1175,16 +1174,16 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font, * new surface, or NULL if there was an error. * * Text is wrapped to multiple lines on line endings and on word boundaries if - * it extends beyond `wrapLength` in pixels. + * it extends beyond `wrap_width` in pixels. * - * If wrapLength is 0, this function will only wrap on newline characters. + * If wrap_width is 0, this function will only wrap on newline characters. * * \param font the font to render with. * \param text text to render, in UTF-8 encoding. * \param length the length of the text, in bytes, or 0 for null terminated * text. * \param fg the foreground color for the text. - * \param wrapLength the maximum width of the text surface or 0 to wrap on + * \param wrap_width the maximum width of the text surface or 0 to wrap on * newline characters. * \returns a new 32-bit, ARGB surface, or NULL if there was an error. * @@ -1197,7 +1196,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font, * \sa TTF_RenderText_LCD_Wrapped * \sa TTF_RenderText_Shaded_Wrapped */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrapLength); +extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrap_width); /** * Render a single UNICODE codepoint at high quality to a new ARGB surface. @@ -1266,9 +1265,9 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD(TTF_Font *font, con * returns the new surface, or NULL if there was an error. * * Text is wrapped to multiple lines on line endings and on word boundaries if - * it extends beyond `wrapLength` in pixels. + * it extends beyond `wrap_width` in pixels. * - * If wrapLength is 0, this function will only wrap on newline characters. + * If wrap_width is 0, this function will only wrap on newline characters. * * \param font the font to render with. * \param text text to render, in UTF-8 encoding. @@ -1276,7 +1275,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD(TTF_Font *font, con * text. * \param fg the foreground color for the text. * \param bg the background color for the text. - * \param wrapLength the maximum width of the text surface or 0 to wrap on + * \param wrap_width the maximum width of the text surface or 0 to wrap on * newline characters. * \returns a new 32-bit, ARGB surface, or NULL if there was an error. * @@ -1289,7 +1288,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD(TTF_Font *font, con * \sa TTF_RenderText_LCD * \sa TTF_RenderText_Shaded_Wrapped */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrapLength); +extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width); /** * Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB @@ -1334,7 +1333,6 @@ typedef struct TTF_TextData TTF_TextData; * \since This struct is available since SDL_ttf 3.0.0. * * \sa TTF_CreateText - * \sa TTF_CreateText_Wrapped * \sa TTF_GetTextProperties * \sa TTF_DestroyText */ @@ -1386,7 +1384,6 @@ extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateSurfaceTextEngine(void); * * \sa TTF_CreateSurfaceTextEngine * \sa TTF_CreateText - * \sa TTF_CreateText_Wrapped */ extern SDL_DECLSPEC bool SDLCALL TTF_DrawSurfaceText(TTF_Text *text, int x, int y, SDL_Surface *surface); @@ -1446,7 +1443,6 @@ extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateRendererTextEngine(SDL_Re * * \sa TTF_CreateRendererTextEngine * \sa TTF_CreateText - * \sa TTF_CreateText_Wrapped */ extern SDL_DECLSPEC bool SDLCALL TTF_DrawRendererText(TTF_Text *text, float x, float y); @@ -1471,9 +1467,6 @@ extern SDL_DECLSPEC void SDLCALL TTF_DestroyRendererTextEngine(TTF_TextEngine *e /** * Create a text object from UTF-8 text and a text engine. * - * This function is equivalent to `TTF_CreateText_Wrapped(engine, font, text, - * 0)` and will wrap on newline characters. - * * \param engine the text engine to use when creating the text object, may be * NULL. * \param font the font to render with. @@ -1488,40 +1481,10 @@ extern SDL_DECLSPEC void SDLCALL TTF_DestroyRendererTextEngine(TTF_TextEngine *e * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_CreateText_Wrapped * \sa TTF_DestroyText */ extern SDL_DECLSPEC TTF_Text * SDLCALL TTF_CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length); -/** - * Create a text object from word-wrapped UTF-8 text and a text engine. - * - * Text is wrapped to multiple lines on line endings and on word boundaries if - * it extends beyond `wrapLength` in pixels. - * - * If wrapLength is 0, this function will only wrap on newline characters. - * - * \param engine the text engine to use when creating the text object, may be - * NULL. - * \param font the font to render with. - * \param text the text to use, in UTF-8 encoding. - * \param length the length of the text, in bytes, or 0 for null terminated - * text. - * \param wrapLength the maximum width of the text surface or 0 to wrap on - * newline characters. - * \returns a TTF_Text object or NULL on failure; call SDL_GetError() for more - * information. - * - * \threadsafety This function should be called on the thread that created the - * font. - * - * \since This function is available since SDL_ttf 3.0.0. - * - * \sa TTF_CreateText - * \sa TTF_DestroyText - */ -extern SDL_DECLSPEC TTF_Text * SDLCALL TTF_CreateText_Wrapped(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length, int wrapLength); - /** * Get the properties associated with a text object. * @@ -1738,12 +1701,11 @@ extern SDL_DECLSPEC bool SDLCALL TTF_SetTextPosition(TTF_Text *text, int x, int extern SDL_DECLSPEC bool SDLCALL TTF_GetTextPosition(TTF_Text *text, int *x, int *y); /** - * Set the UTF-8 text used by a text object. + * Set whether wrapping is enabled on a text object. * * \param text the TTF_Text to modify. - * \param string the UTF-8 text to use, may be NULL. - * \param length the length of the text, in bytes, or 0 for null terminated - * text. + * \param wrap_width the maximum width in pixels, 0 to wrap on newline + * characters. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1752,23 +1714,16 @@ extern SDL_DECLSPEC bool SDLCALL TTF_GetTextPosition(TTF_Text *text, int *x, int * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_AppendTextString - * \sa TTF_DeleteTextString - * \sa TTF_InsertTextString + * \sa TTF_GetTextWrapWidth */ -extern SDL_DECLSPEC bool SDLCALL TTF_SetTextString(TTF_Text *text, const char *string, size_t length); +extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapWidth(TTF_Text *text, int wrap_width); /** - * Insert UTF-8 text into a text object. + * Get whether wrapping is enabled on a text object. * - * \param text the TTF_Text to modify. - * \param offset the offset, in bytes, from the beginning of the string if >= - * 0, the offset from the end of the string if < 0. Note that - * this does not do UTF-8 validation, so you should only insert - * at UTF-8 sequence boundaries. - * \param string the UTF-8 text to insert. - * \param length the length of the text, in bytes, or 0 for null terminated - * text. + * \param text the TTF_Text to query. + * \param wrap_width a pointer filled in with the maximum width in pixels or 0 + * if the text is being wrapped on newline characters. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1777,19 +1732,21 @@ extern SDL_DECLSPEC bool SDLCALL TTF_SetTextString(TTF_Text *text, const char *s * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_AppendTextString - * \sa TTF_DeleteTextString - * \sa TTF_SetTextString + * \sa TTF_SetTextWrapWidth */ -extern SDL_DECLSPEC bool SDLCALL TTF_InsertTextString(TTF_Text *text, int offset, const char *string, size_t length); +extern SDL_DECLSPEC bool SDLCALL TTF_GetTextWrapWidth(TTF_Text *text, int *wrap_width); /** - * Append UTF-8 text to a text object. + * Set whether whitespace should be visible when wrapping a text object. + * + * If the whitespace is visible, it will take up space for purposes of + * alignment and wrapping. This is good for editing, but looks better when + * centered or aligned if whitespace around line wrapping is hidden. This + * defaults false. * * \param text the TTF_Text to modify. - * \param string the UTF-8 text to insert. - * \param length the length of the text, in bytes, or 0 for null terminated - * text. + * \param visible true to show whitespace when wrapping text, false to hide + * it. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1798,42 +1755,33 @@ extern SDL_DECLSPEC bool SDLCALL TTF_InsertTextString(TTF_Text *text, int offset * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_DeleteTextString - * \sa TTF_InsertTextString - * \sa TTF_SetTextString + * \sa TTF_TextWrapWhitespaceVisible */ -extern SDL_DECLSPEC bool SDLCALL TTF_AppendTextString(TTF_Text *text, const char *string, size_t length); +extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapWhitespaceVisible(TTF_Text *text, bool visible); /** - * Delete UTF-8 text from a text object. + * Return whether whitespace is shown when wrapping a text object. * - * \param text the TTF_Text to modify. - * \param offset the offset, in bytes, from the beginning of the string if >= - * 0, the offset from the end of the string if < 0. Note that - * this does not do UTF-8 validation, so you should only delete - * at UTF-8 sequence boundaries. - * \param length the length of text to delete, in bytes, or -1 for the - * remainder of the string. - * \returns true on success or false on failure; call SDL_GetError() for more - * information. + * \param text the TTF_Text to query. + * \returns true if whitespace is shown when wrapping text, or false + * otherwise. * * \threadsafety This function should be called on the thread that created the * text. * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_AppendTextString - * \sa TTF_InsertTextString - * \sa TTF_SetTextString + * \sa TTF_SetTextWrapWhitespaceVisible */ -extern SDL_DECLSPEC bool SDLCALL TTF_DeleteTextString(TTF_Text *text, int offset, int length); +extern SDL_DECLSPEC bool SDLCALL TTF_TextWrapWhitespaceVisible(TTF_Text *text); /** - * Set whether wrapping is enabled on a text object. + * Set the UTF-8 text used by a text object. * * \param text the TTF_Text to modify. - * \param wrapLength the maximum width in pixels, 0 to wrap on newline - * characters. + * \param string the UTF-8 text to use, may be NULL. + * \param length the length of the text, in bytes, or 0 for null terminated + * text. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1842,16 +1790,23 @@ extern SDL_DECLSPEC bool SDLCALL TTF_DeleteTextString(TTF_Text *text, int offset * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_GetTextWrapping + * \sa TTF_AppendTextString + * \sa TTF_DeleteTextString + * \sa TTF_InsertTextString */ -extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapping(TTF_Text *text, int wrapLength); +extern SDL_DECLSPEC bool SDLCALL TTF_SetTextString(TTF_Text *text, const char *string, size_t length); /** - * Get whether wrapping is enabled on a text object. + * Insert UTF-8 text into a text object. * - * \param text the TTF_Text to query. - * \param wrapLength a pointer filled in with the maximum width in pixels or 0 - * if the text is being wrapped on newline characters. + * \param text the TTF_Text to modify. + * \param offset the offset, in bytes, from the beginning of the string if >= + * 0, the offset from the end of the string if < 0. Note that + * this does not do UTF-8 validation, so you should only insert + * at UTF-8 sequence boundaries. + * \param string the UTF-8 text to insert. + * \param length the length of the text, in bytes, or 0 for null terminated + * text. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1860,21 +1815,19 @@ extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapping(TTF_Text *text, int wrapLen * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_SetTextWrapping + * \sa TTF_AppendTextString + * \sa TTF_DeleteTextString + * \sa TTF_SetTextString */ -extern SDL_DECLSPEC bool SDLCALL TTF_GetTextWrapping(TTF_Text *text, int *wrapLength); +extern SDL_DECLSPEC bool SDLCALL TTF_InsertTextString(TTF_Text *text, int offset, const char *string, size_t length); /** - * Set whether whitespace should be visible when wrapping a text object. - * - * If the whitespace is visible, it will take up space for purposes of - * alignment and wrapping. This is good for editing, but looks better when - * centered or aligned if whitespace around line wrapping is hidden. This - * defaults false. + * Append UTF-8 text to a text object. * * \param text the TTF_Text to modify. - * \param visible true to show whitespace when wrapping text, false to hide - * it. + * \param string the UTF-8 text to insert. + * \param length the length of the text, in bytes, or 0 for null terminated + * text. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1883,25 +1836,35 @@ extern SDL_DECLSPEC bool SDLCALL TTF_GetTextWrapping(TTF_Text *text, int *wrapLe * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_TextWrapWhitespaceVisible + * \sa TTF_DeleteTextString + * \sa TTF_InsertTextString + * \sa TTF_SetTextString */ -extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapWhitespaceVisible(TTF_Text *text, bool visible); +extern SDL_DECLSPEC bool SDLCALL TTF_AppendTextString(TTF_Text *text, const char *string, size_t length); /** - * Return whether whitespace is shown when wrapping a text object. + * Delete UTF-8 text from a text object. * - * \param text the TTF_Text to query. - * \returns true if whitespace is shown when wrapping text, or false - * otherwise. + * \param text the TTF_Text to modify. + * \param offset the offset, in bytes, from the beginning of the string if >= + * 0, the offset from the end of the string if < 0. Note that + * this does not do UTF-8 validation, so you should only delete + * at UTF-8 sequence boundaries. + * \param length the length of text to delete, in bytes, or -1 for the + * remainder of the string. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. * * \threadsafety This function should be called on the thread that created the * text. * * \since This function is available since SDL_ttf 3.0.0. * - * \sa TTF_SetTextWrapWhitespaceVisible + * \sa TTF_AppendTextString + * \sa TTF_InsertTextString + * \sa TTF_SetTextString */ -extern SDL_DECLSPEC bool SDLCALL TTF_TextWrapWhitespaceVisible(TTF_Text *text); +extern SDL_DECLSPEC bool SDLCALL TTF_DeleteTextString(TTF_Text *text, int offset, int length); /** * Get the size of a text object. diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c index 37b04bb3..6908a729 100644 --- a/src/SDL_ttf.c +++ b/src/SDL_ttf.c @@ -344,7 +344,7 @@ typedef enum { } render_mode_t; #define NO_MEASUREMENT \ - 0, NULL, NULL + false, 0, NULL, NULL static bool Find_GlyphByIndex(TTF_Font *font, FT_UInt idx, int want_pixmap, int want_color, int want_lcd, int want_subpixel, int translation, c_glyph **out_glyph, TTF_Image **out_image); @@ -2917,7 +2917,7 @@ bool TTF_GetGlyphKerning(TTF_Font *font, Uint32 previous_ch, Uint32 ch, int *ker return true; } -static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, int *w, int *h, int *xstart, int *ystart, int measure_width, int *extent, int *count) +static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, int *w, int *h, int *xstart, int *ystart, bool measure_width, int max_width, int *measured_width, size_t *measured_length) { int x = 0; int pos_x, pos_y; @@ -2941,16 +2941,18 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i #endif int prev_advance = 0; - // Measurement mode - int char_count = 0; - int current_width = 0; - if (w) { *w = 0; } if (h) { *h = 0; } + if (measured_width) { + *measured_width = 0; + } + if (measured_length) { + *measured_length = 0; + } TTF_CHECK_INITIALIZED(false); TTF_CHECK_POINTER("font", font, false); @@ -2959,6 +2961,9 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i if (!length) { length = SDL_strlen(text); } + if (measured_length) { + *measured_length = length; + } maxy = font->height; @@ -3116,14 +3121,13 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i if (measure_width) { int cw = SDL_max(maxx, FT_FLOOR(x + prev_advance)) - minx; cw += 2 * font->outline; - if (cw <= measure_width) { - current_width = cw; - char_count += 1; - } - if (cw >= measure_width) { - if (cw > measure_width) { - // The last character didn't fit - font->pos_len -= 1; + if (!max_width || cw <= max_width) { + if (measured_width) { + *measured_width = cw; + } + } else { + if (measured_length) { + *measured_length = (size_t)offset; } break; } @@ -3164,30 +3168,6 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i *h += 2 * font->outline; } - // Measurement mode - if (measure_width) { - if (extent) { - *extent = current_width; - } - if (count) { -#if TTF_USE_HARFBUZZ - if ((unsigned int)char_count == glyph_count) { - /* The higher level code doesn't know about ligatures, - * so if we've covered all the glyphs, report the full - * string length. - * - * If we have to line wrap somewhere in the middle, we - * might be off by the number of ligatures, but there - * isn't an easy way around that without using hb_buffer - * at that level instead. - */ - *count = (int)SDL_utf8strlen(text); - } else -#endif - *count = char_count; - } - } - #if TTF_USE_HARFBUZZ if (hb_buffer) { hb_buffer_destroy(hb_buffer); @@ -3209,9 +3189,9 @@ bool TTF_GetStringSize(TTF_Font *font, const char *text, size_t length, int *w, return TTF_Size_Internal(font, text, length, w, h, NULL, NULL, NO_MEASUREMENT); } -bool TTF_MeasureString(TTF_Font *font, const char *text, size_t length, int width, int *extent, int *count) +bool TTF_MeasureString(TTF_Font *font, const char *text, size_t length, int max_width, int *measured_width, size_t *measured_length) { - return TTF_Size_Internal(font, text, length, NULL, NULL, NULL, NULL, width, extent, count); + return TTF_Size_Internal(font, text, length, NULL, NULL, NULL, NULL, true, max_width, measured_width, measured_length); } static SDL_Surface* TTF_Render_Internal(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, const render_mode_t render_mode) @@ -3346,7 +3326,7 @@ static bool CharacterIsNewLine(Uint32 c) return false; } -static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int xoffset, int wrapLength, bool trim_whitespace, TTF_Line **lines, int *num_lines, int *w, int *h) +static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int xoffset, int wrap_width, bool trim_whitespace, TTF_Line **lines, int *num_lines, int *w, int *h) { int width, height; int i, numLines = 0, rowHeight; @@ -3363,8 +3343,8 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int TTF_CHECK_INITIALIZED(false); TTF_CHECK_POINTER("font", font, false); TTF_CHECK_POINTER("text", text, false); - if (wrapLength < 0) { - return SDL_InvalidParamError("wrapLength"); + if (wrap_width < 0) { + return SDL_InvalidParamError("wrap_width"); } if (!length) { @@ -3382,16 +3362,15 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int size_t left = length; do { - int extent = 0, max_count = 0, char_count = 0; const char *save_text = NULL; size_t save_length = (size_t)(-1); if (numLines >= maxNumLines) { TTF_Line *new_lines; - if (wrapLength == 0) { + if (wrap_width == 0) { maxNumLines += 32; } else { - maxNumLines += (width / wrapLength) + 1; + maxNumLines += (width / wrap_width) + 1; } new_lines = (TTF_Line *)SDL_realloc(strLines, maxNumLines * sizeof (*strLines)); if (new_lines == NULL) { @@ -3420,59 +3399,52 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int strLines[numLines].length = left; ++numLines; - int measure_width = wrapLength; - if (measure_width > 0) { - measure_width = SDL_max(measure_width - xoffset, 1); + int max_width = wrap_width; + if (max_width > 0) { + max_width = SDL_max(max_width - xoffset, 1); } - if (!TTF_MeasureString(font, spot, left, measure_width, &extent, &max_count)) { + size_t max_length = 0; + if (!TTF_MeasureString(font, spot, left, max_width, NULL, &max_length)) { SDL_SetError("Error measure text"); goto done; } - if (wrapLength != 0) { + if (wrap_width != 0) { // The first line can be empty if we have a text position that's // at the edge of the wrap length, but subsequent lines should have // at least one character per line. - if (max_count == 0 && numLines > 1) { - max_count = 1; + if (max_length == 0 && numLines > 1) { + max_length = 1; } } - if (max_count > 0) { - while (left > 0) { - int is_delim; - Uint32 c = SDL_StepUTF8(&spot, &left); + const char *end = spot + max_length; + while (spot < end) { + int is_delim; + Uint32 c = SDL_StepUTF8(&spot, &left); - if (c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED) { - continue; - } - - char_count += 1; + if (c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED) { + continue; + } - // With wrapLength == 0, normal text rendering but newline aware - is_delim = (wrapLength > 0) ? CharacterIsDelimiter(c) : CharacterIsNewLine(c); + // With wrap_width == 0, normal text rendering but newline aware + is_delim = (wrap_width > 0) ? CharacterIsDelimiter(c) : CharacterIsNewLine(c); - // Record last delimiter position - if (is_delim) { - save_text = spot; - save_length = left; - // Break, if new line - if (c == '\n' || (c == '\r' && *spot != '\n')) { - break; - } - } - - // Break, if reach the limit - if (char_count == max_count) { + // Record last delimiter position + if (is_delim) { + save_text = spot; + save_length = left; + // Break, if new line + if (c == '\n' || (c == '\r' && *spot != '\n')) { break; } } + } - // Cut at last delimiter/new lines, otherwise in the middle of the word - if (save_text && left > 0) { - spot = save_text; - left = save_length; - } + // Cut at last delimiter/new lines, otherwise in the middle of the word + if (save_text && left > 0) { + spot = save_text; + left = save_length; } // First line is complete, start the next at offset 0 @@ -3508,7 +3480,7 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int rowHeight = SDL_max(height, font->lineskip); - if (wrapLength == 0) { + if (wrap_width == 0) { // Find the max of all line lengths if (numLines > 1) { width = 0; @@ -3524,10 +3496,10 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int } } else { if (numLines <= 1 && font->horizontal_align == TTF_HORIZONTAL_ALIGN_LEFT) { - // Don't go above wrapLength if you have only 1 line which hasn't been cut - width = SDL_min((int)wrapLength, width); + // Don't go above wrap_width if you have only 1 line which hasn't been cut + width = SDL_min((int)wrap_width, width); } else { - width = wrapLength; + width = wrap_width; } } height = rowHeight + font->lineskip * (numLines - 1); @@ -3556,12 +3528,12 @@ static bool GetWrappedLines(TTF_Font *font, const char *text, size_t length, int return result; } -bool TTF_GetStringSizeWrapped(TTF_Font *font, const char *text, size_t length, int wrapLength, int *w, int *h) +bool TTF_GetStringSizeWrapped(TTF_Font *font, const char *text, size_t length, int wrap_width, int *w, int *h) { - return GetWrappedLines(font, text, length, 0, wrapLength, true, NULL, NULL, w, h); + return GetWrappedLines(font, text, length, 0, wrap_width, true, NULL, NULL, w, h); } -static SDL_Surface* TTF_Render_Wrapped_Internal(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrapLength, const render_mode_t render_mode) +static SDL_Surface* TTF_Render_Wrapped_Internal(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width, const render_mode_t render_mode) { Uint32 color; int width, height; @@ -3569,7 +3541,7 @@ static SDL_Surface* TTF_Render_Wrapped_Internal(TTF_Font *font, const char *text int i, numLines = 0; TTF_Line *strLines = NULL; - if (!GetWrappedLines(font, text, length, 0, wrapLength, true, &strLines, &numLines, &width, &height)) { + if (!GetWrappedLines(font, text, length, 0, wrap_width, true, &strLines, &numLines, &width, &height)) { return NULL; } @@ -3656,19 +3628,19 @@ static SDL_Surface* TTF_Render_Wrapped_Internal(TTF_Font *font, const char *text return NULL; } -SDL_Surface* TTF_RenderText_Shaded_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrapLength) +SDL_Surface* TTF_RenderText_Shaded_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width) { - return TTF_Render_Wrapped_Internal(font, text, length, fg, bg, wrapLength, RENDER_SHADED); + return TTF_Render_Wrapped_Internal(font, text, length, fg, bg, wrap_width, RENDER_SHADED); } -SDL_Surface* TTF_RenderText_Blended_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrapLength) +SDL_Surface* TTF_RenderText_Blended_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrap_width) { - return TTF_Render_Wrapped_Internal(font, text, length, fg, fg /* unused */, wrapLength, RENDER_BLENDED); + return TTF_Render_Wrapped_Internal(font, text, length, fg, fg /* unused */, wrap_width, RENDER_BLENDED); } -SDL_Surface* TTF_RenderText_LCD_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrapLength) +SDL_Surface* TTF_RenderText_LCD_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width) { - return TTF_Render_Wrapped_Internal(font, text, length, fg, bg, wrapLength, RENDER_LCD); + return TTF_Render_Wrapped_Internal(font, text, length, fg, bg, wrap_width, RENDER_LCD); } struct TTF_TextLayout @@ -3685,7 +3657,7 @@ typedef struct TTF_InternalText TTF_TextLayout layout; } TTF_InternalText; -static TTF_Text *CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length, int wrapLength) +TTF_Text *TTF_CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length) { if (engine && engine->version < sizeof(*engine)) { // Update this to handle older versions of this interface @@ -3708,7 +3680,6 @@ static TTF_Text *CreateText(TTF_TextEngine *engine, TTF_Font *font, const char * result->internal->color.a = 1.0f; result->internal->needs_layout_update = true; result->internal->engine = engine; - result->internal->layout->wrap_length = wrapLength; if (text && *text) { if (length == 0) { length = SDL_strlen(text); @@ -3729,16 +3700,6 @@ static TTF_Text *CreateText(TTF_TextEngine *engine, TTF_Font *font, const char * return result; } -TTF_Text *TTF_CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length) -{ - return CreateText(engine, font, text, length, 0); -} - -TTF_Text *TTF_CreateText_Wrapped(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length, int wrapLength) -{ - return CreateText(engine, font, text, length, wrapLength); -} - static int SDLCALL SortClusters(const void *a, const void *b) { TTF_SubString *A = (TTF_SubString *)a; @@ -3833,7 +3794,7 @@ static int CalculateClusterLengths(TTF_Text *text, TTF_SubString *clusters, int static bool LayoutText(TTF_Text *text) { TTF_Font *font = text->internal->font; - int wrapLength = text->internal->layout->wrap_length; + int wrap_width = text->internal->layout->wrap_length; bool trim_whitespace = !text->internal->layout->wrap_whitespace_visible; size_t length = SDL_strlen(text->text); int i, width = 0, height = 0, numLines = 0; @@ -3845,7 +3806,7 @@ static bool LayoutText(TTF_Text *text) int *lines = NULL; bool result = false; - if (!GetWrappedLines(font, text->text, length, text->internal->x, wrapLength, trim_whitespace, &strLines, &numLines, &width, &height)) { + if (!GetWrappedLines(font, text->text, length, text->internal->x, wrap_width, trim_whitespace, &strLines, &numLines, &width, &height)) { return true; } height += text->internal->y; @@ -4188,6 +4149,53 @@ bool TTF_GetTextPosition(TTF_Text *text, int *x, int *y) return true; } +bool TTF_SetTextWrapWidth(TTF_Text *text, int wrap_width) +{ + TTF_CHECK_POINTER("text", text, false); + + if (wrap_width == text->internal->layout->wrap_length) { + return true; + } + + text->internal->layout->wrap_length = SDL_max(wrap_width, 0); + text->internal->needs_layout_update = true; + return true; +} + +bool TTF_GetTextWrapWidth(TTF_Text *text, int *wrap_width) +{ + if (wrap_width) { + *wrap_width = 0; + } + + TTF_CHECK_POINTER("text", text, false); + + if (wrap_width) { + *wrap_width = text->internal->layout->wrap_length; + } + return true; +} + +bool TTF_SetTextWrapWhitespaceVisible(TTF_Text *text, bool visible) +{ + TTF_CHECK_POINTER("text", text, false); + + if (visible == text->internal->layout->wrap_whitespace_visible) { + return true; + } + + text->internal->layout->wrap_whitespace_visible = visible; + text->internal->needs_layout_update = true; + return true; +} + +bool TTF_TextWrapWhitespaceVisible(TTF_Text *text) +{ + TTF_CHECK_POINTER("text", text, false); + + return text->internal->layout->wrap_whitespace_visible; +} + bool TTF_SetTextString(TTF_Text *text, const char *string, size_t length) { TTF_CHECK_POINTER("text", text, false); @@ -4310,53 +4318,6 @@ bool TTF_DeleteTextString(TTF_Text *text, int offset, int length) return true; } -bool TTF_SetTextWrapping(TTF_Text *text, int wrapLength) -{ - TTF_CHECK_POINTER("text", text, false); - - if (wrapLength == text->internal->layout->wrap_length) { - return true; - } - - text->internal->layout->wrap_length = SDL_max(wrapLength, 0); - text->internal->needs_layout_update = true; - return true; -} - -bool TTF_GetTextWrapping(TTF_Text *text, int *wrapLength) -{ - if (wrapLength) { - *wrapLength = 0; - } - - TTF_CHECK_POINTER("text", text, false); - - if (wrapLength) { - *wrapLength = text->internal->layout->wrap_length; - } - return true; -} - -bool TTF_SetTextWrapWhitespaceVisible(TTF_Text *text, bool visible) -{ - TTF_CHECK_POINTER("text", text, false); - - if (visible == text->internal->layout->wrap_whitespace_visible) { - return true; - } - - text->internal->layout->wrap_whitespace_visible = visible; - text->internal->needs_layout_update = true; - return true; -} - -bool TTF_GetTextWrapSpaceTrimming(TTF_Text *text) -{ - TTF_CHECK_POINTER("text", text, false); - - return text->internal->layout->wrap_whitespace_visible; -} - bool TTF_GetTextSize(TTF_Text *text, int *w, int *h) { if (w) { diff --git a/src/SDL_ttf.sym b/src/SDL_ttf.sym index 4aab9e0f..a0e2d867 100644 --- a/src/SDL_ttf.sym +++ b/src/SDL_ttf.sym @@ -5,7 +5,6 @@ SDL3_ttf_0.0.0 { TTF_CreateRendererTextEngine; TTF_CreateSurfaceTextEngine; TTF_CreateText; - TTF_CreateText_Wrapped; TTF_DeleteTextString; TTF_DestroyRendererTextEngine; TTF_DestroySurfaceTextEngine; @@ -53,7 +52,7 @@ SDL3_ttf_0.0.0 { TTF_GetTextSubStringForLine; TTF_GetTextSubStringForPoint; TTF_GetTextSubStringsForRange; - TTF_GetTextWrapping; + TTF_GetTextWrapWidth; TTF_Init; TTF_InsertTextString; TTF_MeasureString; @@ -89,7 +88,7 @@ SDL3_ttf_0.0.0 { TTF_SetTextPosition; TTF_SetTextString; TTF_SetTextWrapWhitespaceVisible; - TTF_SetTextWrapping; + TTF_SetTextWrapWidth; TTF_TextWrapWhitespaceVisible; TTF_UpdateText; TTF_Version;