|
|
@ -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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|