mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 15:55:51 +08:00
Allow font scaling
+ Fix for em_unit in respect to the scaled font + TextInput: Fix for non-default size
This commit is contained in:
parent
c0aef5ff0a
commit
a4767695ea
@ -94,8 +94,10 @@ public:
|
||||
m_prev_scale_factor = m_scale_factor;
|
||||
m_normal_font = get_default_font_for_dpi(this, dpi);
|
||||
|
||||
if (font_point_size > 0)
|
||||
if (font_point_size > 0) {
|
||||
m_font_size = font_point_size;
|
||||
m_normal_font.SetPointSize(font_point_size);
|
||||
}
|
||||
|
||||
/* Because of default window font is a primary display font,
|
||||
* We should set correct font for window before getting em_unit value.
|
||||
@ -111,7 +113,7 @@ public:
|
||||
// Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
|
||||
// So, calculate the m_em_unit value from the font size, as before
|
||||
#if !defined(__WXGTK__)
|
||||
m_em_unit = std::max<size_t>(10, 10.0f * m_scale_factor);
|
||||
m_em_unit = std::max<size_t>(10/*m_font_size*/, int(m_scale_factor * m_font_size));
|
||||
#else
|
||||
// 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<size_t>(10, this->GetTextExtent("m").x - 1);
|
||||
@ -178,7 +180,6 @@ public:
|
||||
float prev_scale_factor() const { return m_prev_scale_factor; }
|
||||
|
||||
int em_unit() const { return m_em_unit; }
|
||||
// int font_size() const { return m_font_size; }
|
||||
const wxFont& normal_font() const { return m_normal_font; }
|
||||
void enable_force_rescale() { m_force_rescale = true; }
|
||||
|
||||
@ -197,7 +198,7 @@ protected:
|
||||
private:
|
||||
float m_scale_factor;
|
||||
int m_em_unit;
|
||||
// int m_font_size;
|
||||
int m_font_size {10};
|
||||
|
||||
wxFont m_normal_font;
|
||||
float m_prev_scale_factor;
|
||||
@ -206,14 +207,6 @@ private:
|
||||
|
||||
int m_new_font_point_size;
|
||||
|
||||
// void recalc_font()
|
||||
// {
|
||||
// wxClientDC dc(this);
|
||||
// const auto metrics = dc.GetFontMetrics();
|
||||
// m_font_size = metrics.height;
|
||||
// m_em_unit = metrics.averageWidth;
|
||||
// }
|
||||
|
||||
// check if new scale is differ from previous
|
||||
bool is_new_scale_factor() const { return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }
|
||||
|
||||
@ -254,7 +247,7 @@ private:
|
||||
m_normal_font = this->GetFont();
|
||||
|
||||
// update em_unit value for new window font
|
||||
m_em_unit = std::max<int>(10, 10.0f * m_scale_factor);
|
||||
m_em_unit = std::max<int>(m_font_size, int(m_scale_factor * m_font_size));
|
||||
|
||||
// rescale missed controls sizes and images
|
||||
on_dpi_changed(suggested_rect);
|
||||
|
@ -600,7 +600,7 @@ void PreferencesDialog::build()
|
||||
activate_options_tab(m_optgroup_other);
|
||||
|
||||
create_downloader_path_sizer();
|
||||
// create_settings_font_widget();
|
||||
create_settings_font_widget();
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
// Add "Render" tab
|
||||
|
@ -56,7 +56,7 @@ void TextInput::Create(wxWindow * parent,
|
||||
state_handler.attach({&label_color, &text_color});
|
||||
state_handler.update_binds();
|
||||
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE);
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, size, style | wxBORDER_NONE);
|
||||
#ifdef __WXOSX__
|
||||
text_ctrl->OSXDisableAllSmartSubstitutions();
|
||||
#endif // __WXOSX__
|
||||
|
Loading…
x
Reference in New Issue
Block a user