diff options
author | scuri <scuri> | 2010-10-14 18:07:59 +0000 |
---|---|---|
committer | scuri <scuri> | 2010-10-14 18:07:59 +0000 |
commit | 26ee3a10b806df99915805516567f6ad38956ac4 (patch) | |
tree | 65b9d3812776ed84b9d09c5c42e99594228cbff2 | |
parent | 6620df9471268a72f0c58eddb99c0d612bca566e (diff) |
Fixed: locale in SVG for floating point numbers, it must use dots "." for decimal separators.
-rw-r--r-- | html/en/drv/svg.html | 6 | ||||
-rw-r--r-- | html/en/history.html | 3 | ||||
-rw-r--r-- | src/svg/cdsvg.c | 11 |
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 "." for floating point separators, we set +the numeric locale to "English" 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 "." 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) { |