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
12.89k stars 671 forks source link

Chinese characters in create_viewport title cant be displayed correctly #2073

Open dovsay opened 1 year ago

dovsay commented 1 year ago

Version of Dear PyGui

Version: 1.9.0 Operating System: Windows 10

My Issue/Question

I have already set font_registry and bind_font, the Chinese in the text can be displayed normally, but the title is still garbled. by the way, can I change the default font of dpg?

To Reproduce

Steps to reproduce the behavior:

  1. Just run the code below 2.The font simhei.ttf can be found in google.

    Expected behavior

I hope all the characters can be displayed correctly,thanks.

Screenshots/Video

微信图片_20230405183736

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

dpg.create_context()

with dpg.font_registry():
    with dpg.font("simhei.ttf", 20) as default_font:
        dpg.add_font_range_hint(dpg.mvFontRangeHint_Chinese_Full)
    with dpg.font("simli.ttf", 20) as second_font:
        dpg.add_font_range_hint(dpg.mvFontRangeHint_Chinese_Full)

with dpg.window(tag="Primary Window"):
    dpg.add_text("Hello, 奇门遁甲")

dpg.bind_font(default_font)

dpg.create_viewport(title='奇门遁甲', width=600, height=200)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.set_primary_window("Primary Window", True)
dpg.start_dearpygui()
dpg.destroy_context()
yhyu13 commented 1 year ago

@dovsay I believe it a problem with the c++ backend of deapygui which pass title string as ansi string instead of utf-8 string.

your best bet is probably avoid using non-ascii letter in the window title

dovsay commented 1 year ago

@yhyu13 Thanks for your reply, I will try it.