Fix storing of wxFont property which describing font to reconstruct on another computer
This commit is contained in:
parent
b716872702
commit
1e2fe6027d
@ -1256,6 +1256,9 @@ bool GLGizmoEmboss::select_facename(const wxString &facename) {
|
||||
const wxFontEncoding &encoding = m_face_names.encoding;
|
||||
wxFont wx_font(wxFontInfo().FaceName(facename).Encoding(encoding));
|
||||
if (!wx_font.IsOk()) return false;
|
||||
// wx font could change source file by size of font
|
||||
int point_size = static_cast<int>(m_style_manager.get_font_prop().size_in_mm);
|
||||
wx_font.SetPointSize(point_size);
|
||||
if (!m_style_manager.set_wx_font(wx_font)) return false;
|
||||
process();
|
||||
return true;
|
||||
@ -2832,9 +2835,18 @@ void GLGizmoEmboss::create_notification_not_valid_font(
|
||||
const std::string &origin_font_name = origin_family.has_value() ?
|
||||
*origin_family :
|
||||
tc.style.path;
|
||||
const std::string &actual_font_name = actual_family.has_value() ?
|
||||
*actual_family :
|
||||
es.name;
|
||||
|
||||
std::string actual_wx_face_name;
|
||||
if (!actual_family.has_value()) {
|
||||
auto& wx_font = m_style_manager.get_wx_font();
|
||||
if (wx_font.has_value()) {
|
||||
wxString wx_face_name = wx_font->GetFaceName();
|
||||
actual_wx_face_name = std::string((const char *) wx_face_name.ToUTF8());
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &actual_font_name = actual_family.has_value() ? *actual_family :
|
||||
(!actual_wx_face_name.empty() ? actual_wx_face_name : es.path);
|
||||
|
||||
std::string text =
|
||||
GUI::format(_L("Can't load exactly same font(\"%1%\"), "
|
||||
|
@ -474,6 +474,7 @@ bool EmbossStyleManager::set_wx_font(const wxFont &wx_font, std::unique_ptr<Embo
|
||||
style.type = WxFontUtils::get_actual_type();
|
||||
// update string path
|
||||
style.path = WxFontUtils::store_wxFont(wx_font);
|
||||
WxFontUtils::update_property(style.prop, wx_font);
|
||||
clear_imgui_font();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,14 @@ EmbossStyle WxFontUtils::create_emboss_style(const wxFont &font, const std::stri
|
||||
EmbossStyle::Type type = get_actual_type();
|
||||
|
||||
// synchronize font property with actual font
|
||||
FontProp font_prop;
|
||||
FontProp font_prop;
|
||||
|
||||
// The point size is defined as 1/72 of the Anglo-Saxon inch (25.4 mm): it
|
||||
// is approximately 0.0139 inch or 352.8 um. But it is too small, so I
|
||||
// decide use point size as mm for emboss
|
||||
font_prop.size_in_mm = font.GetPointSize(); // *0.3528f;
|
||||
font_prop.emboss = font_prop.size_in_mm / 2.f;
|
||||
|
||||
WxFontUtils::update_property(font_prop, font);
|
||||
return { name_item, fontDesc, type, font_prop };
|
||||
}
|
||||
@ -129,7 +136,7 @@ EmbossStyle WxFontUtils::get_os_font()
|
||||
wxFont font = wxSystemSettings::GetFont(system_font);
|
||||
EmbossStyle es = create_emboss_style(font);
|
||||
es.name += std::string(" (OS default)");
|
||||
return create_emboss_style(font);
|
||||
return es;
|
||||
}
|
||||
|
||||
std::string WxFontUtils::get_human_readable_name(const wxFont &font)
|
||||
@ -233,13 +240,7 @@ std::optional<wxFont> WxFontUtils::create_wxFont(const EmbossStyle &style)
|
||||
|
||||
void WxFontUtils::update_property(FontProp &font_prop, const wxFont &font)
|
||||
{
|
||||
// The point size is defined as 1/72 of the Anglo-Saxon inch (25.4 mm): it
|
||||
// is approximately 0.0139 inch or 352.8 um. But it is too small, so I
|
||||
// decide use point size as mm for emboss
|
||||
font_prop.size_in_mm = font.GetPointSize(); // *0.3528f;
|
||||
font_prop.emboss = font_prop.size_in_mm / 2.f;
|
||||
|
||||
wxString wx_face_name = font.GetFaceName();
|
||||
wxString wx_face_name = font.GetFaceName();
|
||||
std::string face_name((const char *) wx_face_name.ToUTF8());
|
||||
if (!face_name.empty()) font_prop.face_name = face_name;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
// Try to create similar font, loaded from 3mf from different Computer
|
||||
static std::optional<wxFont> create_wxFont(const EmbossStyle &style);
|
||||
// update font property by wxFont
|
||||
// update font property by wxFont - without emboss depth and font size
|
||||
static void update_property(FontProp &font_prop, const wxFont &font);
|
||||
|
||||
static bool is_italic(const wxFont &font);
|
||||
|
Loading…
Reference in New Issue
Block a user