From b2f0ea6c0de9869ecc704b659f2805f3d55ee844 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 6 Nov 2016 21:51:20 +0100 Subject: [PATCH] Font: Default font given explicit name "ProggyClean.ttf" --- imgui_demo.cpp | 5 ++--- imgui_draw.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index e5215141..ffc66a93 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1721,8 +1721,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) if (ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size)) { ImGui::SameLine(); ShowHelpMarker("Tip: Load fonts with io.Fonts->AddFontFromFileTTF()\nbefore calling io.Fonts->GetTex* functions."); - ImGuiIO& io = ImGui::GetIO(); - ImFontAtlas* atlas = io.Fonts; + ImFontAtlas* atlas = ImGui::GetIO().Fonts; if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) { ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128)); @@ -1734,7 +1733,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) ImFont* font = atlas->Fonts[i]; ImGui::BulletText("Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size); ImGui::TreePush((void*)(intptr_t)i); - ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) io.FontDefault = font; + ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font; ImGui::PushFont(font); ImGui::Text("The quick brown fox jumps over the lazy dog"); ImGui::PopFont(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 7bdb94c7..b8b4d9ee 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1184,7 +1184,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) font_cfg.OversampleH = font_cfg.OversampleV = 1; font_cfg.PixelSnapH = true; } - if (font_cfg.Name[0] == '\0') strcpy(font_cfg.Name, ""); + if (font_cfg.Name[0] == '\0') strcpy(font_cfg.Name, "ProggyClean.ttf"); const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85(); ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, 13.0f, &font_cfg, GetGlyphRangesDefault());