From fcf1e9d0c4850574c14f009f5cfee2f7ac4aa16b Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 8 Sep 2020 03:14:53 +0100 Subject: [PATCH] Link glyph array from back to front This way, glyphs are allocated from front to bacl, which makes the atlas much more pleasant to look at. --- src/Font.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index 2c23a912..f1a59a92 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -1092,14 +1092,14 @@ FontObject* LoadFontFromData(const unsigned char *data, size_t data_size, unsign // Initialise the linked-list for (size_t i = 0; i < TOTAL_GLYPH_SLOTS; ++i) { + if (i != 0) + font_object->glyphs[i].next = &font_object->glyphs[i - 1]; + font_object->glyphs[i].x = (i % font_object->atlas_row_length) * atlas_entry_width; font_object->glyphs[i].y = (i / font_object->atlas_row_length) * atlas_entry_height; - - if (i != TOTAL_GLYPH_SLOTS - 1) - font_object->glyphs[i].next = &font_object->glyphs[i + 1]; } - font_object->glyph_list_head = font_object->glyphs; + font_object->glyph_list_head = &font_object->glyphs[TOTAL_GLYPH_SLOTS - 1]; return font_object; }