mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Mde it optional to new() io.Font - however it stills needs to be loaded.
This commit is contained in:
parent
51df5874a6
commit
241e8086fa
@ -465,7 +465,6 @@ void InitImGui()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load font
|
// Load font
|
||||||
io.Font = new ImFont();
|
|
||||||
io.Font->LoadDefault();
|
io.Font->LoadDefault();
|
||||||
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
||||||
//io.Font->DisplayOffset.y += 0.0f;
|
//io.Font->DisplayOffset.y += 0.0f;
|
||||||
|
@ -238,7 +238,6 @@ void InitImGui()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load font
|
// Load font
|
||||||
io.Font = new ImFont();
|
|
||||||
io.Font->LoadDefault();
|
io.Font->LoadDefault();
|
||||||
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
||||||
//io.Font->DisplayOffset.y += 0.0f;
|
//io.Font->DisplayOffset.y += 0.0f;
|
||||||
|
@ -278,7 +278,6 @@ void InitImGui()
|
|||||||
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
|
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
|
||||||
|
|
||||||
// Load font
|
// Load font
|
||||||
io.Font = new ImFont();
|
|
||||||
io.Font->LoadDefault();
|
io.Font->LoadDefault();
|
||||||
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
||||||
//io.Font->DisplayOffset.y += 0.0f;
|
//io.Font->DisplayOffset.y += 0.0f;
|
||||||
|
@ -187,7 +187,6 @@ void InitImGui()
|
|||||||
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
|
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
|
||||||
|
|
||||||
// Load font
|
// Load font
|
||||||
io.Font = new ImFont();
|
|
||||||
io.Font->LoadDefault();
|
io.Font->LoadDefault();
|
||||||
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
//io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault());
|
||||||
//io.Font->DisplayOffset.y += 0.0f;
|
//io.Font->DisplayOffset.y += 0.0f;
|
||||||
|
11
imgui.cpp
11
imgui.cpp
@ -417,6 +417,12 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We statically allocate a default font storage for the user.
|
||||||
|
// This allows the user to avoid newing the default font, while keeping IO.Font a pointer which is easy to swap if needed.
|
||||||
|
// We cannot new() the font because user may override MemAllocFn after the ImGuiIO() constructor is called.
|
||||||
|
// For the same reason we cannot call LoadDefault() on the font.
|
||||||
|
static ImFont GDefaultStaticFont;
|
||||||
|
|
||||||
ImGuiIO::ImGuiIO()
|
ImGuiIO::ImGuiIO()
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(*this));
|
memset(this, 0, sizeof(*this));
|
||||||
@ -425,7 +431,7 @@ ImGuiIO::ImGuiIO()
|
|||||||
IniSavingRate = 5.0f;
|
IniSavingRate = 5.0f;
|
||||||
IniFilename = "imgui.ini";
|
IniFilename = "imgui.ini";
|
||||||
LogFilename = "imgui_log.txt";
|
LogFilename = "imgui_log.txt";
|
||||||
Font = NULL;
|
Font = &GDefaultStaticFont;
|
||||||
FontGlobalScale = 1.0f;
|
FontGlobalScale = 1.0f;
|
||||||
FontAllowUserScaling = false;
|
FontAllowUserScaling = false;
|
||||||
PixelCenterOffset = 0.0f;
|
PixelCenterOffset = 0.0f;
|
||||||
@ -1662,9 +1668,12 @@ void ImGui::Shutdown()
|
|||||||
g.LogFile = NULL;
|
g.LogFile = NULL;
|
||||||
}
|
}
|
||||||
if (g.IO.Font)
|
if (g.IO.Font)
|
||||||
|
{
|
||||||
|
if (g.IO.Font != &GDefaultStaticFont)
|
||||||
{
|
{
|
||||||
g.IO.Font->~ImFont();
|
g.IO.Font->~ImFont();
|
||||||
ImGui::MemFree(g.IO.Font);
|
ImGui::MemFree(g.IO.Font);
|
||||||
|
}
|
||||||
g.IO.Font = NULL;
|
g.IO.Font = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
imgui.h
7
imgui.h
@ -746,14 +746,15 @@ struct ImFont
|
|||||||
float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
||||||
ImVec2 DisplayOffset; // = (0.0f,0.0f) // Offset font rendering by xx pixels
|
ImVec2 DisplayOffset; // = (0.0f,0.0f) // Offset font rendering by xx pixels
|
||||||
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found.
|
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found.
|
||||||
ImTextureID TexID; // = NULL // User reference to texture used by the font (ignore if you aren't using multiple fonts/textures)
|
|
||||||
|
|
||||||
// Texture data
|
// Texture data: user is in charge of copying the pixels into a GPU texture.
|
||||||
// User is in charge of copying the pixels into a GPU texture.
|
|
||||||
// You can set 'TexID' to uniquely identify your texture. TexId is copied to the ImDrawCmd structure which you receive during rendering.
|
// You can set 'TexID' to uniquely identify your texture. TexId is copied to the ImDrawCmd structure which you receive during rendering.
|
||||||
|
ImTextureID TexID; // User reference to texture used by the font (ignore if you aren't using multiple fonts/textures)
|
||||||
unsigned char* TexPixels; // 1 byte, 1 component per pixel. Total byte size of TexWidth * TexHeight
|
unsigned char* TexPixels; // 1 byte, 1 component per pixel. Total byte size of TexWidth * TexHeight
|
||||||
int TexWidth;
|
int TexWidth;
|
||||||
int TexHeight;
|
int TexHeight;
|
||||||
|
|
||||||
|
// [Internal]
|
||||||
ImVec2 TexExtraDataPos; // Position of our rectangle where we draw non-font graphics
|
ImVec2 TexExtraDataPos; // Position of our rectangle where we draw non-font graphics
|
||||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block)
|
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user