mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-29 16:25:40 +00:00
Fonts: adding new fonts after removing all fonts mid-frame properly updates current state.
This commit is contained in:
@@ -128,6 +128,7 @@ Other Changes:
|
|||||||
is enabled, creating side-effects when later disabling hinting or
|
is enabled, creating side-effects when later disabling hinting or
|
||||||
dynamically switching to stb_truetype rasterizer.
|
dynamically switching to stb_truetype rasterizer.
|
||||||
- Post rescale GlyphOffset is always rounded.
|
- Post rescale GlyphOffset is always rounded.
|
||||||
|
- Adding new fonts after removing all fonts mid-frame properly updates current state.
|
||||||
- Textures:
|
- Textures:
|
||||||
- Fixed a building issue when ImTextureID is defined as a struct.
|
- Fixed a building issue when ImTextureID is defined as a struct.
|
||||||
- Fixed displaying texture # in Metrics/Debugger window.
|
- Fixed displaying texture # in Metrics/Debugger window.
|
||||||
|
|||||||
@@ -3035,6 +3035,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg_in)
|
|||||||
ImFontAtlasBuildInit(this);
|
ImFontAtlasBuildInit(this);
|
||||||
|
|
||||||
// Create new font
|
// Create new font
|
||||||
|
const bool is_first_font = (Fonts.Size == 0);
|
||||||
ImFont* font;
|
ImFont* font;
|
||||||
if (!font_cfg_in->MergeMode)
|
if (!font_cfg_in->MergeMode)
|
||||||
{
|
{
|
||||||
@@ -3092,6 +3093,8 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg_in)
|
|||||||
}
|
}
|
||||||
ImFontAtlasFontSourceAddToFont(this, font, font_cfg);
|
ImFontAtlasFontSourceAddToFont(this, font, font_cfg);
|
||||||
|
|
||||||
|
if (is_first_font)
|
||||||
|
ImFontAtlasBuildNotifySetFont(this, NULL, font);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3254,6 +3257,9 @@ void ImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font, ImFont*
|
|||||||
shared_data->Font = new_font;
|
shared_data->Font = new_font;
|
||||||
if (ImGuiContext* ctx = shared_data->Context)
|
if (ImGuiContext* ctx = shared_data->Context)
|
||||||
{
|
{
|
||||||
|
if (ctx->FrameCount == 0 && old_font == NULL) // While this should work either way, we save ourselves the bother / debugging confusion of running ImGui code so early when it is not needed.
|
||||||
|
continue;
|
||||||
|
|
||||||
if (ctx->IO.FontDefault == old_font)
|
if (ctx->IO.FontDefault == old_font)
|
||||||
ctx->IO.FontDefault = new_font;
|
ctx->IO.FontDefault = new_font;
|
||||||
if (ctx->Font == old_font)
|
if (ctx->Font == old_font)
|
||||||
|
|||||||
Reference in New Issue
Block a user