font_description.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Mark Page
27 ** Harry Storbacka
28 */
29
30
31 #pragma once
32
33 #include <memory>
34
35 namespace clan
36 {
39
40 class DisplayWindow;
41 class FontDescription_Impl;
42
43 enum class FontWeight : int
44 {
45 thin = 100,
46 extra_light = 200,
47 light = 300,
48 normal = 400,
49 medium = 500,
50 semi_bold = 600,
51 bold = 700,
52 extra_bold = 800,
53 heavy = 900
54 };
55
56 enum class FontStyle
57 {
58 normal,
59 italic,
60 oblique // Currently not supported by ClanLib
61 };
62
66 class FontDescription
67 {
70
71 public:
73 FontDescription();
74
75 virtual ~FontDescription();
76
80 static FontDescription create_null_object();
81
85
86 public:
87
88 enum Charset
89 {
90 charset_default,
91 charset_ansi,
92 charset_baltic,
93 charset_chinesebig5,
94 charset_easteurope,
95 charset_gb2312,
96 charset_greek,
97 charset_hangul,
98 charset_mac,
99 charset_oem,
100 charset_russian,
101 charset_shiftjis,
102 charset_symbol,
103 charset_turkish,
104 charset_vietnamese,
105 charset_johab,
106 charset_arabic,
107 charset_hebrew,
108 charset_thai
109 };
110
112 bool is_null() const { return !impl; }
113
115 void throw_if_null() const;
116
118 float get_height() const;
119
121 float get_line_height() const;
122
126 float get_average_width() const;
127
129 float get_escapement() const;
130
132 float get_orientation() const;
133
135 FontWeight get_weight() const;
136
138 FontStyle get_style() const;
139
141 bool get_anti_alias() const;
142
144 bool get_subpixel() const;
145
147 Charset get_charset() const;
148
151 bool operator==(const FontDescription &other) const;
152
157 std::string get_unique_id() const;
158
162
163 public:
165 FontDescription &operator =(const FontDescription &copy);
166
167 // \brief Copy the entire font description (not just the implementation)
168 FontDescription clone() const;
169
171 void set_height(float value = 20.0f);
172
176 void set_average_width(float value = 0.0f);
177
179 void set_escapement(float value);
180
182 void set_orientation(float value);
183
185 void set_weight(FontWeight value = FontWeight::normal);
186
188 void set_line_height(float height);
189
191 void set_style(FontStyle setting = FontStyle::normal);
192
194 void set_anti_alias(bool setting = true);
195
197 void set_subpixel(bool setting = true);
198
202 void set_charset(Charset new_charset);
203
207
208 private:
209 std::shared_ptr<FontDescription_Impl> impl;
211 };
212
213 }
214
216
clan::FontDescription::get_charset
Charset get_charset() const
Get the font charset
clan::FontWeight::extra_light
clan
Definition: clanapp.h:35
clan::FontDescription::charset_hangul
Definition: font_description.h:97
clan::FontDescription
Font description class.
Definition: font_description.h:66
clan::FontDescription::charset_mac
Definition: font_description.h:98
clan::FontDescription::charset_russian
Definition: font_description.h:100
clan::FontDescription::charset_turkish
Definition: font_description.h:103
clan::FontDescription::charset_shiftjis
Definition: font_description.h:101
clan::FontDescription::charset_greek
Definition: font_description.h:96
clan::FontWeight::medium
clan::FontDescription::get_orientation
float get_orientation() const
Returns the font orientation.
clan::FontDescription::charset_easteurope
Definition: font_description.h:94
clan::FontDescription::charset_ansi
Definition: font_description.h:91
clan::FontDescription::set_anti_alias
void set_anti_alias(bool setting=true)
Sets the font anti-alias setting (defaults to true)
clan::FontWeight
FontWeight
Definition: font_description.h:43
clan::FontDescription::charset_thai
Definition: font_description.h:108
clan::FontDescription::get_line_height
float get_line_height() const
Returns the distance between each line.
clan::FontStyle::oblique
clan::FontDescription::get_escapement
float get_escapement() const
Returns the font escapement.
clan::FontDescription::charset_johab
Definition: font_description.h:105
clan::FontDescription::charset_chinesebig5
Definition: font_description.h:93
clan::FontDescription::is_null
bool is_null() const
Returns true if this object is invalid.
Definition: font_description.h:112
clan::FontDescription::set_orientation
void set_orientation(float value)
Sets the font orientation.
clan::FontDescription::set_escapement
void set_escapement(float value)
Sets the font escapement.
clan::FontDescription::get_unique_id
std::string get_unique_id() const
Returns an unique string identifying this font description.
clan::FontDescription::charset_gb2312
Definition: font_description.h:95
clan::FontDescription::charset_symbol
Definition: font_description.h:102
clan::StyleTokenType::string
@ keyword
clan::FontDescription::~FontDescription
virtual ~FontDescription()
clan::FontDescription::set_charset
void set_charset(Charset new_charset)
Sets the font charset (defaults to charset_default)
clan::FontDescription::set_weight
void set_weight(FontWeight value=FontWeight::normal)
Sets the font weight.
clan::FontDescription::get_subpixel
bool get_subpixel() const
Get the font subpixel rendering setting (defaults to true)
clan::FontDescription::create_null_object
static FontDescription create_null_object()
Create null object.
clan::FontDescription::throw_if_null
void throw_if_null() const
Throw an exception if this object is invalid.
clan::Key::f
clan::FontWeight::normal
clan::FontDescription::charset_arabic
Definition: font_description.h:106
clan::FontStyle
FontStyle
Definition: font_description.h:56
clan::FontWeight::semi_bold
clan::FontDescription::charset_vietnamese
Definition: font_description.h:104
clan::FontWeight::thin
clan::FontDescription::clone
FontDescription clone() const
clan::FontStyle::italic
clan::FontWeight::bold
clan::FontDescription::set_line_height
void set_line_height(float height)
Sets the distance between each line.
clan::FontDescription::set_subpixel
void set_subpixel(bool setting=true)
Sets the font subpixel rendering setting (defaults to true)
clan::FontDescription::charset_baltic
Definition: font_description.h:92
clan::FontDescription::get_weight
FontWeight get_weight() const
Returns the font weight.
clan::FontDescription::get_average_width
float get_average_width() const
Returns the font average width.
clan::FontDescription::set_style
void set_style(FontStyle setting=FontStyle::normal)
Sets the font style.
clan::FontDescription::FontDescription
FontDescription()
Constructs a font description with default values.
clan::FontDescription::charset_default
Definition: font_description.h:90
clan::FontWeight::extra_bold
clan::FontDescription::set_height
void set_height(float value=20.0f)
Sets the font height.
clan::FontWeight::light
clan::FontDescription::operator=
FontDescription & operator=(const FontDescription &copy)
Copy assignment operator (does not copy the description, use clone() if you want that) ...
clan::FontDescription::charset_hebrew
Definition: font_description.h:107
clan::FontDescription::Charset
Charset
Definition: font_description.h:88
clan::FontDescription::operator==
bool operator==(const FontDescription &other) const
Returns true if the font is identical Line_height is excluded.
clan::FontDescription::get_height
float get_height() const
Returns the font height.
clan::FontStyle::normal
clan::FontWeight::heavy
clan::FontDescription::charset_oem
Definition: font_description.h:99
clan::FontDescription::set_average_width
void set_average_width(float value=0.0f)
Sets the font average width.
clan::FontDescription::get_anti_alias
bool get_anti_alias() const
Get the font anti-alias setting (defaults to true)
clan::FontDescription::get_style
FontStyle get_style() const
Returns the font style.