Compare commits

..

No commits in common. "717a072b3d6d3550fcc84278e7448bcbc5db8ddf" and "6858877d6b81296c71230cab674fdb8b945b7965" have entirely different histories.

3 changed files with 8 additions and 14 deletions

@ -129,6 +129,6 @@ typedef struct UIContextStruct {
VkResult init_pipelines(VkDevice device, VmaAllocator allocator, VkExtent2D swapchain_extent, vec2 window_scale, VkRenderPass render_pass, Queue transfer_queue, VkCommandPool transfer_pool, UIContext* context); VkResult init_pipelines(VkDevice device, VmaAllocator allocator, VkExtent2D swapchain_extent, vec2 window_scale, VkRenderPass render_pass, Queue transfer_queue, VkCommandPool transfer_pool, UIContext* context);
VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayout layout, VkDescriptorPool pool,VkCommandPool transfer_pool, Queue transfer_queue, FT_Library library, const char* ttf_file, uint32_t size, VkBool32 antialias, uint32_t** charmap, FontDescriptor* descriptor); VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayout layout, VkDescriptorPool pool,VkCommandPool transfer_pool, Queue transfer_queue, FT_Library library, const char* ttf_file, uint32_t size, uint32_t** charmap, FontDescriptor* descriptor);
#endif #endif

@ -247,7 +247,7 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render_context) {
FontDescriptor test_font; FontDescriptor test_font;
uint32_t* charmap; uint32_t* charmap;
result = load_font(render_context->device, render_context->allocator, ui_context.font_layout, ui_context.font_pool, render_context->transfer_pool, render_context->transfer_queue, library, "test.ttf", 16, VK_TRUE, &charmap, &test_font); result = load_font(render_context->device, render_context->allocator, ui_context.font_layout, ui_context.font_pool, render_context->transfer_pool, render_context->transfer_queue, library, "test.ttf", 16, &charmap, &test_font);
if(result != VK_SUCCESS) { if(result != VK_SUCCESS) {
return result; return result;
} }

@ -459,7 +459,7 @@ VkResult create_font_descriptor_pools(VkDevice device, uint32_t max_sets, VkDesc
return VK_SUCCESS; return VK_SUCCESS;
} }
VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayout layout, VkDescriptorPool pool,VkCommandPool transfer_pool, Queue transfer_queue, FT_Library library, const char* ttf_file, uint32_t size, VkBool32 antialias, uint32_t** charmap, FontDescriptor* descriptor) { VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayout layout, VkDescriptorPool pool,VkCommandPool transfer_pool, Queue transfer_queue, FT_Library library, const char* ttf_file, uint32_t size, uint32_t** charmap, FontDescriptor* descriptor) {
FT_Face face; FT_Face face;
int error; int error;
@ -482,12 +482,6 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou
uint32_t max_width = 0; uint32_t max_width = 0;
uint32_t symbol_count = 0; uint32_t symbol_count = 0;
uint32_t c; uint32_t c;
FT_Int32 load_flags = FT_LOAD_RENDER;
if(antialias == VK_TRUE) {
load_flags += FT_RENDER_MODE_NORMAL;
} else {
load_flags += FT_RENDER_MODE_MONO;
}
// TODO: worry about variants(that's why num_glyphs doesn't match symbol_count) // TODO: worry about variants(that's why num_glyphs doesn't match symbol_count)
c = FT_Get_First_Char(face, &glyph_index); c = FT_Get_First_Char(face, &glyph_index);
@ -495,7 +489,7 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou
if(glyph_index == 0) { if(glyph_index == 0) {
break; break;
} }
FT_Load_Glyph(face, glyph_index, load_flags); FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER | FT_RENDER_MODE_MONO);
uint32_t width = face->glyph->bitmap.width; uint32_t width = face->glyph->bitmap.width;
uint32_t height = face->glyph->bitmap.rows; uint32_t height = face->glyph->bitmap.rows;
tmp_charmap[i] = c; tmp_charmap[i] = c;
@ -522,12 +516,12 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou
for(uint32_t i = 0; i < symbol_count; i++) { for(uint32_t i = 0; i < symbol_count; i++) {
glyph_index = FT_Get_Char_Index(face, (*charmap)[i]); glyph_index = FT_Get_Char_Index(face, (*charmap)[i]);
FT_Load_Glyph(face, glyph_index, load_flags); FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER | FT_RENDER_MODE_MONO);
for(uint32_t y = 0; y < face->glyph->bitmap.rows; y++) { for(uint32_t y = 0; y < face->glyph->bitmap.rows; y++) {
for(uint32_t x = 0; x < face->glyph->bitmap.width; x++) { for(uint32_t x = 0; x < face->glyph->bitmap.width; x++) {
uint32_t level = face->glyph->bitmap.buffer[y*face->glyph->bitmap.width+x]; if(face->glyph->bitmap.buffer[y*face->glyph->bitmap.width+x] != 0) {
level = ((level * 0xFFFFFF) / 256) << 8; images[max_width*max_height*i + max_width*y + x] = 0xFFFFFFFF;
images[max_width*max_height*i + max_width*y + x] = 0x000000FF + level; }
} }
} }
} }