mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Icon scaling when using pixel perfect font
This commit is contained in:
@@ -57,7 +57,7 @@ namespace hex::fonts {
|
||||
if (fontName.find("icon") != std::string::npos)
|
||||
actualFontSize = ImHexApi::Fonts::pointsToPixels(fontSize);
|
||||
else
|
||||
actualFontSize = fontSize;
|
||||
actualFontSize = fontSize;
|
||||
|
||||
if (FT_Set_Pixel_Sizes(face, actualFontSize, actualFontSize) != 0) {
|
||||
log::fatal("Failed to set pixel size");
|
||||
@@ -187,7 +187,7 @@ namespace hex::fonts {
|
||||
// If there's no custom font set, or it failed to load, fall back to the default font
|
||||
if (!defaultFont.has_value()) {
|
||||
if (pixelPerfectFont) {
|
||||
fontSize = std::max(1.0F, std::floor(ImHexApi::System::getGlobalScale() * ImHexApi::System::getBackingScaleFactor() * 13.0F));
|
||||
realFontSize = fontSize = std::max(1.0F, std::floor(ImHexApi::System::getBackingScaleFactor() * 13.0F));
|
||||
defaultFont = fontAtlas->addDefaultFont();
|
||||
std::string defaultFontName = "Proggy Clean";
|
||||
memcpy(fontAtlas->getAtlas()->ConfigData[fontIndex].Name, defaultFontName.c_str(), defaultFontName.size());
|
||||
|
||||
@@ -101,13 +101,14 @@ namespace hex::fonts {
|
||||
}
|
||||
|
||||
bool SliderPoints::draw(const std::string &name) {
|
||||
float value = ImHexApi::Fonts::pixelsToPoints(m_value);
|
||||
float min = ImHexApi::Fonts::pixelsToPoints(m_min);
|
||||
float max = ImHexApi::Fonts::pixelsToPoints(m_max);
|
||||
auto scaleFactor = ImHexApi::System::getBackingScaleFactor();
|
||||
float value = ImHexApi::Fonts::pixelsToPoints(m_value) * scaleFactor;
|
||||
float min = ImHexApi::Fonts::pixelsToPoints(m_min) * scaleFactor;
|
||||
float max = ImHexApi::Fonts::pixelsToPoints(m_max) * scaleFactor;
|
||||
|
||||
auto changed = ImGui::SliderFloat(name.c_str(), &value, min, max, "%.0f pt");
|
||||
|
||||
m_value = ImHexApi::Fonts::pointsToPixels(value);
|
||||
m_value = ImHexApi::Fonts::pointsToPixels(value / scaleFactor);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user