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 
67 {
70 
71 public:
74 
75  virtual ~FontDescription();
76 
81 
85 
86 public:
87 
88  enum Charset
89  {
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 
136 
139 
141  bool get_anti_alias() const;
142 
144  bool get_subpixel() const;
145 
148 
151  bool operator==(const FontDescription &other) const;
152 
157  std::string get_unique_id() const;
158 
162 
163 public:
166 
167  // \brief Copy the entire font description (not just the implementation)
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 
186 
188  void set_line_height(float height);
189 
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 
void set_subpixel(bool setting=true)
Sets the font subpixel rendering setting (defaults to true)
Font description class.
Definition: font_description.h:67
@ charset_chinesebig5
Definition: font_description.h:93
bool get_subpixel() const
Get the font subpixel rendering setting (defaults to true)
void set_escapement(float value)
Sets the font escapement.
Charset
Definition: font_description.h:89
virtual ~FontDescription()
@ charset_oem
Definition: font_description.h:99
@ charset_easteurope
Definition: font_description.h:94
FontStyle get_style() const
Returns the font style.
@ charset_shiftjis
Definition: font_description.h:101
void set_anti_alias(bool setting=true)
Sets the font anti-alias setting (defaults to true)
@ charset_greek
Definition: font_description.h:96
void set_weight(FontWeight value=FontWeight::normal)
Sets the font weight.
float get_line_height() const
Returns the distance between each line.
float get_height() const
Returns the font height.
bool is_null() const
Returns true if this object is invalid.
Definition: font_description.h:112
void set_line_height(float height)
Sets the distance between each line.
FontStyle
Definition: font_description.h:57
bool operator==(const FontDescription &other) const
Returns true if the font is identical Line_height is excluded.
void set_height(float value=20.0f)
Sets the font height.
float get_orientation() const
Returns the font orientation.
std::string get_unique_id() const
Returns an unique string identifying this font description.
bool get_anti_alias() const
Get the font anti-alias setting (defaults to true)
@ charset_arabic
Definition: font_description.h:106
@ charset_symbol
Definition: font_description.h:102
void set_style(FontStyle setting=FontStyle::normal)
Sets the font style.
@ charset_baltic
Definition: font_description.h:92
Definition: clanapp.h:36
FontWeight
Definition: font_description.h:44
float get_escapement() const
Returns the font escapement.
@ charset_default
Definition: font_description.h:90
void set_average_width(float value=0.0f)
Sets the font average width.
@ charset_russian
Definition: font_description.h:100
Charset get_charset() const
\biref Get the font charset
@ charset_hangul
Definition: font_description.h:97
FontDescription & operator=(const FontDescription &copy)
Copy assignment operator (does not copy the description, use clone() if you want that)
@ charset_turkish
Definition: font_description.h:103
void set_orientation(float value)
Sets the font orientation.
FontDescription clone() const
@ charset_thai
Definition: font_description.h:108
void throw_if_null() const
Throw an exception if this object is invalid.
static FontDescription create_null_object()
Create null object.
@ charset_vietnamese
Definition: font_description.h:104
@ charset_hebrew
Definition: font_description.h:107
void set_charset(Charset new_charset)
Sets the font charset (defaults to charset_default)
FontWeight get_weight() const
Returns the font weight.
@ charset_johab
Definition: font_description.h:105
float get_average_width() const
Returns the font average width.
@ charset_mac
Definition: font_description.h:98
@ charset_gb2312
Definition: font_description.h:95
@ charset_ansi
Definition: font_description.h:91
FontDescription()
Constructs a font description with default values.