hoffstadt / hoffstadt/DearPyGui
Binding font to a plot axis crashes the application
- Dominant language
- C++
- Stars
- 15.6k
- Forks
- 783
- PR merge metrics
- No merged PRs in 30d
Description
## Version of Dear PyGui
Version: 1.11.2
Operating System: Windows
## My Issue/Question
When a font is bound to `dpg.plot_axis`, the application immediately segfaults.
This is caused by `ImGui::PopFont()` in `DearPyGui::draw_plot_axis`, which does not have a corresponding `PushFont`.
## To Reproduce
Steps to reproduce the behavior:
1. Create a plot.
2. Use `dpg.bind_item_font` on one of the axes.
## Expected behavior
No crash. Ideally, the font should be applied to this axis' label, but if that is not possible (due to the way ImPlot renders plot elements), at least ignore the font and don't segfault.
## Screenshots/Video
None.
## Standalone, minimal, complete and verifiable example
```python
from math import sin
from pathlib import Path
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title="Test", width=520, height=550)
with dpg.font_registry():
regular_font = dpg.add_font(Path(__file__).parent / "resources/fonts/RobotoMono-SemiBold.ttf", 18)
with dpg.window(pos=(0, 0), width=500, height=500):
dpg.add_button(label="Bind font to Y axis", callback=lambda: (dpg.set_item_label("y-axis", "New Y"), dpg.bind_item_font("y-axis", regular_font)))
x_data = [x/10 for x in range(0, 200)]
y_data = [sin(x) for x in x_data]
with dpg.plot(label="x=f(y)", height=-1, width=-1):
x_axis = dpg.add_plot_axis(dpg.mvXAxis, label="x")
with dpg.plot_axis(dpg.mvYAxis, label="y", tag="y-axis") as y_axis:
dpg.add_line_series(y_data, x_data)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```
Contributor guide
Assessment
This issue has not been assessed yet.