Repository navigation
Description
2025/06/25: RELEASED 1.92.0. PLEASE STOP POSTING HERE. OPEN A NEW ISSUE INSTEAD!
See docs/BACKENDS.md for instruction to add support for ImGuiBackendFlags_RendererHasTextures in your custom backend.
2025/06/11: merged to master, branch now deleted.
2025/06/06: pushed enough changes that I am hopeful this could be merged this month. Feedback welcome.
2025/03/19: pushed a "big" change reverting the renaming ImTextureID to ImTextureUserID from the March 5 version. This is simpler for end-user, both in terms of breaking changes and in term of understanding the design. The structure previously called ImTextureID in the March 5 version is now called ImTextureRef.
2025/03/05: Pushed an experimental features/dynamic_fonts branch.
I am looking for feedback / early adopters to try this as we will inevitably find bugs or use cases that are not well supported.
The API are not 100% stabilized but it is expected they stay relatively close.
As of today, I only recommend experienced users to try this. Things should be simplified and clarified over the upcoming month.
WHEN YOU SUBMIT FEEDBACK PLEASE TRY TO INCLUDE RELEVANT CONTEXT. Things may look simple in the surface but there are lots of parameters under the hood.
Warning: Your first impression may be very dry: the examples application are using the default bitmap fonts and are still not DPI aware. (but it is now trivial to scale the font dynamically).
You may tinker with changing FontSize or FontScale in Style Editor. It's going to make more sense in an established application. If you are using multiple fonts, large fonts, icon fonts, non-English languages, this will likely make things easier.
TL;DR; Add a font once, use it as any size.
2025-01-27.font.resize.mp4
If you want to help testing this:
- Read this :)
- Branch your project and update to this
features/dynamic_fontsbranch of imgui. - Make changes (in required/desirable) in your branch.
- If you find any issue you can report/discuss and return to your main branch. Your feedback will help improve the code but also comments/docs/examples.
- If you start using this, please try to update and feedback regularly as we work on finalizing this.
I am interested in different situations:
- Updating to latest code and using an old standard backend. Do you see any issue/breakage?
- Updating to latest code and using the latest standard backend.
- Updating to latest code and using a custom backend. Do you see any issue/breakage? How's your experience figuring out how to update to support
ImGuiBackendFlags_RendererHasTextures? - Users for
AddCustomRectRegular()/AddCustomRectFontGlyph()api: I am creating a dedicated topic Request for feedback: custom rect / custom glyphs / custom loaders withdynamic_fontsbranch. #8466 for feedback on those.
The API we are replacing to interface with renderer backends has been here since January 2015 (!), so is more 10 years old. I want to ensure that the new API will also last long.
THE PLAN
My hope is that I can finish and merge this to master in 1~2 months but it will depends on amount of feedback/bugs, and the remaining work on more "General Scaling".
- I am pushing a public branch today. It is temporarily based over
docking. If you need to maintain changes on your side (custom engine etc.) you can use#ifdef IMGUI_HAS_TEXTURES. - Now gathering a first wave of feedback and issues from early enthusiasts.
I am creating two topics:- Topic Request for feedback: dynamic fonts & texture updates (v1.92) #8465 (this one) for any general question and issue on this feature.
- Topic Request for feedback: custom rect / custom glyphs / custom loaders with
dynamic_fontsbranch. #8466 solely related to support for CustomRect viaAddCustomRect()API (previouslyAddCustomRectRegular()/AddCustomRectFontGlyph()).
Your feedback, any sorts of feedback will help fixing bugs, improving documentation, comments and examples. Don't hesitate to share any sorts of feedback, or any report of what confused you, if even for a minute.
- The commit history will be reworked/sculpted, rebased and force-pushed for a little while, as I am treating this as short-term feature branch. So you will likely need to checkout when you update (regular merging will be harder). At some point when I am convinced enough that the commits are a good, I will stop sculpting history and start only adding to it.
- When this is deemed mature enough, it will be rebased on master and pushed as 1.92. We will open new topics if the current topics have had too many posts and many already solved issues.
- My expectation is that before 1.92 I will have also finished and added more features related to "general scaling" (current code only has "font scaling").
USEFUL REFERENCES COMMITS/DIFF
Public API
- Browse for main changes inside
imgui.hin the diff between before and after - Added about ~300 lines added to imgui.h, including comments and obsolete stuff.
Backends:
(line count including comments)
- Allegro5: ee8941e (+35 lines)
- DirectX9: 75efba7 (+48 lines)
- DirectX10: 2d2b1bc (+40 lines)
- DirectX11: 372fd27 (+40 lines)
- DirectX12: eefe5d5 (+87 lines)
- Metal: 26c017d (+55 lines)
- OpenGL2: 0430c55 (+25 lines)
- OpenGL3: dbb91a5 (+47 lines)
- SDL_Renderer2: 9fa65cd (+20 lines)
- SDL_Renderer3: e538883 (+19 lines)
- SDL_GPU: 16fe666 (+41 lines)
- Vulkan: abe294b (+33 lines)
- WGPU: 571dae9 (+30 lines)
Third Party Extensions
- ImPlot fixes: epezent/implot@193b9d8
cimgui expose image functions withImTextureUserIDtype to simplify function calls: 1.92: Auto convert ImTextureID from ImTextureUserID ? cimgui/cimgui#287
Activity
ocornut commentedon Mar 5, 2025
GENERAL OVERVIEW OF THE CHANGES
As outlined in the '10 years of Dear ImGui' article there are many changes coming related to the font system and text shaping.
For the font system, I have decided to split the work in 2 distinct steps:
The code I am publishing today is mostly step 1.
What is part of what I am publishing (step 1)
ImGuiBackendFlags_RendererHasTextures:What is not part of this update yet (step 2, will come next)
Your first impression may be very dry: The examples are using the default bitmap fonts and are still not DPI aware.
Generally speaking, the design puzzle here has been to push toward improvements while providing a reasonable path for old code to function without major issues. I have iterated on this for countless hours to find what I hope is the best solution, but it's expected that people will run into issues.
ocornut commentedon Mar 5, 2025
KNOWN ISSUES
style.FontSizefrom inside Style Editor. Or bindio.FontGlobalScaleto an interactive item and immediately see this in action:ImGui::DragFloat("io.FontGlobalScale", &ImGui::GetIO().FontGlobalScale, 0.05f, 0.5f, 5.0f);Important: use of legacyio.FontGlobalScale,ImGuiConfigFlags_DpiEnableScaleFontsandSetWindowFontScale()should now all appear to work nicely. But be warned they can lead to confusion and feedback loop when using e.g.GetFontSize()as a base to request another size. This will be clarified and improved as I finish work on general scaling.ImFont::AddRemapChar()doesn't work and may be obsoleted as I'm not sure anyone is using this.ImTextureUserIDinto ImTextureID.ocornut commentedon Mar 5, 2025
Q: ImTextureID vs ImTextureRef ?
CHANGELOG
Moved to https://github.com/ocornut/imgui/releases/tag/v1.92.0
GamingMinds-DanielC commentedon Mar 5, 2025
Sounds great so far, but this one point worries me a little bit:
This sounds like glyphs (with "glyph" being glyph X of font Y at size Z) are always carried over, never discarded if unused. With zooming there will quickly be many different size variations, combined with scrolling through large texts (especially with Kanji since there are tons of them) this can spiral out of control fast and exceed maximum texture sizes.
I think it is necessary that glyphs that have not been submitted to any text function for at least N frames will be skipped when packing the new texture. But I'm pretty sure it is just the way you worded it and your actual implementation already takes care of this.
ocornut commentedon Mar 5, 2025
It is the way I have worded it indeed, I will amend the description paragraph.
When there is no room anymore, size variations that are not used may be evicted during repacking.
ocornut commentedon Mar 6, 2025
As well as various small fixes/addition, I have temporarily added a scale widget + direction in the demo to make experimenting less dry.

