DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

Nerd Fonts

Open jgarza9788 opened this issue 2 years ago • 5 comments

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

jgarza9788 avatar Jun 23 '22 11:06 jgarza9788


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()

Screenshot 2022-06-23 083640

jgarza9788 avatar Jun 23 '22 12:06 jgarza9788

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

yhyu13 avatar Jun 30 '22 16:06 yhyu13

@jgarza9788 Yes, we community need icon font badly, please head to the Discord server to raise dev's awareness on this issue.

yhyu13 avatar Jun 30 '22 17:06 yhyu13

ok, thanks for letting me know... i thought i wasn't enabling it the right way.

jgarza9788 avatar Jun 30 '22 17:06 jgarza9788

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:

image

hugle avatar Aug 09 '22 11:08 hugle

Closing this issue as it's a duplicate.

bandit-masked avatar Jan 04 '23 22:01 bandit-masked