Fix segmentation fault in Font loading

This commit is contained in:
MrLetsplay 2023-09-15 21:34:11 +02:00
parent da91e92124
commit 2ff8debe8c
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg

View File

@ -248,11 +248,13 @@ CharacterBlock Font::generateCharacterBlock(unsigned int block) {
int col = c % KEK_FONT_BITMAP_WIDTH_BLOCKS; int col = c % KEK_FONT_BITMAP_WIDTH_BLOCKS;
int row = c / KEK_FONT_BITMAP_WIDTH_BLOCKS; int row = c / KEK_FONT_BITMAP_WIDTH_BLOCKS;
for(unsigned int r = 0; r < face->glyph->bitmap.rows; r++) { // TODO: handle wide characters more gracefully
memcpy( for(unsigned int r = 0; r < std::min(64u, face->glyph->bitmap.rows); r++) {
textureBytes + row * KEK_FONT_RESOLUTION * KEK_FONT_BITMAP_WIDTH + col * KEK_FONT_RESOLUTION + r * KEK_FONT_BITMAP_WIDTH, size_t offset = row * KEK_FONT_RESOLUTION * KEK_FONT_BITMAP_WIDTH + col * KEK_FONT_RESOLUTION + r * KEK_FONT_BITMAP_WIDTH;
size_t len = face->glyph->bitmap.width;
memcpy(textureBytes + offset,
face->glyph->bitmap.buffer + r * face->glyph->bitmap.width, face->glyph->bitmap.buffer + r * face->glyph->bitmap.width,
face->glyph->bitmap.width); len);
} }
Character ch; Character ch;