Font: Renamed ImFont::Clear() to ImFont::ClearOutputData() for consistency with what ImFontAtlas does. DisplayOffset is set by constructor but not reset by ClearOutputData. (#1349)

This commit is contained in:
omar 2017-10-22 10:24:56 +02:00
parent fce41d0b55
commit 7f880674e5
2 changed files with 6 additions and 10 deletions

View File

@ -1500,7 +1500,7 @@ struct ImFont
// Methods // Methods
IMGUI_API ImFont(); IMGUI_API ImFont();
IMGUI_API ~ImFont(); IMGUI_API ~ImFont();
IMGUI_API void Clear(); IMGUI_API void ClearOutputData();
IMGUI_API void BuildLookupTable(); IMGUI_API void BuildLookupTable();
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const; IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
IMGUI_API void SetFallbackChar(ImWchar c); IMGUI_API void SetFallbackChar(ImWchar c);

View File

@ -1618,12 +1618,8 @@ void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* f
{ {
if (!font_config->MergeMode) if (!font_config->MergeMode)
{ {
ImVec2 display_offset = font->DisplayOffset; font->ClearOutputData();
font->Clear();
font->FontSize = font_config->SizePixels; font->FontSize = font_config->SizePixels;
font->DisplayOffset = display_offset;
font->ConfigData = font_config; font->ConfigData = font_config;
font->ContainerAtlas = atlas; font->ContainerAtlas = atlas;
font->Ascent = ascent; font->Ascent = ascent;
@ -1904,7 +1900,8 @@ ImFont::ImFont()
{ {
Scale = 1.0f; Scale = 1.0f;
FallbackChar = (ImWchar)'?'; FallbackChar = (ImWchar)'?';
Clear(); DisplayOffset = ImVec2(0.0f, 1.0f);
ClearOutputData();
} }
ImFont::~ImFont() ImFont::~ImFont()
@ -1917,13 +1914,12 @@ ImFont::~ImFont()
if (g.Font == this) if (g.Font == this)
g.Font = NULL; g.Font = NULL;
*/ */
Clear(); ClearOutputData();
} }
void ImFont::Clear() void ImFont::ClearOutputData()
{ {
FontSize = 0.0f; FontSize = 0.0f;
DisplayOffset = ImVec2(0.0f, 1.0f);
Glyphs.clear(); Glyphs.clear();
IndexAdvanceX.clear(); IndexAdvanceX.clear();
IndexLookup.clear(); IndexLookup.clear();