42 Font(
const std::string & _family=
"Helvetica",
int _size=15,
43 const std::string & _color=
"black",
bool _bold=
false,
bool _italic=
false)
44 : family(_family), size(_size), color(_color)
45 , is_bold(_bold), is_italic(_italic), is_smallcaps(false)
46 , is_underlined(false), is_overlined(false), is_linethrough(false), is_wavy_line(false) { ; }
47 Font(
int _size,
const std::string & _color=
"black",
bool _bold=
false,
bool _italic=
false)
48 :
Font(
"Helvetica", _size, _color, _bold, _italic) { ; }
67 Font &
SetFamily(
const std::string & _family) { family = _family;
return *
this; }
69 Font &
SetColor(
const std::string & _color) { color = _color;
return *
this; }
71 Font &
SetBold(
bool _in=
true) { is_bold = _in;
return *
this; }
81 style.
Set(
"color", color);
82 style.
Set(
"font-family", family);
84 if (is_bold) style.
Set(
"font-weight",
"bold");
85 if (is_italic) style.
Set(
"font-style",
"italic");
86 if (is_smallcaps) style.
Set(
"font-variant",
"small-caps");
88 std::string decoration(
"");
89 if (is_underlined) decoration +=
" underline";
90 if (is_overlined) decoration +=
" overline";
91 if (is_linethrough) decoration +=
" line-through";
92 if (line_color !=
"") { decoration +=
" "; decoration +=
line_color; }
93 if (is_wavy_line) decoration +=
" wavy";
94 style.
Set(
"text-decoration", decoration);
105 std::stringstream ss;
106 ss <<
"<span style=\"color:" << color
107 <<
"; font-family:" << family
108 <<
"; font-size:" <<
size;
109 if (is_bold) ss <<
"; font-weight:bold";
110 if (is_italic) ss <<
"; font-style:italic";
111 if (is_smallcaps) ss <<
"; font-variant:small-caps";
113 ss <<
"; text-decoration:";
114 if (is_underlined) ss <<
" underline";
115 if (is_overlined) ss <<
" overline";
116 if (is_linethrough) ss <<
" line-through";
117 if (line_color !=
"") ss <<
" " <<
line_color;
118 if (is_wavy_line) ss <<
" wavy";
126 return (family == _in.
family)
127 && (size == _in.
size)
128 && (color == _in.
color)
void ConfigStyle(Style &style) const
Take a Style object an fill it out based on this font information.
Definition: Font.h:80
Font(const std::string &_family="Helvetica", int _size=15, const std::string &_color="black", bool _bold=false, bool _italic=false)
Definition: Font.h:42
Font & SetSize(int _size)
Definition: Font.h:68
Font & SetWavyLine(bool _in=true)
Definition: Font.h:77
bool is_underlined
Should this text be underlined?
Definition: Font.h:34
const std::string & GetFamily() const
Definition: Font.h:54
std::string to_string(ALL_TYPES &&...all_values)
Definition: string_utils.h:511
Font(int _size, const std::string &_color="black", bool _bold=false, bool _italic=false)
Definition: Font.h:47
bool is_smallcaps
Should this test be in small caps?
Definition: Font.h:33
Font & SetItalic(bool _in=true)
Definition: Font.h:72
Font & SetOverlined(bool _in=true)
Definition: Font.h:75
int GetSize() const
Definition: Font.h:55
Style & Set(const std::string &s, SET_TYPE v)
Record that setting "s" is set to value "v" (converted to string) and return this object...
Definition: Style.h:50
const std::string & GetColor() const
Definition: Font.h:56
Font(const Font &)=default
bool operator!=(const Font &_in) const
Definition: Font.h:139
bool is_linethrough
Should this text have a line through it?
Definition: Font.h:36
Font & SetColor(const std::string &_color)
Definition: Font.h:69
std::string GetHTMLStart()
Definition: Font.h:104
bool IsSmallcaps() const
Definition: Font.h:60
bool IsStrikethrough() const
Definition: Font.h:63
std::string GetHTMLEnd()
Definition: Font.h:123
Tools to dynamically build (and cache) color maps.
bool is_italic
Is this font itaic?
Definition: Font.h:32
~Font()
Definition: Font.h:49
Font & SetSmallcaps(bool _in=true)
Definition: Font.h:73
bool IsWavyLine() const
Definition: Font.h:64
Font & SetLineColor(const std::string &_color)
Definition: Font.h:70
Font & SetBold(bool _in=true)
Definition: Font.h:71
Font & SetStrikethrough(bool _in=true)
Definition: Font.h:76
bool IsUnderlined() const
Definition: Font.h:61
std::string family
Font family to use.
Definition: Font.h:26
bool is_bold
Is this font bold?
Definition: Font.h:31
std::string line_color
Color of lines through the text (underline, linethrough, etc.)
Definition: Font.h:29
bool HasLine() const
Definition: Font.h:65
If we are in emscripten, make sure to include the header.
Definition: array.h:37
bool is_overlined
Should this text have a line above it?
Definition: Font.h:35
Style AsStyle() const
Definition: Font.h:98
Font & SetUnderlined(bool _in=true)
Definition: Font.h:74
const std::string & GetLineColor() const
Definition: Font.h:57
bool operator==(const Font &_in) const
Definition: Font.h:125
bool IsOverlined() const
Definition: Font.h:62
int size
Font size (in px) to use.
Definition: Font.h:27
Font & operator=(const Font &)=default
bool is_wavy_line
Should lines be made wavy?
Definition: Font.h:37
std::string color
Font color.
Definition: Font.h:28
Font & SetFamily(const std::string &_family)
Definition: Font.h:67
Maintain information about an HTML font.
Definition: Font.h:24
A CSS class for tracking font style, etc.
bool IsBold() const
Definition: Font.h:58
bool IsItalic() const
Definition: Font.h:59