hoffstadt / hoffstadt/DearPyGui
Wrong char on input when using keyboard on input_text widgets after setting add_font_range
- Dominant language
- C++
- Stars
- 15.6k
- Forks
- 783
- PR merge metrics
- No merged PRs in 30d
Description
## Version of Dear PyGui
Version: 0.8.39
Operating System:
Affected: Windows 10
Not affected: Fedora 34
Not tested: Mac
## My Issue/Question
Using custom char range for "Latin Extended-A" from:
[https://en.wikipedia.org/wiki/List_of_Unicode_characters#Latin-1_Supplement](https://en.wikipedia.org/wiki/List_of_Unicode_characters#Latin-1_Supplement)
[0x0100, 0x017f]
Input chars are getting messed up...
Issue affects only Windows 10.
Issue doesnt affect Fedora 34 on the same machine and same keyboard.
I dont know how to verify my hypothesis:
DPG doesnt take into consideration system default encoding.

I'm using Windows with cp1250 encoding {command: [System.Text.Encoding]::Default

Fedora encoding:
```
[test@localhost ~]$ locale charmap
UTF-8
```
Question to the Author: **does DPG take into consideration default system encoding?**
Not every system use 'utf-8'.
Maybe thats the problem?
When copy-pasting chars from f.e. notepad.exe **everything is ok.**
add_char_remap(wrong_char, correct_char) fixes problem but every wrong_char will be wrong when actually used elsewhere...
## To Reproduce
Steps to reproduce the behavior:
1. Run example on Windows 10 with cp1250 default encoding, polish_programmer keyboard layout.
2. Input supposed chars
3. Watch the hell burn.
## Expected behavior
Input of correct chars on any system.
## Screenshots/Video

## Standalone, minimal, complete and verifiable example
```python
import dearpygui.dearpygui as dpg
path = 'font_path.ttf'
with dpg.font_registry():
with dpg.font(path, 20, default_font=True):
dpg.add_font_range(0x0100, 0x017f)
def to_hex(s: str):
return ' '.join(hex(ord(x)) for x in s)
def callback(s, u, a):
val = dpg.get_value(item=s)
dpg.configure_item(item=a[0], default_value=val)
dpg.configure_item(item=a[1], default_value=to_hex(val))
with dpg.window(label="Main window", width=500, height=400) as main_window_id:
dpg.set_primary_window(main_window_id, True)
text_id = dpg.generate_uuid()
hex_text_id = dpg.generate_uuid()
chars = 'ĄąĘęŹźŻż'
dpg.add_input_text(callback=callback, user_data=(text_id, hex_text_id), label='Input this: ' + chars)
dpg.add_separator()
dpg.add_text(default_value='Should be:')
dpg.add_text(default_value=chars)
dpg.add_text(default_value=to_hex(chars))
dpg.add_separator()
dpg.add_text(default_value='Is:')
dpg.add_text(id=text_id, default_value='', label='Val from input text')
dpg.add_text(id=hex_text_id, default_value='', label='Hex val from input text')
dpg.add_separator()
dpg.start_dearpygui()
```
Contributor guide
Assessment
This issue has not been assessed yet.