mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
(Breaking) Fonts: removing obsolete ImFont::Scale.
This commit is contained in:
parent
25f9c318e3
commit
e3860aa6ac
4 changed files with 16 additions and 5 deletions
13
imgui.cpp
13
imgui.cpp
|
|
@ -8683,7 +8683,9 @@ void ImGui::SetCurrentFont(ImFont* font, float font_size)
|
|||
if (font != NULL)
|
||||
{
|
||||
IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
IM_ASSERT(font->Scale > 0.0f);
|
||||
#endif
|
||||
g.DrawListSharedData.Font = g.Font;
|
||||
ImFontAtlasUpdateDrawListsSharedData(g.Font->ContainerAtlas);
|
||||
if (g.CurrentWindow != NULL)
|
||||
|
|
@ -8699,7 +8701,10 @@ void ImGui::UpdateCurrentFontSize()
|
|||
return;
|
||||
|
||||
float final_size = g.FontSizeBeforeScaling * g.IO.FontGlobalScale;
|
||||
final_size *= g.Font->Scale;
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
if (g.Font != NULL)
|
||||
final_size *= g.Font->Scale;
|
||||
#endif
|
||||
if (window != NULL)
|
||||
final_size *= window->FontWindowScale;
|
||||
|
||||
|
|
@ -16753,14 +16758,16 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|||
ImFontAtlasFontDiscardBakes(atlas, font, 2);
|
||||
|
||||
// Display details
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
SetNextItemWidth(GetFontSize() * 8);
|
||||
DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f");
|
||||
SameLine(); MetricsHelpMarker(
|
||||
/*SameLine(); MetricsHelpMarker(
|
||||
"Note that the default embedded font is NOT meant to be scaled.\n\n"
|
||||
"Font are currently rendered into bitmaps at a given size at the time of building the atlas. "
|
||||
"You may oversample them to get some flexibility with scaling. "
|
||||
"You can also render at multiple sizes and select which one to use at runtime.\n\n"
|
||||
"(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");
|
||||
"(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)");*/
|
||||
#endif
|
||||
|
||||
char c_str[5];
|
||||
Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
|
||||
|
|
|
|||
4
imgui.h
4
imgui.h
|
|
@ -3762,10 +3762,12 @@ struct ImFont
|
|||
ImVector<ImFontConfig*> Sources; // 16 // in // List of sources. Pointers within ContainerAtlas->Sources[]
|
||||
ImWchar EllipsisChar; // 2-4 // out // Character used for ellipsis rendering ('...').
|
||||
ImWchar FallbackChar; // 2-4 // out // Character used if a glyph isn't found (U+FFFD, '?')
|
||||
float Scale; // 4 // in // Base font scale (~1.0f), multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||
ImU8 Used8kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/8192/8]; // 1 bytes if ImWchar=ImWchar16, 16 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints.
|
||||
bool EllipsisAutoBake; // 1 // // Mark when the "..." glyph needs to be generated.
|
||||
ImGuiStorage RemapPairs; // 16 // // Remapping pairs when using AddRemapChar(), otherwise empty.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
float Scale; // 4 // in // Legacy base font scale (~1.0f), multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||
#endif
|
||||
|
||||
// Methods
|
||||
IMGUI_API ImFont();
|
||||
|
|
|
|||
|
|
@ -5018,7 +5018,9 @@ void ImFontBaked::ClearOutputData()
|
|||
ImFont::ImFont()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
Scale = 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
ImFont::~ImFont()
|
||||
|
|
|
|||
|
|
@ -2139,7 +2139,7 @@ struct ImGuiContext
|
|||
ImFont* Font; // Currently bound font. (== FontStack.back().Font)
|
||||
ImFontBaked* FontBaked; // Currently bound font at currently bound size. (== Font->GetFontBaked(FontSize))
|
||||
float FontSize; // Currently bound font size == line height (== FontSizeBeforeScaling * io.FontGlobalScale * font->Scale * g.CurrentWindow->FontWindowScale).
|
||||
float FontSizeBeforeScaling; // == value passed to PushFontSize()
|
||||
float FontSizeBeforeScaling; // == value passed to PushFont() / PushFontSize() when specified.
|
||||
float FontScale; // == FontBaked->Size / Font->FontSize. Scale factor over baked size.
|
||||
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
|
||||
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue