From e783b833f9ad84b9a37aa259d76f063b1da0c95b Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Sun, 26 Feb 2023 10:47:01 +0100 Subject: [PATCH] Make rect_height_compare a stable sort stb_rect_pack was producing different results on different platforms due to differing qsort implementations. This change uses the existing was_packed field to make the sort stable. --- libs/ffi/stb_truetype-sys/src/stb_rect_pack.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/ffi/stb_truetype-sys/src/stb_rect_pack.h b/libs/ffi/stb_truetype-sys/src/stb_rect_pack.h index 0d88cb5..9ab5923 100644 --- a/libs/ffi/stb_truetype-sys/src/stb_rect_pack.h +++ b/libs/ffi/stb_truetype-sys/src/stb_rect_pack.h @@ -555,7 +555,11 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b) return -1; if (p->h < q->h) return 1; - return (p->w > q->w) ? -1 : (p->w < q->w); + if (p->w > q->w) + return -1; + if (p->w < q->w) + return 1; + return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); } static int STBRP__CDECL rect_original_order(const void *a, const void *b) -- 2.49.0