shithub: cstory

Download patch

ref: febeb1b692f7d3c31a780fe3b6a33de257077165
parent: d1560da21713226fc76e0a03b23e2748d1c1a2c4
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Sep 16 14:18:37 EDT 2020

More-efficient way of determining atlas size

--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1081,7 +1081,7 @@
 					size_t atlas_entry_height = FT_MulFix(font->face->bbox.yMax - font->face->bbox.yMin + 1, font->face->size->metrics.y_scale) / 64;
 
 					size_t atlas_columns = ceil(sqrt(atlas_entry_width * atlas_entry_height * TOTAL_GLYPH_SLOTS) / atlas_entry_width);
-					size_t atlas_rows = ceil(sqrt(atlas_entry_width * atlas_entry_height * TOTAL_GLYPH_SLOTS) / atlas_entry_height);
+					size_t atlas_rows = (TOTAL_GLYPH_SLOTS + (atlas_columns - 1)) / atlas_columns;
 
 					font->atlas_row_length = atlas_columns;