polyscope icon indicating copy to clipboard operation
polyscope copied to clipboard

Support general unicode string names (Chinese font, accents, etc)

Open lovecoding2023 opened this issue 4 years ago • 4 comments

Polyscope is an easy-to-use program. I try to customize the UI using the python version, but the Chinese characters can't be displayed. The display is '?' Is there any way to display it? thanks in advance!

lovecoding2023 avatar Jan 13 '22 13:01 lovecoding2023

If it doesn't work right now, it probably can't be done without some enhancements to Polyscope on the C++ side.

This has been on my TODO list for a while, but unfortunately it may not be simple. We probably need to add more unicode characters to our font atlases. Basically, all this stuff happens in ImGUI, so the solution in Polyscope is whatever the ImGUI solution is. See the imgui docs and e.g. here for discussion. After that, there may be a separate issue that Polyscope uses string names as keys in dictionaries all over the place; we need to make all this work with unicode strings.

One small request: could you share some snippet of code that you would expect to work? Some code that creates a few button labels or something like that? I'm not a Chinese speaker/typer, so I don't know what typical inputs would look like to test :)

nmwsharp avatar Jan 13 '22 15:01 nmwsharp

Call to the world: I personally have no experience writing cross-platform unicode C++ string handling. I've heard it can be difficult. It anyone wants to offer tips or assistance it would be greatly appreciated!

(I'm also going to change the title to make this a general issue for this)

nmwsharp avatar Jan 13 '22 15:01 nmwsharp

Thank you for your kind answer. I saw that discussion you mentioned today, because I'm not familiar with C++, and I don't know how to import this font file in polyscope, such as below:

io.Fonts->AddFontFromFileTTF("c:\Windows\Fonts\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesChinese());`

Here is the test code I wrote according to your detailed instructions. psim.Begin('信息',True,0) psim.PushItemWidth(150) psim.TextUnformatted("This is text, with English and 中文") psim.Button("button 按钮") 00

lovecoding2023 avatar Jan 13 '22 16:01 lovecoding2023

I saw the documentation of font import and testing here ,but I don't know how to use it in the python version of polyscope

lovecoding2023 avatar Jan 13 '22 16:01 lovecoding2023