Fallback if roundf didn't exist, like in dietlibc (#1953)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66e4a83..2a8fd8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,7 +108,7 @@
 if (UNIX)
   list(APPEND CMAKE_REQUIRED_LIBRARIES m)
 endif ()
-check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l)
+check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l roundf)
 check_include_file(unistd.h HAVE_UNISTD_H)
 if (${HAVE_UNISTD_H})
   add_definitions(-DHAVE_UNISTD_H)
diff --git a/src/hb.hh b/src/hb.hh
index 0e7b890..3a824fd 100644
--- a/src/hb.hh
+++ b/src/hb.hh
@@ -477,6 +477,15 @@
 /* Size signifying variable-sized array */
 #define VAR 1
 
+static inline double
+_hb_roundf (float x)
+{
+  return x >= 0 ? floor ((double) x + .5) : ceil ((double) x - .5);
+}
+#ifndef HAVE_ROUNDF
+#define roundf(x) _hb_roundf(x)
+#endif
+
 /* Endian swap, used in Windows related backends */
 static inline uint16_t hb_uint16_swap (const uint16_t v)
 { return (v >> 8) | (v << 8); }