diff --git a/src/slic3r/GUI/FirmwareDialog.cpp b/src/slic3r/GUI/FirmwareDialog.cpp index a9969802f..afa15f43f 100644 --- a/src/slic3r/GUI/FirmwareDialog.cpp +++ b/src/slic3r/GUI/FirmwareDialog.cpp @@ -726,7 +726,7 @@ const char* FirmwareDialog::priv::avr109_dev_name(Avr109Pid usb_pid) { return "Prusa MMU 2.0 Control"; break; case USB_PID_CW1_BOOT: - return "Prusa CurWa"; + return "Original Prusa CW1"; break; default: throw std::runtime_error((boost::format("Invalid avr109 device USB PID: %1%") % usb_pid.boot).str()); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index 754e69351..e978dc466 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "libslic3r/Config.hpp" @@ -113,6 +115,32 @@ int get_dpi_for_window(wxWindow *window) #endif } +wxFont get_default_font_for_dpi(int dpi) +{ +#ifdef _WIN32 + // First try to load the font with the Windows 10 specific way. + struct SystemParametersInfoForDpi_t { typedef BOOL (WINAPI *FN)(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni, UINT dpi); }; + static auto SystemParametersInfoForDpi_fn = winapi_get_function(L"User32.dll", "SystemParametersInfoForDpi"); + if (SystemParametersInfoForDpi_fn != nullptr) { + NONCLIENTMETRICS nm; + memset(&nm, 0, sizeof(NONCLIENTMETRICS)); + nm.cbSize = sizeof(NONCLIENTMETRICS); + if (SystemParametersInfoForDpi_fn(SPI_GETNONCLIENTMETRICS, 0, &nm, 0, dpi)) { + wxNativeFontInfo info; + info.lf = nm.lfMessageFont; + return wxFont(info); + } + } + // Then try to guesstimate the font DPI scaling on Windows 8. + // Let's hope that the font returned by the SystemParametersInfo(), which is used by wxWidgets internally, makes sense. + int dpi_primary = get_dpi_for_window(nullptr); + if (dpi_primary != dpi) { + // Rescale the font. + return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scaled(float(dpi) / float(dpi_primary)); + } +#endif + return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); +} CheckboxFileDialog::ExtraPanel::ExtraPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 9577cebf4..a17bbf6d3 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -34,6 +34,7 @@ void on_window_geometry(wxTopLevelWindow *tlw, std::function callback); enum { DPI_DEFAULT = 96 }; int get_dpi_for_window(wxWindow *window); +wxFont get_default_font_for_dpi(int dpi); struct DpiChangedEvent : public wxEvent { int dpi; @@ -58,12 +59,10 @@ public: const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxFrameNameStr) : P(parent, id, title, pos, size, style, name) { - m_scale_factor = (float)get_dpi_for_window(this) / (float)DPI_DEFAULT; + int dpi = get_dpi_for_window(this); + m_scale_factor = (float)dpi / (float)DPI_DEFAULT; m_prev_scale_factor = m_scale_factor; - float scale_primary_display = (float)get_dpi_for_window(nullptr) / (float)DPI_DEFAULT; - m_normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - if (std::abs(m_scale_factor - scale_primary_display) > 1e-6) - m_normal_font = m_normal_font.Scale(m_scale_factor / scale_primary_display); + m_normal_font = get_default_font_for_dpi(dpi); // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window. m_em_unit = std::max(10, this->GetTextExtent("m").x - 1);