From 6b7fbf4fe476d908fd44ca9421363e053324ba69 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 24 Nov 2021 21:03:16 +0100 Subject: Fix glyphs overlapping, but adds unnecessary padding --- tests/main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/main.c b/tests/main.c index b341bb3..0d4f096 100644 --- a/tests/main.c +++ b/tests/main.c @@ -56,8 +56,8 @@ static void draw(mgl_window *window, void *userdata) { u->fps_counter = 0; fprintf(stderr, "fps: %d\n", u->fps); } - char str[255]; - snprintf(str, sizeof(str), "hello|fps\nåäö: %d", u->fps); + char str[512]; + snprintf(str, sizeof(str), ",.-_/1234567890½!\"#¤%%&/()=?¡@£$€¥{[]}\\'abcdefghijklmnopqrstuvwxyzáàäåãâíìîïúùũüûéèẽëêóòõôöABCDEFGHIJKLMNOPQRSTUVWXYZÁÀÄÅÃÂÍÌÎÏÚÙŨÜÛÉÈẼËÊÓÒÕÔÖ └> pacman -Q quickmedia-git"); mgl_text text; mgl_text_init(&text, u->font, str, strlen(str)); @@ -120,7 +120,7 @@ static void draw(mgl_window *window, void *userdata) { mgl_rectangle rect = { .position = { window->cursor_position.x, window->cursor_position.y }, - .size = { u->cjk_font->texture.width, u->cjk_font->texture.height }, + .size = { u->font->texture.width, u->font->texture.height }, .color = { 255, 255, 255, 255 }, }; mgl_rectangle_draw(context, &rect); @@ -132,25 +132,25 @@ static void draw(mgl_window *window, void *userdata) { .color = {255, 0, 0, 100} }, (mgl_vertex){ - .position = {u->cjk_font->texture.width, 0.0f}, - .texcoords = {u->cjk_font->texture.width, 0.0f}, + .position = {u->font->texture.width, 0.0f}, + .texcoords = {u->font->texture.width, 0.0f}, .color = {0, 255, 0, 100}, }, (mgl_vertex){ - .position = {u->cjk_font->texture.width, u->cjk_font->texture.height}, - .texcoords = {u->cjk_font->texture.width, u->cjk_font->texture.height}, + .position = {u->font->texture.width, u->font->texture.height}, + .texcoords = {u->font->texture.width, u->font->texture.height}, .color = {0, 0, 255, 100}, }, (mgl_vertex){ - .position = {0.0f, u->cjk_font->texture.height}, - .texcoords = {0.0f, u->cjk_font->texture.height}, + .position = {0.0f, u->font->texture.height}, + .texcoords = {0.0f, u->font->texture.height}, .color = {255, 0, 255, 100} } }; mgl_vertex_buffer_update(u->vertex_buffer1, vertices1, 4, MGL_PRIMITIVE_QUADS, MGL_USAGE_STREAM); mgl_vertex_buffer_set_position(u->vertex_buffer1, (mgl_vec2f){ window->cursor_position.x, window->cursor_position.y }); - mgl_vertex_buffer_draw(context, u->vertex_buffer1, &u->cjk_font->texture); + mgl_vertex_buffer_draw(context, u->vertex_buffer1, &u->font->texture); } static void test_hash_map_get_insert(mgl_font_char_map *char_map, uint32_t unicode, bool exists) { @@ -250,7 +250,7 @@ int main(int argc, char **argv) { if(mgl_texture_load_from_file(&texture, "tests/X11.jpg", &(mgl_texture_load_options){ false, false }) != 0) return 1; - if(mgl_mapped_file_load("/usr/share/fonts/noto/NotoSans-Regular.ttf", &font_file, &(mgl_memory_mapped_file_load_options){ .readable = true, .writable = false }) != 0) + if(mgl_mapped_file_load("/usr/share/fonts/TTF/Hack-Regular.ttf", &font_file, &(mgl_memory_mapped_file_load_options){ .readable = true, .writable = false }) != 0) return 1; if(mgl_mapped_file_load("/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", &cjk_font_file, &(mgl_memory_mapped_file_load_options){ .readable = true, .writable = false }) != 0) -- cgit v1.2.3