hoffstadt / hoffstadt/DearPyGui

Binding icon font to tab button crashes application

Open
#2,084 2 comments 0 reactions 0 assignees View on GitHub
state: pending type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 1.9.0
Operating System: Windows 10 Pro 22H2

## My Issue/Question

Attempting to bind an icon font to a tab button causes the application to crash.

It is possibly to correctly display this font other ways just fine, for example as a basic line of text. (see L29, run with L32 commented)

## To Reproduce

Minimal example that reproduces the issue:
```python
import dearpygui.dearpygui as dpg

dpg.create_context()

def add_font(file, size: int | float, parent=0, **kwargs) -> int:
if not isinstance(size, (int, float)):
raise ValueError(f'font size must be an integer or float. Not {type(size)}')

chars = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
for i, char in enumerate(chars):
chars[i] = ord(char)

with dpg.font(file, size, parent=parent, **kwargs) as font:
dpg.add_font_range_hint(dpg.mvFontRangeHint_Default, parent=font)
dpg.add_font_range_hint(dpg.mvFontRangeHint_Cyrillic, parent=font)
dpg.add_font_chars(chars, parent=font)
return font

with dpg.font_registry():
box_icons = add_font("boxicons.ttf", 30, tag="_box_icons")

dpg.create_viewport(title='Private Use Area Unicode Block Test', width=720, height=520, resizable=False)

with dpg.window(label="Font Test", tag="_font_test"):
with dpg.tab_bar(tag="_font_test_bar") as tb:
with dpg.tab(label="Compression", tag="_font_test_tab"):
icons = dpg.add_text("              ")
dpg.bind_item_font(icons, box_icons)
dpg.add_tab_button(label="", leading=True, tag="_toggle")
dpg.bind_item_font("_toggle", box_icons)

dpg.setup_dearpygui()
dpg.set_primary_window("_font_test", True)
dpg.show_viewport()

while dpg.is_dearpygui_running():
dpg.render_dearpygui_frame()
dpg.destroy_context()

```

## Expected behavior

The label of the `tab_button` should show the icon font. As a side note this works perfectly fine on tabs themselves, just not `tab_button`s.
[boxicons.zip](https://github.com/hoffstadt/DearPyGui/files/11361939/boxicons.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.