mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 11:00:37 +08:00
103 lines
2.9 KiB
C++
103 lines
2.9 KiB
C++
#ifndef slic3r_TextConfiguration_hpp_
|
|
#define slic3r_TextConfiguration_hpp_
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <optional>
|
|
|
|
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
|
|
struct FontItem
|
|
{
|
|
std::string name;
|
|
std::string path;
|
|
enum class Type;
|
|
Type type;
|
|
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)
|
|
{}
|
|
|
|
// define data stored in path
|
|
enum class Type {
|
|
undefined = 0,
|
|
file_path, // TrueTypeFont file loacation on computer - for privacy: path is NOT stored into 3mf
|
|
// wx font descriptors are platform dependent
|
|
wx_win_font_descr, // path is font descriptor generated by wxWidgets on windows
|
|
wx_lin_font_descr, // path is font descriptor generated by wxWidgets on windows
|
|
wx_mac_font_descr // path is font descriptor generated by wxWidgets on windows
|
|
};
|
|
};
|
|
|
|
// Font item name inside list is unique
|
|
// FontList is not map beacuse items order matters (view of list)
|
|
using FontList = std::vector<FontItem>;
|
|
|
|
// define how to create 'Text volume'
|
|
struct TextConfiguration
|
|
{
|
|
// define font
|
|
FontItem font_item;
|
|
|
|
std::string text = "None";
|
|
|
|
TextConfiguration() = default; // optional needs empty constructor
|
|
TextConfiguration(const FontItem &font_item, const std::string &text)
|
|
: font_item(font_item), text(text)
|
|
{}
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif // slic3r_TextConfiguration_hpp_
|