diff --git a/client/Makefile b/client/Makefile index 0c19234..1728e53 100644 --- a/client/Makefile +++ b/client/Makefile @@ -1,5 +1,5 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) -CFLAGS = -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra +CFLAGS = -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra -fsanitize=address LDFLAGS = -lfreetype -lz -lglfw -lvulkan -ldl -Xlinker -rpath -Xlinker /opt/homebrew/lib SOURCES = src/main.c src/render.c src/ui.c src/command.c lib/spng.c lib/vma.cpp diff --git a/client/include/ui.h b/client/include/ui.h index c42798e..c3f338f 100644 --- a/client/include/ui.h +++ b/client/include/ui.h @@ -162,8 +162,8 @@ typedef struct UIContextStorageStruct { uint32_t max_fonts; uint32_t max_textures; - uint8_t* font_slots; - uint8_t* texture_slots; + char** font_slots; + char** texture_slots; UIContext data; } UIContextStorage; diff --git a/client/src/ui.c b/client/src/ui.c index 0c89344..da0627e 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -378,8 +378,9 @@ VkResult load_texture( TextureStorage* memory) { *index = 0xFFFFFFFF; for(uint32_t i = 0; i < context->max_textures; i++) { - if(context->texture_slots[i] == 0) { - context->texture_slots[i] = 1; + if(context->texture_slots[i] == NULL) { + context->texture_slots[i] = malloc(strlen(png_path) + 1); + memcpy(context->texture_slots[i], png_path, strlen(png_path) + 1); *index = i; break; } @@ -593,10 +594,22 @@ VkResult load_font( VkBool32 antialias, uint32_t* index, FontStorage* memory) { + FT_Face face; + + int error; + error = FT_New_Face(library, ttf_file, 0, &face); + if(error != FT_Err_Ok) { + return VK_ERROR_UNKNOWN; + } + *index = 0xFFFFFFFF; for(uint32_t i = 0; i < context->max_fonts; i++) { if(context->font_slots[i] == 0) { - context->font_slots[i] = 1; + context->font_slots[i] = malloc(strlen(face->family_name) + strlen(face->style_name) + 2); + memcpy(context->font_slots[i], face->family_name, strlen(face->family_name)); + context->font_slots[i][strlen(face->family_name)] = ':'; + memcpy(context->font_slots[i] + strlen(face->family_name) + 1, face->style_name, strlen(face->style_name)); + context->font_slots[i][strlen(face->family_name) + strlen(face->style_name) + 1] = '\0'; *index = i; break; } @@ -605,14 +618,6 @@ VkResult load_font( return VK_ERROR_OUT_OF_DEVICE_MEMORY; } - FT_Face face; - - int error; - error = FT_New_Face(library, ttf_file, 0, &face); - if(error != FT_Err_Ok) { - return VK_ERROR_UNKNOWN; - } - error = FT_Set_Pixel_Sizes(face, 0, size); if(error != FT_Err_Ok) { return VK_ERROR_UNKNOWN;