Fix segmentation fault in Font loading
This commit is contained in:
parent
da91e92124
commit
2ff8debe8c
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user