diff options
| author | Tom Black <[email protected]> | 2021-02-09 12:35:35 -0600 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2021-02-09 12:35:35 -0600 |
| commit | 2e5062143c6885b27294b5ad2ca8243f699316c9 (patch) | |
| tree | baa93d66b7a10cc43c6c02c92cbf998c35654106 | |
| parent | 5ee186644388c2be6dc4290647d603388525933b (diff) | |
| download | ruby2d-2e5062143c6885b27294b5ad2ca8243f699316c9.tar.gz ruby2d-2e5062143c6885b27294b5ad2ca8243f699316c9.zip | |
Support UTF-8 text rendering
| -rw-r--r-- | ext/ruby2d/text.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/ruby2d/text.c b/ext/ruby2d/text.c index 58d4086..fdd0e1f 100644 --- a/ext/ruby2d/text.c +++ b/ext/ruby2d/text.c @@ -49,7 +49,7 @@ R2D_Text *R2D_CreateText(const char *font, const char *msg, int size) { txt->texture_id = 0; // Save the width and height of the text - TTF_SizeText(txt->font_data, txt->msg, &txt->width, &txt->height); + TTF_SizeUTF8(txt->font_data, txt->msg, &txt->width, &txt->height); return txt; } @@ -61,7 +61,7 @@ R2D_Text *R2D_CreateText(const char *font, const char *msg, int size) { void R2D_SetText(R2D_Text *txt, const char *msg, ...) { if (!txt) return; - // `msg` cannot be an empty string or NULL for TTF_SizeText + // `msg` cannot be an empty string or NULL for TTF_SizeUTF8 if (msg == NULL || strlen(msg) == 0) msg = " "; // Format and store new text string @@ -72,7 +72,7 @@ void R2D_SetText(R2D_Text *txt, const char *msg, ...) { va_end(args); // Save the width and height of the text - TTF_SizeText(txt->font_data, txt->msg, &txt->width, &txt->height); + TTF_SizeUTF8(txt->font_data, txt->msg, &txt->width, &txt->height); // Delete the current texture so a new one can be generated R2D_GL_FreeTexture(&txt->texture_id); @@ -102,9 +102,9 @@ void R2D_DrawText(R2D_Text *txt) { if (txt->texture_id == 0) { SDL_Color color = { 255, 255, 255 }; - txt->surface = TTF_RenderText_Blended(txt->font_data, txt->msg, color); + txt->surface = TTF_RenderUTF8_Blended(txt->font_data, txt->msg, color); if (!txt->surface) { - R2D_Error("TTF_RenderText_Blended", TTF_GetError()); + R2D_Error("TTF_RenderUTF8_Blended", TTF_GetError()); return; } R2D_GL_CreateTexture(&txt->texture_id, GL_RGBA, |
