-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImGuiFontWrapper.cpp
More file actions
36 lines (29 loc) · 1.1 KB
/
Copy pathImGuiFontWrapper.cpp
File metadata and controls
36 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "precomp.h"
#include "ImGuiFontWrapper.h"
#include "Settings.h"
#include "Scope.h"
#include "ImguiHelpers.h"
Framework::ImGuiFontWrapper::ImGuiFontWrapper(const std::string& filePathAndSize)
{
std::vector<std::string> pathAndSize = StringFunctions::SplitString(filePathAndSize, ",");
assert(pathAndSize.size() == 1
|| pathAndSize.size() == 2);
mFilePath = pathAndSize[0];
mSizeWithFullQuality = pathAndSize.size() == 1 ? 20.0f : std::stof(pathAndSize[1]);
}
Framework::ImGuiFontWrapper::~ImGuiFontWrapper() = default;
void Framework::ImGuiFontWrapper::SendToImguiFontAtlas()
{
Framework::Settings::Inst().GetSettings().GetVariable("fontQuality") >> mQuality;
mSizeInAtlas = mSizeWithFullQuality * mQuality;
mFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(mFilePath.c_str(), mSizeInAtlas);
mFont->Scale = Framework::ImguiHelpers::sDefaultFontSize / mSizeInAtlas;
if (mFont == ImGui::GetIO().Fonts->Fonts[0])
{
sDefaultFont = this;
}
}
void Framework::ImGuiFontWrapper::SetWindowFontSize(const float size) const
{
ImGui::SetWindowFontScale(size / Framework::ImguiHelpers::sDefaultFontSize);
}