diff options
| author | Manolo Gouy <Manolo> | 2017-09-06 16:25:42 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-09-06 16:25:42 +0000 |
| commit | 950ec3e863cc8706c72db09c965eb159b28b0ab0 (patch) | |
| tree | b2d490ce4aff22175e848eff388bbf01cbfa891d /src | |
| parent | 16f968b40fd8dd219d56eeb420ce6d30ed869979 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_SVG_Image.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
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 <FL/Fl_SVG_Image.H> #include <FL/fl_utf8.h> #include <stdio.h> +#if HAVE_LOCALE_H +#include <locale.h> +#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); |
