From c464596b33610cc1683b69fd8ce38404597f7d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Sun, 19 Jan 2025 13:10:35 -0500 Subject: [PATCH] Work around what appears to be an integer promotion issue On an aarch64 Chromebook running gcc 12.2.0, these would wrap in weird ways causing vector fonts to be positioned incorrectly. It managed to say that (25 - -7) * 4 / 3 == -168 This casting dance appears to resolve the issue. --- src/syncterm/ripper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/syncterm/ripper.c b/src/syncterm/ripper.c index 77acb38fd8..59f4605ed4 100644 --- a/src/syncterm/ripper.c +++ b/src/syncterm/ripper.c @@ -8654,7 +8654,7 @@ write_char(char ch) // yh = font_metrics[rip.font.num][3].base * mult / div; // This way seems insane... but seems to work. - yh = (((char)rip_fonts[rip.font.num - 1][0x88]) - ((char)rip_fonts[rip.font.num - 1][0x8a])) * mult + yh = (((signed char)rip_fonts[rip.font.num - 1][0x88]) - ((signed char)rip_fonts[rip.font.num - 1][0x8a])) * mult / div; // printf("Font: %d @ %d\n", rip.font.num, rip.font.size); @@ -8680,8 +8680,8 @@ write_char(char ch) cx |= 0x80; if (cy & 0x40) cy |= 0x80; - bcx = (cx * mult) / div; - bcy = (cy * mult) / div; + bcx = ((signed char)cx * mult) / div; + bcy = ((signed char)cy * mult) / div; if (rip.font.vertical) { dx = yh - bcy; dy = -bcx; -- GitLab