hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
13.31k stars 691 forks source link

The viewport title appears as garbled characters in Chinese #2261

Open s95050937 opened 10 months ago

s95050937 commented 10 months ago

I have currently set the viewport title to Traditional Chinese. The Chinese displayed within the window is correct. However, I've noticed that the Chinese display becomes garbled in the title bar and the name when the application is minimized. Is there any way to fix this issue?

import dearpygui.dearpygui as dpg
import dearpygui.dearpygui as dpg
dpg.create_context()

reg = dpg.add_font_registry()
fontName = dpg.add_font(file="C:\Windows\Fonts\msjh.ttc", size=18, parent=reg)
dpg.add_font_range(0x0001, 0x9FFF, parent=fontName)
dpg.bind_font(fontName)
with dpg.window():
    dpg.add_button(label='測試')
dpg.create_viewport(title="測試", width=1000, height=500)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

image image

v-ein commented 10 months ago

A bit of explanation (from the corresponding Discord thread):

It's an issue with how DPG configures viewport title on Windows. Quite similar to tickets #1075, #2212, and ImGui ticket #5725 (but occurs in a different place in the code). Reported to ImGui repo as #5975.

Basically mvPrerender() on Win32 uses SetWindowTextA() to set window title, but it passes in a UTF8-encoded string, which is very wrong.

Until the issue is fixed, I'd recommend to use plain ASCII for the window title (yep, that restricts it to English-only text).

monkeycc commented 10 months ago

https://github.com/hoffstadt/DearPyGui/issues/1760#issuecomment-1217108500 Can the problem be solved?

https://github.com/ocornut/imgui/commit/fe0a24f38a3501906bd304b381e3510fce9b8891 DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted Can the problem be solved?

v-ein commented 10 months ago

Can the problem be solved?

Yes, in a couple of different ways. I'm not sure yet which one should be implemented. Depends on how the build process is set up.

monkeycc commented 9 months ago

Looking forward to you fixing this issue thanks

utmcontent commented 9 months ago

file="C:\Windows\Fonts\msjh.ttc", size=18, parent=reg Wrong font file for title drag rectangle.