hoffstadt / hoffstadt/DearPyGui
Support for font awesome and similar unicode based icon library
- Dominant language
- C++
- Stars
- 15.6k
- Forks
- 783
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
I'm trying to build a more modern-looking GUI, where it is a must to give some hints with icons on buttons, like a play button or stop button. Although as I see in the documentation the DearPyGUI supports custom fonts. When I import the downloaded otf file of FontAwesome, the icons included do not work. I don't know if this is a bug, or just flat-out not supported behavior. From all the examples I found online, it gave me the impression that not many people use icons with buttons wiht DPG, so I suppose it is not supported. If it IS supported I would be happy if there were a simple example in docs of how to do it, because following the current docs, I cannot display special characters.
**Describe the solution you'd like**
I want to be able to specify simply display icons from fontawesome and/or other icon font libraries in the UI elements.
**Describe alternatives you've considered**
I don't know how to circumvent this.
**Additional context**
Based on the docs, at least one of these attempts should show an icon, and it doesn't.
```
import dearpygui.dearpygui as dpg
import fontawesome as fa
dpg.create_context()
fontawesome_tag = "font_tag"
fontawesome_tag2 = "font_tag2"
# add a font registry
with dpg.font_registry():
# first argument ids the path to the .ttf or .otf file
# based on my understanding, at least one of these examples should be able to generate special characters
second_font = dpg.add_font("../fonts/fontawesome-free-5.15.4-desktop/otfs/Font Awesome 5 Free-Regular-400.otf", 10,
tag=fontawesome_tag)
with dpg.font("../fonts/fontawesome-free-5.15.4-desktop/otfs/Font Awesome 5 Free-Regular-400.otf", 10,
tag=fontawesome_tag2) as font2:
dpg.add_font_range(0x0000, 0xffff)
with dpg.window(label="Font Example", height=200, width=200):
dpg.add_button(label=f'\uf164 {fa.icons["thumbs-up"]} Default font')
b2 = dpg.add_button(label=f'\uf164 {fa.icons["thumbs-up"]} Secondary font')
b3 = dpg.add_button(label=f'\uf164 {fa.icons["thumbs-up"]} Third font')
dpg.add_button(label="default")
# set font of specific widget
dpg.bind_item_font(b2, second_font)
dpg.bind_item_font(b3, fontawesome_tag2)
# in the commandline it plots the special characters
print("This works", '\uf164')
print(fa.icons["thumbs-up"])
dpg.show_font_manager()
dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```
Contributor guide
Assessment
This issue has not been assessed yet.