From 1f12b8f2c611a957f1545eae394b13dabdbd8f82 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 26 Oct 2018 12:39:42 +0200 Subject: [PATCH] Older MSVC versions seem to lack round() --- libpsautohint/src/ac.c | 8 +++++++- libpsautohint/src/basic.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libpsautohint/src/ac.c b/libpsautohint/src/ac.c index f67ff35ef..4d5f858ce 100644 --- a/libpsautohint/src/ac.c +++ b/libpsautohint/src/ac.c @@ -147,9 +147,15 @@ AutoHint(const ACFontInfo* fontinfo, const char* srcbezdata, bool extrahint, } #if defined(_MSC_VER) && _MSC_VER < 1800 +double +round(double x) +{ + return x < 0 ? ceil(x-0.5) : floor(x + 0.5); +} + float roundf(float x) { - return (float)((x < 0) ? (ceil((x)-0.5)) : (floor((x) + 0.5))); + return (float)(x < 0 ? ceil(x-0.5) : floor(x + 0.5)); } #endif diff --git a/libpsautohint/src/basic.h b/libpsautohint/src/basic.h index 8cb66e3b2..1440765d8 100644 --- a/libpsautohint/src/basic.h +++ b/libpsautohint/src/basic.h @@ -35,6 +35,7 @@ typedef unsigned char bool; #endif /* _MSC_VER < 1900 */ #if _MSC_VER < 1800 +double round(double x); float roundf(float x); #endif /* _MSC_VER < 1800 */ #endif /* _MSC_VER */