macroquad
macroquad copied to clipboard
cache_glyph() fails with large text
The same happens with measure_text() and populate_font_cache(), problem is in the cache_glyph() function.
Minimal reproduction:
use macroquad::text::measure_text;
#[macroquad::main("test")]
async fn main() {
measure_text("place the entry portal", None, 358, 1.0);
}
358 is the exact value, it works fine with 357. When called more than once, it will fail even with smaller values:
use macroquad::text::measure_text;
#[macroquad::main("test")]
async fn main() {
measure_text("place the entry portal", None, 200, 1.0);
measure_text("place the entry portal", None, 201, 1.0);
measure_text("place the entry portal", None, 202, 1.0);
}
The size at which is starts failing also depends on the text, for example, for "text", it starts to fail at 581 text size.
use macroquad::text::measure_text;
#[macroquad::main("test")]
async fn main() {
measure_text("text", None, 581, 1.0);
}