summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
authorGravatarGravatar Vas Crabb <vas@vastheman.com>2019-11-05 18:36:51 +1100
committerGravatarGravatar Vas Crabb <vas@vastheman.com>2019-11-05 18:36:51 +1100
commit76a2e99d6bb80aaf515b8da699255c87498f7ca0 (patch)
tree70b0e458b44d472f990439686d8da5e16d92b2ad /src/emu
parentaddf59de2fab6f3855aaf83b9308ea2c58143391 (diff)
Set global locale when parsing with nanosvg - fixes SVG display issues when locale is not English
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/screen.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp
index c14c2ab1aac..52d373fbeb8 100644
--- a/src/emu/screen.cpp
+++ b/src/emu/screen.cpp
@@ -15,8 +15,11 @@
#include <nanosvg/src/nanosvg.h>
#include <nanosvg/src/nanosvgrast.h>
+
+#include <clocale>
#include <set>
+
//**************************************************************************
// DEBUGGING
//**************************************************************************
@@ -91,10 +94,17 @@ private:
screen_device::svg_renderer::svg_renderer(memory_region *region)
{
+ // nanosvg makes assumptions about the global locale
char *s = new char[region->bytes()+1];
memcpy(s, region->base(), region->bytes());
s[region->bytes()] = 0;
+ const char *const lcctype(std::setlocale(LC_CTYPE, nullptr));
+ const char *const lcnumeric(std::setlocale(LC_NUMERIC, nullptr));
+ std::setlocale(LC_CTYPE, "C");
+ std::setlocale(LC_NUMERIC, "C");
m_image = nsvgParse(s, "px", 72);
+ std::setlocale(LC_CTYPE, lcctype);
+ std::setlocale(LC_NUMERIC, lcnumeric);
delete[] s;
m_rasterizer = nsvgCreateRasterizer();