Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lovecoding2023 opened this issue Jan 13, 2022 · 4 comments
Open

Comments

@lovecoding2023
Copy link

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!

@nmwsharp
Copy link
Owner

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
Copy link
Owner

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 nmwsharp changed the title python-Chinese font Support general unicode string names (Chinese font, accents, etc) Jan 13, 2022
@lovecoding2023
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants