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
This commit is contained in:
Manolo Gouy 2017-09-06 16:25:42 +00:00
parent 16f968b40f
commit 950ec3e863
2 changed files with 2899 additions and 1 deletions

2882
nanosvg/fl_nanosvg.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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);