mirror of
https://github.com/nicbarker/clay.git
synced 2025-09-18 04:26:18 +00:00
[Renderers/SDL] Font sizing is ignored (#444)
This commit is contained in:
parent
74f0ffbe26
commit
f97cb9ea10
|
@ -32,6 +32,7 @@ static inline Clay_Dimensions SDL_MeasureText(Clay_StringSlice text, Clay_TextEl
|
||||||
TTF_Font *font = fonts[config->fontId];
|
TTF_Font *font = fonts[config->fontId];
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
|
TTF_SetFontSize(font, config->fontSize);
|
||||||
if (!TTF_GetStringSize(font, text.chars, text.length, &width, &height)) {
|
if (!TTF_GetStringSize(font, text.chars, text.length, &width, &height)) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Failed to measure text: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Failed to measure text: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ static Clay_Dimensions SDL2_MeasureText(Clay_StringSlice text, Clay_TextElementC
|
||||||
SDL2_Font *fonts = (SDL2_Font*)userData;
|
SDL2_Font *fonts = (SDL2_Font*)userData;
|
||||||
|
|
||||||
TTF_Font *font = fonts[config->fontId].font;
|
TTF_Font *font = fonts[config->fontId].font;
|
||||||
|
TTF_SetFontSize(font, config->fontSize);
|
||||||
char *chars = (char *)calloc(text.length + 1, 1);
|
char *chars = (char *)calloc(text.length + 1, 1);
|
||||||
memcpy(chars, text.chars, text.length);
|
memcpy(chars, text.chars, text.length);
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
@ -294,6 +295,7 @@ static void Clay_SDL2_Render(SDL_Renderer *renderer, Clay_RenderCommandArray ren
|
||||||
char *cloned = (char *)calloc(config->stringContents.length + 1, 1);
|
char *cloned = (char *)calloc(config->stringContents.length + 1, 1);
|
||||||
memcpy(cloned, config->stringContents.chars, config->stringContents.length);
|
memcpy(cloned, config->stringContents.chars, config->stringContents.length);
|
||||||
TTF_Font* font = fonts[config->fontId].font;
|
TTF_Font* font = fonts[config->fontId].font;
|
||||||
|
TTF_SetFontSize(font, config->fontSize);
|
||||||
SDL_Surface *surface = TTF_RenderUTF8_Blended(font, cloned, (SDL_Color) {
|
SDL_Surface *surface = TTF_RenderUTF8_Blended(font, cloned, (SDL_Color) {
|
||||||
.r = (Uint8)config->textColor.r,
|
.r = (Uint8)config->textColor.r,
|
||||||
.g = (Uint8)config->textColor.g,
|
.g = (Uint8)config->textColor.g,
|
||||||
|
|
|
@ -164,6 +164,7 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
||||||
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
||||||
Clay_TextRenderData *config = &rcmd->renderData.text;
|
Clay_TextRenderData *config = &rcmd->renderData.text;
|
||||||
TTF_Font *font = rendererData->fonts[config->fontId];
|
TTF_Font *font = rendererData->fonts[config->fontId];
|
||||||
|
TTF_SetFontSize(font, config->fontSize);
|
||||||
TTF_Text *text = TTF_CreateText(rendererData->textEngine, font, config->stringContents.chars, config->stringContents.length);
|
TTF_Text *text = TTF_CreateText(rendererData->textEngine, font, config->stringContents.chars, config->stringContents.length);
|
||||||
TTF_SetTextColor(text, config->textColor.r, config->textColor.g, config->textColor.b, config->textColor.a);
|
TTF_SetTextColor(text, config->textColor.r, config->textColor.g, config->textColor.b, config->textColor.a);
|
||||||
TTF_DrawRendererText(text, rect.x, rect.y);
|
TTF_DrawRendererText(text, rect.x, rect.y);
|
||||||
|
|
Loading…
Reference in a new issue