DearPyGui
DearPyGui copied to clipboard
Nerd Fonts
I tried to use a nerd font (https://www.nerdfonts.com/) within DPG. however the icons didn't work (even after trying to add to the range).
it would be nice if it was compatible with the NerdFonts. this way we would be able to add icons to our apps, without importing pngs
import os
import dearpygui.dearpygui as dpg
DIR = os.path.dirname(os.path.realpath(__file__))
dpg.create_context()
dpg.create_viewport(
title='nerd font demo',
width=600,
height=800,
x_pos = 400,
y_pos = 25,
)
with dpg.font_registry():
# first argument ids the path to the .ttf or .otf file
df = os.path.join(DIR,'fonts','Hack Regular Nerd Font Complete Mono Windows Compatible.ttf')
with dpg.font(df, 14) as font1:
dpg.add_font_range(0xf600, 0xf1ff)
# dpg.add_font_range(0x3100, 0x3ff0)
# default_font = font1
# # with dpg.add_font(df, 14) as font:
# # default_font = font
default_font = dpg.add_font(df, 14)
dpg.show_font_manager()
with dpg.window(tag="#primary_window",no_scrollbar=True):
dpg.bind_font(default_font)
dpg.add_text('hello world \uf883 0xf883')
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.set_primary_window("#primary_window", True)
dpg.start_dearpygui()
dpg.destroy_context()
Duplicate to #1552, adding icon font support is on road map for v1.7. Dpg does not expose font merging method that native imgui support at this moment
@jgarza9788 Yes, we community need icon font badly, please head to the Discord server to raise dev's awareness on this issue.
ok, thanks for letting me know... i thought i wasn't enabling it the right way.
After dpg.add_font
, if you use character map tool to find out the unicode of the font and add characters one by one, it will show correctly in DPG, just a bit inconvenient:
Closing this issue as it's a duplicate.