mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 21:26:05 +08:00
FontItem improvmement: Use default constructors to let the compiler
generate move constructor and move assignement. Also used some move operators to reduce unnecessary memory allocations.
This commit is contained in:
parent
5a1cbbc4ba
commit
120a85d4c4
@ -188,9 +188,9 @@ std::optional<Emboss::Glyph> Private::get_glyph(
|
||||
}
|
||||
|
||||
FontItem Private::create_font_item(std::wstring name, std::wstring path) {
|
||||
return FontItem(boost::nowide::narrow(name.c_str()),
|
||||
boost::nowide::narrow(path.c_str()),
|
||||
FontItem::Type::file_path, FontProp());
|
||||
return { boost::nowide::narrow(name.c_str()),
|
||||
boost::nowide::narrow(path.c_str()),
|
||||
FontItem::Type::file_path, FontProp() };
|
||||
}
|
||||
|
||||
ExPolygons Private::dilate_to_unique_points(ExPolygons &expolygons)
|
||||
|
@ -3374,14 +3374,14 @@ std::optional<TextConfiguration> TextConfigurationSerialization::read(const char
|
||||
std::string weight = get_attribute_value_string(attributes, num_attributes, FONT_WEIGHT_ATTR);
|
||||
if (!weight.empty()) fp.weight = weight;
|
||||
|
||||
std::string font_name = "";
|
||||
std::string font_name {};
|
||||
std::string font_descriptor = get_attribute_value_string(attributes, num_attributes, FONT_DESCRIPTOR_ATTR);
|
||||
std::string type_str = get_attribute_value_string(attributes, num_attributes, FONT_DESCRIPTOR_TYPE_ATTR);
|
||||
FontItem::Type type = TextConfigurationSerialization::get_type(type_str);
|
||||
FontItem fi(font_name, font_descriptor, type, fp);
|
||||
FontItem fi{ font_name, std::move(font_descriptor), type, std::move(fp) };
|
||||
|
||||
std::string text = get_attribute_value_string(attributes, num_attributes, TEXT_DATA_ATTR);
|
||||
return TextConfiguration(fi, text);
|
||||
return TextConfiguration(std::move(fi), std::move(text));
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,22 +118,11 @@ struct FontItem
|
||||
|
||||
enum class Type;
|
||||
// Define what is stored in path
|
||||
Type type;
|
||||
Type type { Type::undefined };
|
||||
|
||||
// User modification of font style
|
||||
FontProp prop;
|
||||
|
||||
FontItem() : type(Type::undefined){} // set undefined type
|
||||
|
||||
// when name is empty than Font item was loaded from .3mf file
|
||||
// and potentionaly it is not reproducable
|
||||
FontItem(const std::string &name,
|
||||
const std::string &path,
|
||||
Type type,
|
||||
const FontProp & prop)
|
||||
: name(name), path(path), type(type), prop(prop) // copy values
|
||||
{}
|
||||
|
||||
// define data stored in path
|
||||
// when wx change way of storing add new descriptor Type
|
||||
enum class Type {
|
||||
|
@ -1824,7 +1824,7 @@ bool GLGizmoEmboss::choose_true_type_file()
|
||||
std::string name = get_file_name(path);
|
||||
//make_unique_name(name, m_font_list);
|
||||
const FontProp& prop = m_font_manager.get_font_prop();
|
||||
FontItem fi(name, path, FontItem::Type::file_path, prop);
|
||||
FontItem fi{ name, path, FontItem::Type::file_path, prop };
|
||||
m_font_manager.add_font(fi);
|
||||
// set first valid added font as active
|
||||
if (m_font_manager.load_font(index)) return true;
|
||||
|
@ -87,7 +87,7 @@ std::optional<FontItem> FontListSerializable::load_font_item(
|
||||
read(app_cfg_section, APP_CONFIG_FONT_LINE_GAP, fp.line_gap);
|
||||
|
||||
FontItem::Type type = WxFontUtils::get_actual_type();
|
||||
return FontItem(name, path, type, fp);
|
||||
return FontItem{ name, path, type, fp };
|
||||
}
|
||||
|
||||
void FontListSerializable::store_font_item(AppConfig & cfg,
|
||||
|
@ -96,7 +96,7 @@ FontItem WxFontUtils::get_font_item(const wxFont &font, const std::string& name)
|
||||
// synchronize font property with actual font
|
||||
FontProp font_prop;
|
||||
WxFontUtils::update_property(font_prop, font);
|
||||
return FontItem(name_item, fontDesc, type, font_prop);
|
||||
return { name_item, fontDesc, type, font_prop };
|
||||
}
|
||||
|
||||
FontItem WxFontUtils::get_os_font()
|
||||
|
Loading…
x
Reference in New Issue
Block a user