mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-16 19:11:13 +00:00
Cannot dynamically add new fonts #224
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#224
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When I add a new font at runtime (after init) and rebuild the texture, the new font appears ok but existing fonts get corrupted. I think this happens because the glyphs move around in the font atlas but the texture coordinates of old fonts are not updated. Is it possible to somehow fix this without needing to readd all previously added fonts to the atlas?
Looks like a bug, after building the font atlas we call ImFontAtlas::ClearTexData().
When adding new fonts the old font isn't in the InputData yet so after the second atlas build the older fonts in the Fonts[] array aren't updated. Not sure what's the righter way to fix it yet.
Right now the workaround is to call Fonts->Clear() and re-add everything.
Note that even if I fix that it won't be faster. I need to compute the atlas size and rasterize everything anyway, it doesn't incrementally rasterize. That would require more work (for later).
Knowing this, would you still want a fix soon?
Rerasterizing everything is acceptable for me. It just felt buggy that adding a new font corrupts the old fonts. I would be happy if adding a new font would "just work". (I'm doing lots of live coding, so I'm used to adding new resources on the fly. Speed is not critical in this case.).
No need to rush this fix, take your time.
That last commit
ocornut/imgui@5df542c3c0allows to append new font.I moved the ClearInputData() from imgui to application side, so it is in the example applications but anyone integrating with their own engine can see more clearly what is being done.
Connects to #220 only when calling ClearInputData() you'll notice that ImFontAtlas has taken ownership of the TTF blob.
Thanks, it fixed the issue!