Skip to content

Add support for multiple fonts#6

Merged
Toni500github merged 3 commits intoToni500github:mainfrom
BurntRanch:multi-font
Mar 14, 2026
Merged

Add support for multiple fonts#6
Toni500github merged 3 commits intoToni500github:mainfrom
BurntRanch:multi-font

Conversation

@BurntRanch
Copy link
Contributor

@BurntRanch BurntRanch commented Mar 14, 2026

this checks for an array at defaults.fonts, and loads each element as a string, skipping any non-strings on the way.

when it comes to loading the font for imgui, it loads each font, and sets the first successfully-loaded font as the default.
when it comes to anywhere else, the first element is treated as the default.

support for default.font also works, and it's treated as the least-priority font.

some test-cases that work:

font = "NotoSansCJK-Regular.ttc"

correctly uses Noto Sans CJK

fonts=["notafontanywhere", "NotoSansCJK-Regular.ttc", 0]

correctly uses Noto Sans CJK

fonts=[""]

correctly uses ImGUIs default font

#fonts=...

correctly uses ImGUIs default font

this checks for an array at `defaults.fonts`, and loads each element as
a string, skipping any non-strings on the way.

when it comes to loading the font for imgui, it loads each font, and
sets the first successfully-loaded font as the default.

when it comes to anywhere else, the first element is treated as the
default.

support for `default.font` also works, and it's treated as the
least-priority font.
@BurntRanch
Copy link
Contributor Author

logs for the first test-case:

[2026-03-14 23:51:45.522] [WARNING] Font at index 1 is not a string!
[2026-03-14 23:51:45.522] [WARNING] Font at index 2 is not a string!
[2026-03-14 23:51:45.522] [WARNING] Fallback to portal capture
[2026-03-14 23:51:45.721] [DEBUG] Found 1 monitor
[2026-03-14 23:51:45.721] [DEBUG] Iterating monitor #0
[2026-03-14 23:51:45.721] [DEBUG] XRandR capturing: monitor 1920x1080+0+0 (cursor at 316,962) 
[00000] While loading ''
[00000] [imgui-error] (current settings: Assert=1, Log=1, Tooltip=1)
[00000] [imgui-error] In window 'NULL': Could not load font file!

@BurntRanch
Copy link
Contributor Author

seems that imgui isn't displaying lower-priority fonts for different languages, which ruins the premise of this PR, I'll try to fix it.

@Toni500github
Copy link
Owner

Post screenshots about this usecase please.
also, apply the opengl3 change in main_tool_metal.mm too

@BurntRanch
Copy link
Contributor Author

Post screenshots about this usecase please.

Here's me using an English font with an Arabic font to recognize Arabic text.
Arabic readers might recognize that the characters are not connected and in the wrong direction. This is a problem with upstream ImGUI.
image

(despite the low confidence, it did get it right)

@Toni500github
Copy link
Owner

image

@Toni500github Toni500github merged commit a640ae2 into Toni500github:main Mar 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants