Fix text rendering with bitmap fonts
This commit is contained in:
1 parent
0e18dd0705
commit
bfe6d48527
1 file changed
+7
-3
+7
-3
@@ -93,18 +93,22 @@ void render_bitmap_font_text(AssetManager *am, Renderer *renderer,
|
|||||||
SDL_Texture *texture = get_texture(am, font->font_atlas);
|
SDL_Texture *texture = get_texture(am, font->font_atlas);
|
||||||
|
|
||||||
u64 char_index = 0;
|
u64 char_index = 0;
|
||||||
|
|
||||||
RenderRect src = {0};
|
RenderRect src = {0};
|
||||||
|
|
||||||
|
f64 ratio = (f64)font_size / font->tile_height;
|
||||||
|
u64 width = font->tile_width * ratio;
|
||||||
RenderRect dst = {
|
RenderRect dst = {
|
||||||
.y = dst_rect.y,
|
.y = dst_rect.y,
|
||||||
.width = font->tile_width,
|
.width = (f64)width,
|
||||||
.height = font->tile_height,
|
.height = font_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (u64 i = 0; i < length; ++i) {
|
for (u64 i = 0; i < length; ++i) {
|
||||||
char_index = (u64)(text[i]) - start_index;
|
char_index = (u64)(text[i]) - start_index;
|
||||||
|
|
||||||
src = get_character_sprite(font, char_index);
|
src = get_character_sprite(font, char_index);
|
||||||
dst.x = i * font->tile_width + dst_rect.x;
|
dst.x = i * width + dst_rect.x;
|
||||||
|
|
||||||
set_texture_color_modulation(texture, text_color);
|
set_texture_color_modulation(texture, text_color);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user