hoffstadt / hoffstadt/DearPyGui
Loading variable fonts creates a segmentation fault
- Dominant language
- C++
- Stars
- 15.6k
- Forks
- 783
- PR merge metrics
- No merged PRs in 30d
Description
## Version of Dear PyGui
Version: 1.7.1
Operating System: Fedora 36
## My Issue/Question
When loading a variable font using `add_font()`, Dear PyGui creates a segmentation fault. Using a debugger shows that the segmentation fault happens in `ImGui::SetCurrentFont(ImFont*)`, this suggests that the issue should be forwarded to ocornut/imgui. But I have not tested variable fonts in Dear ImGui.
## To Reproduce
Steps to reproduce the behavior:
1. Download a variable font, [Cantarell](https://cantarell.gnome.org/) is the example that was used.
2. Put the Cantarell-VF.otf font in a python environment with Dear PyGui.
3. Copy the example from [Font Loading Instructions](https://dearpygui.readthedocs.io/en/latest/documentation/fonts.html#font-loading-instructions) and paste it in test.py with the same directory as the python environment.
4. Inside test.py replace every instance of "NotoSerifCJKjp-Medium.otf" to "Cantarell-VF.otf".
5. Run test.py using the python environment.
6. Segmentation fault.
## Expected behavior
The expected behavior is that the example from Font Loading Instructions runs and the font manager shows that Cantarell-VF.otf is loaded instead of NotoSerifCJKjp-Medium.otf.
## Screenshots/Video


## Standalone, minimal, complete and verifiable example
```python
import dearpygui.dearpygui as dpg
dpg.create_context()
# add a font registry
with dpg.font_registry():
# first argument ids the path to the .ttf or .otf file
default_font = dpg.add_font("Cantarell-VF.otf", 20)
second_font = dpg.add_font("Cantarell-VF.otf", 10)
with dpg.window(label="Font Example", height=200, width=200):
dpg.add_button(label="Default font")
b2 = dpg.add_button(label="Secondary font")
dpg.add_button(label="default")
# set font of specific widget
dpg.bind_font(default_font)
dpg.bind_item_font(b2, second_font)
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.