mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-05-21 21:19:03 -05:00
fix: Pixel perfect font not scaling correctly
This commit is contained in:
@@ -1030,11 +1030,16 @@ namespace hex {
|
||||
void Font::push(float size) const {
|
||||
auto font = getFont(m_fontName);
|
||||
|
||||
if (size <= 0.0F && font != nullptr) {
|
||||
size = font->LegacySize;
|
||||
}
|
||||
if (font != nullptr) {
|
||||
if (size <= 0.0F) {
|
||||
size = font->LegacySize;
|
||||
}
|
||||
|
||||
size *= System::getGlobalScale();
|
||||
if (!font->Sources[0]->PixelSnapH)
|
||||
size *= System::getGlobalScale();
|
||||
else
|
||||
size *= std::floor(System::getGlobalScale());
|
||||
}
|
||||
|
||||
ImGui::PushFont(font, size);
|
||||
}
|
||||
|
||||
@@ -1283,8 +1283,8 @@ namespace hex {
|
||||
|
||||
io.UserData = &m_imguiCustomData;
|
||||
|
||||
auto scale = ImHexApi::System::getGlobalScale();
|
||||
style.ScaleAllSizes(scale);
|
||||
style.ScaleAllSizes(ImHexApi::System::getGlobalScale());
|
||||
auto scale = ImHexApi::System::getNativeScale();
|
||||
io.DisplayFramebufferScale = ImVec2(scale, scale);
|
||||
|
||||
style.WindowMenuButtonPosition = ImGuiDir_None;
|
||||
|
||||
@@ -36,19 +36,21 @@ namespace hex::fonts {
|
||||
|
||||
std::memcpy(config.Name, name.get().c_str(), std::min(name.get().size(), sizeof(config.Name) - 1));
|
||||
|
||||
if (settings.isBold())
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_Bold;
|
||||
if (settings.isItalic())
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_Oblique;
|
||||
switch (settings.getAntialiasingType()) {
|
||||
case AntialiasingType::None:
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_Monochrome | ImGuiFreeTypeLoaderFlags_MonoHinting;
|
||||
break;
|
||||
case AntialiasingType::Grayscale:
|
||||
break;
|
||||
case AntialiasingType::Lcd:
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_SubPixel;
|
||||
break;
|
||||
if (!settings.isPixelPerfectFont()) {
|
||||
if (settings.isBold())
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_Bold;
|
||||
if (settings.isItalic())
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_Oblique;
|
||||
switch (settings.getAntialiasingType()) {
|
||||
case AntialiasingType::None:
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_Monochrome | ImGuiFreeTypeLoaderFlags_MonoHinting;
|
||||
break;
|
||||
case AntialiasingType::Grayscale:
|
||||
break;
|
||||
case AntialiasingType::Lcd:
|
||||
config.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_SubPixel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -57,9 +59,11 @@ namespace hex::fonts {
|
||||
*imguiFont = atlas->AddFontFromFileTTF(fontPath.string().c_str(), 0.0F, &config);
|
||||
|
||||
if (*imguiFont == nullptr) {
|
||||
if (settings.isPixelPerfectFont())
|
||||
*imguiFont = atlas->AddFontDefault();
|
||||
else {
|
||||
if (settings.isPixelPerfectFont()) {
|
||||
auto defaultConfig = config;
|
||||
defaultConfig.SizePixels = ImHexApi::Fonts::DefaultFontSize;
|
||||
*imguiFont = atlas->AddFontDefault(&defaultConfig);
|
||||
} else {
|
||||
static auto jetbrainsFont = romfs::get("fonts/JetBrainsMono.ttf");
|
||||
*imguiFont = atlas->AddFontFromMemoryTTF(const_cast<u8 *>(jetbrainsFont.data<u8>()), jetbrainsFont.size(), 0.0F, &config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user