NanoMichael / MicroTeX

A dynamic, cross-platform, and embeddable LaTeX rendering library
MIT License
399 stars 66 forks source link

Crashes on Windows-Mingw64 with a locale-related exception. #140

Closed ghost closed 1 year ago

ghost commented 1 year ago

The test case is the stock example latex2png .

running ./latex2png.exe test.tex out.png results in an exception:

./latex2png.exe --clm $(pwd)/../../../res/xits/XITSMath-Regular.clm1 --mathfont $(pwd)/../../../res/xits/XITSMath-Regular.otf input.tex out.png
"\\(E=mc^2\\)"
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid

I do not know how to debug this, as mingw64's gdb does not break on exceptions.

ghost commented 1 year ago

Okay, I found the problem: utils.cpp has static const std::locale locale("en_US.UTF-8");

This will not work on Windows, and throw that exception. In my case, the "C" locale worked, and even worked with non-latin characters, buy YMMV.