bratpilz commentedon Mar 7, 2025
This is really great! It lets me delete a lot of the code I had written to deal with creating and using fonts of different sizes, and it's much faster and more flexible on top of that.
So far I've noticed only two issues (for which I can also create separate GitHub issues if you prefer):
PushFont(active_fonts.bold); [...] PopFont();to have a heading text be bold. Right now this resets the font size back to what I initially specified when creating the font though.I saw that this is because of a temporary backwards compatibility measure in PushFont:
font_size = font->Sources[0].SizePixels; // g.FontSize;If I change this line to
font_size = g.FontSize;, the bold text is also shown at the new size (i.e. 16.0f in the example above).ImGuiContext, and I'm sharing the font atlas between all of these contexts. When I close one of the windows, I destroy its context and also callImGui_ImplOpenGL3_Shutdown. This then deletes all the textures that are still in use in the other OS windows' contexts, which leads to the following assertion:with the following stack:
If I comment out the call to
ImGui_ImplOpenGL3_Shutdown, the problem disappears, but then I'm leaking resources on the GPU.ocornut commentedon Mar 7, 2025
Thank you @bratpilz for your feedback.
(1) I haven't figured out the right design for this yet. To be forward-facing, it seems evident that
PushFont(xxx)by default should preserve current font size, but this creates a problem with legacy code which defacto often used this to change font for the purpose of changing size.We can distinguish font_size ==0 from font_size < 0 to allow for two different behavior, but again the tricky part is to decide on the default one. I'll work on this.
(2) I think we could solve this by adding a reference count inside ImFontAtlas and having backend check this. I'll work on this too.
ocornut commentedon Mar 7, 2025
I have pushed 3eefa4e which should solve the problem with sharing an atlas between context. For simplicity I had to take a shortcut of assuming that when multiple contexts are created, they all have their backend initialized/bound to the context.
[-]Request for feedback: dynamic fonts & texture update protocol.[/-][+]Request for feedback: dynamic fonts & texture updates (v1.92)[/+]ZingBallyhoo commentedon Mar 7, 2025
Question r.e supporting in custom backends, would it be possible for the pixel data to be kept alive until the backend agrees the texture is destroyed? Currently the data is freed as soon as the texture enters the ImTextureStatus_WantDestroy state, but its possible that the data could still be in use asynchronously (obviously relies on the whole "Textures blocks that have been used will never be rewritten" guarantee). Also fine if not! Just requires buffering
98 remaining items
inflex commentedon Jun 13, 2025
With the new dynamic font system, is it more efficient to still maintain a limited set of font sizes in use ( ie, 10, 14, 20, 32, 45... ) or will it be no different to infinitely variable sizes?
ie, I draw part names to fit the width of parts on my boards, previously I used fixed sizes selected using a quantizing algorithm, but now I can just do ImGui::PushFontSize(part_width *constant_scaler); however I do wonder if it's most definitely going to be detrimental to performance compared to a fixed set?
rodrigorc commentedon Jun 13, 2025
It looks like this is a use case for
ImFontFlags_LockBakedSizes?inflex commentedon Jun 13, 2025
I'll look in to that; for now I've started quantizing though I do wonder if I'm actually going to end up now with consuming more VRAM than the old prebaked situation ( 4~5 fixed font sizes ). Guess that's for me to experiment with and set size bracketing up too.
Next thing I'll be on the look out for is rotated text.
rodrigorc commentedon Jun 13, 2025
What I do for a somewhat similar situation is to render the text myself, by accessing the atlas texture and adding the glyphs as quads to the WindowDrawList. That is why I asked above for the
GetFontBaked(density). Then you can do the scale and rotation at will.Fonts: fixed FontBaked=NULL in initial call to SetCurrentWindow() in …
ocornut commentedon Jun 13, 2025
Should be fixed now, thanks!
This is worth opening a new topic for, but.
GetFontBaked(font, 24.0f)every frame it'll prevent that size from being evicted, so you could already use that if you find it beneficial.DrawList, Fonts: fixed ImFontAtlasTextureRepack() overwriting draw li…
Fonts: fixed RenderText() asserting when crossing VtxOffset change bo…
Fonts: fixed PVS Studio false positive "expression 'cmd_count != draw…
ocornut commentedon Jun 25, 2025
I have fixed a bug and pushed some of the last breaking changes before tagging this as a release.
(1) obsoleted single parameter
PushFont(ImFont*)in favor of explicitPushFont(ImFont*, font_size_base_unscaled)(ca72eb0)Recap:
PushFont(font, 0.0f)// Change font and keep current sizePushFont(NULL, 20.0f)// Keep font and change current sizePushFont(font, 20.0f)// Change font and set size to 20.0fPushFont(font, style.FontSizeBase * 2.0f)// Change font and set size to be twice bigger than current size.PushFont(font, font->LegacySize)// Change font and set size to size passed to AddFontXXX() function. Same as pre-1.92 behavior, for fixed size fonts.Kept inline redirection function that does
PushFont(font, font->LegacySize).IF YOU USED THIS BRANCH OR NEW FEATURES IN THE PAST FEW WEEKS, THE DIFFERENCE IS: If you call single the obsolete parameter version it now does PushFont(font, font->LegacySize) instead of PushFont(font, 0.0f).
Interestingly since
sizeis now optional in the AddFontXXX calls, if you specify a size of 0.0f, font->LegacySize will be 0.0f.(2) removed
PushFontSize(),PopFontSize()(97e0d59)You can use
PushFont(NULL, new_size)instead.The reasoning behind this is that due to external scaling factor we need to distinguish base/unscaled sizes from scaled sizes (after global factors
style.FontScaleMainstyle.FontScaleDpiare applied).The size parameter passed to
PushFont()ends up instyle.FontSizeBase. Therefore in theoryPushFontSize()should be calledPushFontSizeBase()orPushFontBaseSize()orPushFontSizeUnscaled()(TDB).(3) removed
ImFontFlags_DefaultToLegacySize(89b5a2c)It is not necessary. Better design to enforce two parameter version of
PushFont()and legacy call to usefont->LegacySize.Backends: SDLGPU: fixes call to SDL_MapGPUTransferBuffer(). Fixes art…
ocornut commentedon Jun 25, 2025
Locking this topic as 1.92 is being released.
IN ORDER TO HELP US IMPROVE THE TRANSITION PROCESS, INCL. DOCUMENTATION AND COMMENTS, PLEASE REPORT ANY DOUBT, CONFUSION, QUESTIONS BY OPENING A NEW ISSUE.
ocornut commentedon Jun 27, 2025
See docs/BACKENDS.md for instructions to add support for
ImGuiBackendFlags_RendererHasTexturesin your custom backend.