From 950ec3e863cc8706c72db09c965eb159b28b0ab0 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 6 Sep 2017 16:25:42 +0000 Subject: Modify how the nanosvg source code is used to support compilation with Visual Studio 7. 1) The original nanosvg.h file is modified for FLTK in file fl_nanosvg.h. The only change is to remove the implementation of function nsvg__atof(). 2) FLTK provides an implementation of nsvg__atof() based on sscanf(). 3) FLTK changes the LC_NUMERIC locale to "C" before calling nanosvg and resets it to its previous state after. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12423 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_SVG_Image.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx index f8c62dad6..1d508ed6f 100644 --- a/src/Fl_SVG_Image.cxx +++ b/src/Fl_SVG_Image.cxx @@ -23,10 +23,19 @@ #include #include #include +#if HAVE_LOCALE_H +#include +#endif + +static double nsvg__atof(const char* s) { // replace nanosvg's version of this function + double value; + sscanf(s, "%lg", &value); + return value; +} #define NANOSVG_ALL_COLOR_KEYWORDS // Include full list of color keywords. #define NANOSVG_IMPLEMENTATION // Expands implementation -#include "../nanosvg/nanosvg.h" +#include "../nanosvg/fl_nanosvg.h" #define NANOSVGRAST_IMPLEMENTATION // Expands implementation #include "../nanosvg/altsvgrast.h" @@ -97,7 +106,14 @@ void Fl_SVG_Image::init_(const char *filename, char *filedata, Fl_SVG_Image *cop } else ld(ERR_FILE_ACCESS); } if (filedata) { +#if HAVE_LOCALE_H + char *saved_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); +#endif counted_svg_image_->svg_image = nsvgParse(filedata, "px", 96); +#if HAVE_LOCALE_H + setlocale(LC_NUMERIC, saved_locale); +#endif if (filename) free(filedata); if (counted_svg_image_->svg_image->width == 0 || counted_svg_image_->svg_image->height == 0) { d(-1); -- cgit v1.2.3