Open monkeycc opened 7 months ago
This error occurs because DPG tries to interpret a UTF-8 string as an ANSI string. Unfortunately there's no workaround because further in the code, the same string is treated as UTF-8.
Here's what happens:
mvFont
as a Python object;char*
pointer (see mvFont::handleSpecificRequiredArgs
-> ToString
-> _PyUnicode_AsString
-> PyUnicode_AsUTF8
).mvFont
then attempts to check whether the font file exists. It does so by opening the file with std::ifstream::open
, which receives a char*
- and on Windows, treats that pointer as ANSI encoded string (correct me if I'm wrong).
ifstream::open
check succeeded, the path would further be passed to ImFontAtlas::AddFontFromFileTTF
-> ImFileLoadToMemory
-> ImFileOpen
. On Windows, ImFileOpen
explicitly converts the file name from UTF-8 to UTF-16 (wchar_t*
), thus treating making the entire call chain (and ImFontAtlas::AddFontFromFileTTF
) UTF-8 aware.Just curious, why are you closing it as completed? I believe the issue still exists and needs a fix.
Thank you, I thought nobody paid attention to this issue anymore
ttf_path E:\中文\config\ttf\MiSans-Regular.ttf
How to solve it ?