Move font property inside of font item to store together with font
This commit is contained in:
parent
ce1df3eada
commit
ef6860d4ee
8 changed files with 259 additions and 156 deletions
|
@ -7,6 +7,45 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
// user defined font property
|
||||
struct FontProp
|
||||
{
|
||||
// define extra space between letters, negative mean closer letter
|
||||
std::optional<int> char_gap;
|
||||
// define extra space between lines, negative mean closer lines
|
||||
std::optional<int> line_gap;
|
||||
// Z depth of text [in mm]
|
||||
float emboss;
|
||||
|
||||
// positive value mean wider character shape
|
||||
// negative value mean tiner character shape
|
||||
std::optional<float> boldness; // [in mm]
|
||||
|
||||
// positive value mean italic of character (CW)
|
||||
// negative value mean CCW skew (unItalic)
|
||||
std::optional<float> skew;
|
||||
|
||||
// TODO: add enum class Align: center/left/right
|
||||
|
||||
//////
|
||||
// Duplicit data to wxFontDescriptor
|
||||
// used for store/load .3mf file
|
||||
//////
|
||||
|
||||
// Height of letter [in mm],
|
||||
// duplicit to wxFont::PointSize
|
||||
float size_in_mm;
|
||||
// Define type of font
|
||||
std::optional<std::string> family;
|
||||
std::optional<std::string> face_name;
|
||||
std::optional<std::string> style;
|
||||
std::optional<std::string> weight;
|
||||
|
||||
FontProp(float line_height = 10.f, float depth = 2.f)
|
||||
: emboss(depth), size_in_mm(line_height)
|
||||
{}
|
||||
};
|
||||
|
||||
// represent selected font
|
||||
// Name must be human readable is visible in gui
|
||||
// (Path + Type) must define how to open font for using on different OS
|
||||
|
@ -16,10 +55,17 @@ struct FontItem
|
|||
std::string path;
|
||||
enum class Type;
|
||||
Type type;
|
||||
FontProp prop;
|
||||
|
||||
FontItem() : type(Type::undefined){} // set undefined type
|
||||
FontItem(const std::string &name, const std::string &path, Type type)
|
||||
: name(name), path(path), type(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)
|
||||
{}
|
||||
|
||||
// define data stored in path
|
||||
|
@ -32,60 +78,19 @@ struct FontItem
|
|||
wx_mac_font_descr // path is font descriptor generated by wxWidgets on windows
|
||||
};
|
||||
};
|
||||
using FontList = std::vector<FontItem>;
|
||||
|
||||
// user defined font property
|
||||
struct FontProp
|
||||
{
|
||||
// define extra space between letters, negative mean closer letter
|
||||
std::optional<int> char_gap = 0;
|
||||
// define extra space between lines, negative mean closer lines
|
||||
std::optional<int> line_gap = 0;
|
||||
// Z depth of text [in mm]
|
||||
float emboss = 5;
|
||||
|
||||
// positive value mean wider character shape
|
||||
// negative value mean tiner character shape
|
||||
std::optional<float> boldness = 0.f; // [in mm]
|
||||
|
||||
// positive value mean italic of character (CW)
|
||||
// negative value mean CCW skew (unItalic)
|
||||
std::optional<float> skew = 0.f;
|
||||
|
||||
// TODO: add enum class Align: center/left/right
|
||||
|
||||
//////
|
||||
// Duplicit data to wxFontDescriptor
|
||||
// used for store/load .3mf file
|
||||
//////
|
||||
|
||||
// Height of letter [in mm],
|
||||
// duplicit to wxFont::PointSize
|
||||
float size_in_mm = 10;
|
||||
// Define type of font
|
||||
std::optional<std::string> family;
|
||||
std::optional<std::string> face_name;
|
||||
std::optional<std::string> style;
|
||||
std::optional<std::string> weight;
|
||||
|
||||
FontProp() = default;
|
||||
};
|
||||
using FontList = std::vector<FontItem>;
|
||||
|
||||
// define how to create 'Text volume'
|
||||
struct TextConfiguration
|
||||
{
|
||||
// define font
|
||||
FontItem font_item;
|
||||
// user modification of font
|
||||
FontProp font_prop;
|
||||
|
||||
std::string text = "None";
|
||||
|
||||
TextConfiguration() = default; // optional needs empty constructor
|
||||
TextConfiguration(const FontItem & font_item,
|
||||
const FontProp & font_prop,
|
||||
const std::string &text)
|
||||
: font_item(font_item), font_prop(font_prop), text(text)
|
||||
TextConfiguration(const FontItem &font_item, const std::string &text)
|
||||
: font_item(font_item), text(text)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue