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. Cherry picked commit: 120a85d4c4b90ffafced442ee5e63e5f794f6945
This commit is contained in:
parent
96c5744684
commit
c11948a084
@ -184,9 +184,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()),
|
||||
return { boost::nowide::narrow(name.c_str()),
|
||||
boost::nowide::narrow(path.c_str()),
|
||||
FontItem::Type::file_path, FontProp());
|
||||
FontItem::Type::file_path, FontProp() };
|
||||
}
|
||||
|
||||
ExPolygons Private::dilate_to_unique_points(ExPolygons &expolygons)
|
||||
|
@ -3395,10 +3395,10 @@ std::optional<TextConfiguration> TextConfigurationSerialization::read(const char
|
||||
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(style_name, font_descriptor, type, fp);
|
||||
FontItem fi{ style_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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,22 +122,13 @@ 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 {
|
||||
|
@ -1912,7 +1912,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;
|
||||
|
@ -101,7 +101,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,
|
||||
|
@ -121,7 +121,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…
Reference in New Issue
Block a user