diff options
Diffstat (limited to 'src/vk/character.cpp')
-rw-r--r-- | src/vk/character.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/vk/character.cpp b/src/vk/character.cpp index 04ddb0c..e5eb87f 100644 --- a/src/vk/character.cpp +++ b/src/vk/character.cpp @@ -61,19 +61,28 @@ load_image(void *obj) error = FT_Render_Glyph(self->face->glyph, FT_RENDER_MODE_NORMAL); if(error) throw CommandError{"failed to render glyph"}; + self->character->bearing_x = self->face->glyph->bitmap_left; + self->character->bearing_y = self->face->glyph->bitmap_top; + self->character->advance = (self->face->glyph->advance.x >> 6); self->character->width = self->face->glyph->bitmap.width; self->character->height = self->face->glyph->bitmap.rows; self->character->mip_levels = 1; - self->character->bearing_x = self->face->glyph->bitmap_left; - self->character->bearing_y = self->face->glyph->bitmap_top; - self->character->advance = self->face->glyph->bitmap.width; // self->face->glyph->advance.x; + + // Character is a white-space. + if(self->character->width <= 0) + { + self->character->image = VK_NULL_HANDLE; + self->character->device_memory = VK_NULL_HANDLE; + + return; + } auto image_size{static_cast<size_t>( self->face->glyph->bitmap.width * self->face->glyph->bitmap.rows * num_channels)}; { // Create the data for the image buffer - source_image_raw.resize(image_size); + source_image_raw.resize(image_size, 0); for(auto y{0}; y < self->face->glyph->bitmap.width; y++) { @@ -83,11 +92,11 @@ load_image(void *obj) x * num_channels; auto glyph_coord = y * self->face->glyph->bitmap.rows + x; // Red - source_image_raw[image_coord] = 0; + source_image_raw[image_coord] = 255; // Green - source_image_raw[image_coord + 1] = 0; + source_image_raw[image_coord + 1] = 255; // Blue - source_image_raw[image_coord + 2] = 0; + source_image_raw[image_coord + 2] = 255; // Alpha source_image_raw[image_coord + 3] = self->face->glyph->bitmap.buffer[glyph_coord]; |