mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Fonts: ImFont::DefaultSize -> ImFont::LegacySize. ImFontFlags_UseDefaultSize -> ImFontFlags_DefaultToLegacySize.
This commit is contained in:
parent
e3860aa6ac
commit
69547bd4bd
3 changed files with 10 additions and 10 deletions
|
|
@ -8620,7 +8620,7 @@ void ImGui::UpdateFontsNewFrame()
|
||||||
atlas->Locked = true;
|
atlas->Locked = true;
|
||||||
|
|
||||||
// We do this really unusual thing of calling *push_front()*, the reason behind that we want to support the PushFont()/NewFrame()/PopFont() idiom.
|
// We do this really unusual thing of calling *push_front()*, the reason behind that we want to support the PushFont()/NewFrame()/PopFont() idiom.
|
||||||
ImFontStackData font_stack_data = { ImGui::GetDefaultFont(), ImGui::GetDefaultFont()->DefaultSize };
|
ImFontStackData font_stack_data = { ImGui::GetDefaultFont(), ImGui::GetDefaultFont()->LegacySize };
|
||||||
g.FontStack.push_front(font_stack_data);
|
g.FontStack.push_front(font_stack_data);
|
||||||
if (g.FontStack.Size == 1)
|
if (g.FontStack.Size == 1)
|
||||||
ImGui::SetCurrentFont(font_stack_data.Font, font_stack_data.FontSize);
|
ImGui::SetCurrentFont(font_stack_data.Font, font_stack_data.FontSize);
|
||||||
|
|
@ -8741,8 +8741,8 @@ void ImGui::PushFont(ImFont* font, float font_size)
|
||||||
font = GetDefaultFont();
|
font = GetDefaultFont();
|
||||||
if (font_size <= 0.0f)
|
if (font_size <= 0.0f)
|
||||||
{
|
{
|
||||||
if (font->Flags & ImFontFlags_UseDefaultSize)
|
if (font->Flags & ImFontFlags_DefaultToLegacySize)
|
||||||
font_size = font->DefaultSize; // Legacy: use default font size. Same as doing PushFont(font, font->DefaultSize). // FIXME-NEWATLAS
|
font_size = font->LegacySize; // Legacy: use AddFont() specified font size. Same as doing PushFont(font, font->LegacySize)
|
||||||
else
|
else
|
||||||
font_size = g.FontSizeBeforeScaling; // Keep current font size
|
font_size = g.FontSizeBeforeScaling; // Keep current font size
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
imgui.h
10
imgui.h
|
|
@ -498,8 +498,8 @@ namespace ImGui
|
||||||
// *IMPORTANT* before 1.92, fonts had a single size. They can now be dynamically be adjusted.
|
// *IMPORTANT* before 1.92, fonts had a single size. They can now be dynamically be adjusted.
|
||||||
// - Before 1.92: PushFont() always used font default size.
|
// - Before 1.92: PushFont() always used font default size.
|
||||||
// - Since 1.92: PushFont() preserve the current shared font size.
|
// - Since 1.92: PushFont() preserve the current shared font size.
|
||||||
// - To use old behavior (single size font): use 'PushFont(font, font->DefaultSize)' in call site, or set 'ImFontConfig::Flags |= ImFontFlags_UseDefaultSize' before calling AddFont().
|
// - To use old behavior (single size font): use 'PushFont(font, font->LegacySize)' in call site, or set 'ImFontConfig::Flags |= ImFontFlags_DefaultToLegacySize' before calling AddFont().
|
||||||
IMGUI_API void PushFont(ImFont* font, float font_size = -1); // use NULL as a shortcut to push default font. Use <0.0f to keep current font size. Use font->DefaultSize to revert to font default size.
|
IMGUI_API void PushFont(ImFont* font, float font_size = -1); // use NULL as a shortcut to push default font. Use <0.0f to keep current font size. Use font->LegacySize to revert to font size specified by AddFont().
|
||||||
IMGUI_API void PopFont();
|
IMGUI_API void PopFont();
|
||||||
IMGUI_API void PushFontSize(float font_size);
|
IMGUI_API void PushFontSize(float font_size);
|
||||||
IMGUI_API void PopFontSize();
|
IMGUI_API void PopFontSize();
|
||||||
|
|
@ -3736,7 +3736,7 @@ struct ImFontBaked
|
||||||
enum ImFontFlags_
|
enum ImFontFlags_
|
||||||
{
|
{
|
||||||
ImFontFlags_None = 0,
|
ImFontFlags_None = 0,
|
||||||
ImFontFlags_UseDefaultSize = 1 << 0, // Legacy compatibility: make PushFont() calls without explicit size use font->DefaultSize instead of current font size.
|
ImFontFlags_DefaultToLegacySize = 1 << 0, // Legacy compatibility: make PushFont() calls without explicit size use font->LegacySize instead of current font size.
|
||||||
ImFontFlags_NoLoadError = 1 << 1, // Disable throwing an error/assert when calling AddFontXXX() with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
ImFontFlags_NoLoadError = 1 << 1, // Disable throwing an error/assert when calling AddFontXXX() with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
||||||
ImFontFlags_NoLoadGlyphs = 1 << 2, // [Internal] Disable loading new glyphs.
|
ImFontFlags_NoLoadGlyphs = 1 << 2, // [Internal] Disable loading new glyphs.
|
||||||
ImFontFlags_LockBakedSizes = 1 << 3, // [Internal] Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size. Important: if you use this to preload given sizes, consider the possibility of multiple font density used on Retina display.
|
ImFontFlags_LockBakedSizes = 1 << 3, // [Internal] Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size. Important: if you use this to preload given sizes, consider the possibility of multiple font density used on Retina display.
|
||||||
|
|
@ -3758,7 +3758,7 @@ struct ImFont
|
||||||
// [Internal] Members: Cold ~24-52 bytes
|
// [Internal] Members: Cold ~24-52 bytes
|
||||||
// Conceptually Sources[] is the list of font sources merged to create this font.
|
// Conceptually Sources[] is the list of font sources merged to create this font.
|
||||||
ImGuiID FontId; // Unique identifier for the font
|
ImGuiID FontId; // Unique identifier for the font
|
||||||
float DefaultSize; // 4 // in // Default font size passed to AddFont(). It's unlikely you should use this (use ImGui::GetFontBaked() to get font baked at current bound size).
|
float LegacySize; // 4 // in // Font size passed to AddFont(). Use for old code calling PushFont() expecting to use that size. (use ImGui::GetFontBaked() to get font baked at current bound size).
|
||||||
ImVector<ImFontConfig*> Sources; // 16 // in // List of sources. Pointers within ContainerAtlas->Sources[]
|
ImVector<ImFontConfig*> Sources; // 16 // in // List of sources. Pointers within ContainerAtlas->Sources[]
|
||||||
ImWchar EllipsisChar; // 2-4 // out // Character used for ellipsis rendering ('...').
|
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, '?')
|
ImWchar FallbackChar; // 2-4 // out // Character used if a glyph isn't found (U+FFFD, '?')
|
||||||
|
|
@ -3785,7 +3785,7 @@ struct ImFont
|
||||||
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip = NULL);
|
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip = NULL);
|
||||||
IMGUI_API void RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false);
|
IMGUI_API void RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false);
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
inline const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) { return CalcWordWrapPosition(DefaultSize * scale, text, text_end, wrap_width); }
|
inline const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) { return CalcWordWrapPosition(LegacySize * scale, text, text_end, wrap_width); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// [Internal] Don't use!
|
// [Internal] Don't use!
|
||||||
|
|
|
||||||
|
|
@ -3004,7 +3004,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg_in)
|
||||||
font = IM_NEW(ImFont)();
|
font = IM_NEW(ImFont)();
|
||||||
font->FontId = FontNextUniqueID++;
|
font->FontId = FontNextUniqueID++;
|
||||||
font->Flags = font_cfg_in->Flags;
|
font->Flags = font_cfg_in->Flags;
|
||||||
font->DefaultSize = font_cfg_in->SizePixels;
|
font->LegacySize = font_cfg_in->SizePixels;
|
||||||
font->CurrentRasterizerDensity = font_cfg_in->RasterizerDensity;
|
font->CurrentRasterizerDensity = font_cfg_in->RasterizerDensity;
|
||||||
Fonts.push_back(font);
|
Fonts.push_back(font);
|
||||||
}
|
}
|
||||||
|
|
@ -3266,7 +3266,7 @@ void ImFontAtlas::RemoveCustomRect(ImFontAtlasRectId id)
|
||||||
// myfont->Flags |= ImFontFlags_LockBakedSizes;
|
// myfont->Flags |= ImFontFlags_LockBakedSizes;
|
||||||
ImFontAtlasRectId ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar codepoint, int width, int height, float advance_x, const ImVec2& offset)
|
ImFontAtlasRectId ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar codepoint, int width, int height, float advance_x, const ImVec2& offset)
|
||||||
{
|
{
|
||||||
float font_size = font->DefaultSize;
|
float font_size = font->LegacySize;
|
||||||
return AddCustomRectFontGlyphForSize(font, font_size, codepoint, width, height, advance_x, offset);
|
return AddCustomRectFontGlyphForSize(font, font_size, codepoint, width, height, advance_x, offset);
|
||||||
}
|
}
|
||||||
// FIXME: we automatically set glyph.Colored=true by default.
|
// FIXME: we automatically set glyph.Colored=true by default.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue