From 3ec78c4ccf4a3bc6caa12044ae217a75a5e47169 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 15 Dec 2021 11:00:47 +0100 Subject: MsgDialog: Fix for scale of the message size, when mainframe wasn't created yet but InfoDialog is shown --- src/slic3r/GUI/MsgDialog.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 6484ead73..a70a9b172 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -147,6 +147,20 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin // calculate html page size from text wxSize page_size; int em = wxGetApp().em_unit(); + if (!wxGetApp().mainframe) { + // If mainframe is nullptr, it means that GUI_App::on_init_inner() isn't completed + // (We just show information dialog about configuration version now) + // And as a result the em_unit value wasn't created yet + // So, calculate it from the scale factor of Dialog +#if defined(__WXGTK__) + // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3). + // So, initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window. + em = std::max(10, parent->GetTextExtent("m").x - 1); +#else + double scale_factor = (double)get_dpi_for_window(parent) / (double)DPI_DEFAULT; + em = std::max(10, 10.0f * scale_factor); +#endif // __WXGTK__ + } // if message containes the table if (msg.Contains("")) { -- cgit v1.2.3