mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-12 12:31:48 +08:00
Fix path for just created font by description
Fix for issue #64 - linux loading windows font
This commit is contained in:
parent
64728feec3
commit
e631d3999c
@ -2621,23 +2621,25 @@ EmbossDataBase GLGizmoEmboss::create_emboss_data_base() {
|
|||||||
bool GLGizmoEmboss::load_configuration(ModelVolume *volume)
|
bool GLGizmoEmboss::load_configuration(ModelVolume *volume)
|
||||||
{
|
{
|
||||||
if (volume == nullptr) return false;
|
if (volume == nullptr) return false;
|
||||||
if (!volume->text_configuration.has_value()) return false;
|
const std::optional<TextConfiguration> tc_opt = volume->text_configuration;
|
||||||
|
if (!tc_opt.has_value()) return false;
|
||||||
|
const TextConfiguration &tc = *tc_opt;
|
||||||
|
const EmbossStyle &style = tc.style;
|
||||||
|
|
||||||
TextConfiguration &tc = *volume->text_configuration;
|
auto has_same_name = [&style](const EmbossStyleManager::Item &style_item) -> bool {
|
||||||
EmbossStyle &tc_es = tc.style;
|
const EmbossStyle &es = style_item.style;
|
||||||
|
return es.name == style.name;
|
||||||
auto has_same_name = [&tc_es](const EmbossStyleManager::Item &style) -> bool {
|
|
||||||
const EmbossStyle &es = style.style;
|
|
||||||
return es.name == tc_es.name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<wxFont> wx_font_opt;
|
std::optional<wxFont> wx_font_opt;
|
||||||
if (tc_es.type == WxFontUtils::get_actual_type())
|
if (style.type == WxFontUtils::get_actual_type())
|
||||||
wx_font_opt = WxFontUtils::load_wxFont(tc_es.path);
|
wx_font_opt = WxFontUtils::load_wxFont(style.path);
|
||||||
|
bool is_path_changed = false;
|
||||||
if (!wx_font_opt.has_value()) {
|
if (!wx_font_opt.has_value()) {
|
||||||
create_notification_not_valid_font(tc);
|
create_notification_not_valid_font(tc);
|
||||||
// Try create similar wx font
|
// Try create similar wx font
|
||||||
wx_font_opt = WxFontUtils::create_wxFont(tc_es);
|
wx_font_opt = WxFontUtils::create_wxFont(style);
|
||||||
|
is_path_changed = wx_font_opt.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& styles = m_style_manager.get_styles();
|
const auto& styles = m_style_manager.get_styles();
|
||||||
@ -2645,22 +2647,25 @@ bool GLGizmoEmboss::load_configuration(ModelVolume *volume)
|
|||||||
if (it == styles.end()) {
|
if (it == styles.end()) {
|
||||||
// style was not found
|
// style was not found
|
||||||
if (wx_font_opt.has_value())
|
if (wx_font_opt.has_value())
|
||||||
m_style_manager.load_style(tc_es, *wx_font_opt);
|
m_style_manager.load_style(style, *wx_font_opt);
|
||||||
} else {
|
} else {
|
||||||
size_t style_index = it - styles.begin();
|
size_t style_index = it - styles.begin();
|
||||||
if (!m_style_manager.load_style(style_index)) {
|
if (!m_style_manager.load_style(style_index)) {
|
||||||
// can`t load stored style
|
// can`t load stored style
|
||||||
m_style_manager.erase(style_index);
|
m_style_manager.erase(style_index);
|
||||||
if (wx_font_opt.has_value())
|
if (wx_font_opt.has_value())
|
||||||
m_style_manager.load_style(tc_es, *wx_font_opt);
|
m_style_manager.load_style(style, *wx_font_opt);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// stored style is loaded, now set modification of style
|
// stored style is loaded, now set modification of style
|
||||||
m_style_manager.get_style() = tc_es;
|
m_style_manager.get_style() = style;
|
||||||
m_style_manager.set_wx_font(*wx_font_opt);
|
m_style_manager.set_wx_font(*wx_font_opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_path_changed)
|
||||||
|
m_style_manager.get_style().path = WxFontUtils::store_wxFont(*wx_font_opt);
|
||||||
|
|
||||||
m_text = tc.text;
|
m_text = tc.text;
|
||||||
m_volume = volume;
|
m_volume = volume;
|
||||||
return true;
|
return true;
|
||||||
|
@ -194,9 +194,9 @@ const TypeToWeight WxFontUtils::type_to_weight =
|
|||||||
(wxFONTWEIGHT_HEAVY, "heavy")
|
(wxFONTWEIGHT_HEAVY, "heavy")
|
||||||
(wxFONTWEIGHT_EXTRAHEAVY, "extraHeavy");
|
(wxFONTWEIGHT_EXTRAHEAVY, "extraHeavy");
|
||||||
|
|
||||||
std::optional<wxFont> WxFontUtils::create_wxFont(const EmbossStyle &fi)
|
std::optional<wxFont> WxFontUtils::create_wxFont(const EmbossStyle &style)
|
||||||
{
|
{
|
||||||
const FontProp &fp = fi.prop;
|
const FontProp &fp = style.prop;
|
||||||
double point_size = static_cast<double>(fp.size_in_mm);
|
double point_size = static_cast<double>(fp.size_in_mm);
|
||||||
wxFontInfo info(point_size);
|
wxFontInfo info(point_size);
|
||||||
if (fp.family.has_value()) {
|
if (fp.family.has_value()) {
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
static std::optional<wxFont> load_wxFont(const std::string &font_descriptor);
|
static std::optional<wxFont> load_wxFont(const std::string &font_descriptor);
|
||||||
|
|
||||||
// Try to create similar font, loaded from 3mf from different Computer
|
// Try to create similar font, loaded from 3mf from different Computer
|
||||||
static std::optional<wxFont> create_wxFont(const EmbossStyle &fi);
|
static std::optional<wxFont> create_wxFont(const EmbossStyle &style);
|
||||||
// update font property by wxFont
|
// update font property by wxFont
|
||||||
static void update_property(FontProp &font_prop, const wxFont &font);
|
static void update_property(FontProp &font_prop, const wxFont &font);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user