|
|
|
@ -459,7 +459,7 @@ VkResult create_font_descriptor_pools(VkDevice device, uint32_t max_sets, VkDesc
|
|
|
|
|
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, 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, VkBool32 antialias, uint32_t** charmap, FontDescriptor* descriptor) {
|
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
|
|
int error;
|
|
|
|
@ -482,6 +482,12 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou
|
|
|
|
|
uint32_t max_width = 0;
|
|
|
|
|
uint32_t symbol_count = 0;
|
|
|
|
|
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)
|
|
|
|
|
c = FT_Get_First_Char(face, &glyph_index);
|
|
|
|
@ -489,7 +495,7 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou
|
|
|
|
|
if(glyph_index == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER | FT_RENDER_MODE_MONO);
|
|
|
|
|
FT_Load_Glyph(face, glyph_index, load_flags);
|
|
|
|
|
uint32_t width = face->glyph->bitmap.width;
|
|
|
|
|
uint32_t height = face->glyph->bitmap.rows;
|
|
|
|
|
tmp_charmap[i] = c;
|
|
|
|
@ -516,12 +522,12 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou
|
|
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < symbol_count; i++) {
|
|
|
|
|
glyph_index = FT_Get_Char_Index(face, (*charmap)[i]);
|
|
|
|
|
FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER | FT_RENDER_MODE_MONO);
|
|
|
|
|
FT_Load_Glyph(face, glyph_index, load_flags);
|
|
|
|
|
for(uint32_t y = 0; y < face->glyph->bitmap.rows; y++) {
|
|
|
|
|
for(uint32_t x = 0; x < face->glyph->bitmap.width; x++) {
|
|
|
|
|
if(face->glyph->bitmap.buffer[y*face->glyph->bitmap.width+x] != 0) {
|
|
|
|
|
images[max_width*max_height*i + max_width*y + x] = 0xFFFFFFFF;
|
|
|
|
|
}
|
|
|
|
|
uint32_t level = face->glyph->bitmap.buffer[y*face->glyph->bitmap.width+x];
|
|
|
|
|
level = ((level * 0xFFFFFF) / 256) << 8;
|
|
|
|
|
images[max_width*max_height*i + max_width*y + x] = 0x000000FF + level;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|