#include <stdio.h>
#include <string.h>
+#include "math/rect.h"
#include "sdl/renderer.h"
#include "sprite_font.h"
#include "system/error.h"
int sprite_font_render_text(const sprite_font_t *sprite_font,
SDL_Renderer *renderer,
vec_t position,
- int size,
+ float size,
color_t color,
const char *text)
{
}
const size_t text_size = strlen(text);
- const int px = (int) roundf(position.x);
- const int py = (int) roundf(position.y);
for (size_t i = 0; i < text_size; ++i) {
const SDL_Rect char_rect = sprite_font_char_rect(sprite_font, text[i]);
- const SDL_Rect dest_rect = {
- .x = px + CHAR_WIDTH * (int) i * size,
- .y = py,
- .w = char_rect.w * size,
- .h = char_rect.h * size
- };
+ const SDL_Rect dest_rect = rect_for_sdl(
+ rect(
+ position.x + (float) CHAR_WIDTH * (float) i * size,
+ position.y,
+ (float) char_rect.w * size,
+ (float) char_rect.h * size));
if (SDL_RenderCopy(renderer, sprite_font->texture, &char_rect, &dest_rect) < 0) {
return -1;
}