summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html/en/drv/svg.html6
-rw-r--r--html/en/history.html3
-rw-r--r--src/svg/cdsvg.c11
3 files changed, 20 insertions, 0 deletions
diff --git a/html/en/drv/svg.html b/html/en/drv/svg.html
index 7f242d5..c9cfcbd 100644
--- a/html/en/drv/svg.html
+++ b/html/en/drv/svg.html
@@ -36,6 +36,12 @@
<p>Any amount of such canvases may exist simultaneously. It is important to note that a call to function
<a href="../func/init.html#cdKillCanvas"><font face="Courier"><strong>
cdKillCanvas</strong></font></a> is required to <b>close</b> the file properly.</p>
+<p><strong>IMPORTANT:</strong> because the SVG specification states that
+floating point number must use dots &quot;.&quot; for floating point separators, we set
+the numeric locale to &quot;English&quot; when the canvas is created, and restore it when
+it is destroyed. But since it uses the global C function <strong>setlocale</strong>
+if you use other C functions that are locale dependent while the SVG canvas is
+being used then be aware that they will be affected.</p>
<h3>Behavior of Functions</h3>
<h4>Control</h4>
<dir>
diff --git a/html/en/history.html b/html/en/history.html
index 87d714e..06eb512 100644
--- a/html/en/history.html
+++ b/html/en/history.html
@@ -59,6 +59,9 @@
<span class="hist_fixed">Fixed:</span> polygon filling in CD_IMAGERGB
driver when there are many horizontal lines in sequence on the same
polygon.</li>
+ <li>
+ <span class="hist_fixed">Fixed:</span> locale in SVG for floating point
+ numbers, it must use dots &quot;.&quot; for decimal separators.</li>
</ul>
<h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.4/">Version 5.4</a> (24/June/2010)</h3>
<ul>
diff --git a/src/svg/cdsvg.c b/src/svg/cdsvg.c
index 0510919..46e41bf 100644
--- a/src/svg/cdsvg.c
+++ b/src/svg/cdsvg.c
@@ -31,6 +31,7 @@ struct _cdCtxCanvas
char linestyle[50];
char pattern[50];
+ char* old_locale;
char* font_weight;
char* font_style;
char* font_decoration;
@@ -57,6 +58,12 @@ static void cdtransform(cdCtxCanvas *ctxcanvas, const double* matrix);
static void cdkillcanvas(cdCtxCanvas* ctxcanvas)
{
+ if (ctxcanvas->old_locale)
+ {
+ setlocale(LC_NUMERIC, ctxcanvas->old_locale);
+ free(ctxcanvas->old_locale);
+ }
+
if (ctxcanvas->clip_control)
fprintf(ctxcanvas->file, "</g>\n"); /* close clipping container */
@@ -1235,6 +1242,10 @@ static void cdcreatecanvas(cdCanvas *canvas, void *data)
ctxcanvas = (cdCtxCanvas *)malloc(sizeof(cdCtxCanvas));
memset(ctxcanvas, 0, sizeof(cdCtxCanvas));
+ /* SVN specification states that number must use dot as decimal separator */
+ ctxcanvas->old_locale = cdStrDup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "English");
+
ctxcanvas->file = fopen(filename, "w");
if (!ctxcanvas->file)
{