font_description.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore 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 UICore 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 #pragma once
31 
32 #include <memory>
33 
34 namespace uicore
35 {
36  class DisplayWindow;
37  class FontDescription_Impl;
38 
39  enum class FontWeight : int
40  {
41  thin = 100,
42  extra_light = 200,
43  light = 300,
44  normal = 400,
45  medium = 500,
46  semi_bold = 600,
47  bold = 700,
48  extra_bold = 800,
49  heavy = 900
50  };
51 
52  enum class FontStyle
53  {
54  normal,
55  italic,
56  oblique // Currently not supported by UICore
57  };
58 
63  {
64  public:
67 
68  virtual ~FontDescription();
69 
74 
75  enum Charset
76  {
96  };
97 
99  bool is_null() const { return !impl; }
100 
102  void throw_if_null() const;
103 
105  float height() const;
106 
108  float line_height() const;
109 
113  float average_width() const;
114 
116  float escapement() const;
117 
119  float orientation() const;
120 
122  FontWeight weight() const;
123 
125  FontStyle style() const;
126 
128  bool anti_alias() const;
129 
131  bool subpixel() const;
132 
134  Charset charset() const;
135 
138  bool operator==(const FontDescription &other) const;
139 
144  std::string unique_id() const;
145 
148 
149  // \brief Copy the entire font description (not just the implementation)
150  FontDescription clone() const;
151 
153  void set_height(float value = 20.0f);
154 
158  void set_average_width(float value = 0.0f);
159 
161  void set_escapement(float value);
162 
164  void set_orientation(float value);
165 
168 
170  void set_line_height(float height);
171 
173  void set_style(FontStyle setting = FontStyle::normal);
174 
176  void set_anti_alias(bool setting = true);
177 
179  void set_subpixel(bool setting = true);
180 
184  void set_charset(Charset new_charset);
185 
186  private:
187  std::shared_ptr<FontDescription_Impl> impl;
188  };
189 }
Charset
Definition: font_description.h:75
Definition: font_description.h:85
Definition: font_description.h:86
bool is_null() const
Returns true if this object is invalid.
Definition: font_description.h:99
float escapement() const
Returns the font escapement.
FontWeight
Definition: font_description.h:39
Definition: font_description.h:87
void set_escapement(float value)
Sets the font escapement.
float line_height() const
Returns the distance between each line.
float height() const
Returns the font height.
Definition: font_description.h:82
Definition: font_description.h:90
Definition: font_description.h:89
Definition: font_description.h:77
FontDescription clone() const
void set_height(float value=20.0f)
Sets the font height.
bool operator==(const FontDescription &other) const
Returns true if the font is identical Line_height is excluded.
FontWeight weight() const
Returns the font weight.
Definition: font_description.h:79
bool anti_alias() const
Get the font anti-alias setting (defaults to true)
void set_style(FontStyle setting=FontStyle::normal)
Sets the font style.
std::string unique_id() const
Returns an unique string identifying this font description.
void set_average_width(float value=0.0f)
Sets the font average width.
Definition: font_description.h:78
Definition: font_description.h:92
FontDescription()
Constructs a font description with default values.
Definition: font_description.h:88
void set_orientation(float value)
Sets the font orientation.
FontStyle style() const
Returns the font style.
float orientation() const
Returns the font orientation.
Definition: font_description.h:93
static FontDescription create_null_object()
Create null object.
void set_charset(Charset new_charset)
Sets the font charset (defaults to charset_default)
Definition: font_description.h:84
Definition: font_description.h:94
Definition: font_description.h:91
float average_width() const
Returns the font average width.
void set_line_height(float height)
Sets the distance between each line.
FontDescription & operator=(const FontDescription &copy)
Copy assignment operator (does not copy the description, use clone() if you want that) ...
void set_subpixel(bool setting=true)
Sets the font subpixel rendering setting (defaults to true)
Definition: font_description.h:95
void throw_if_null() const
Throw an exception if this object is invalid.
Definition: font_description.h:80
FontStyle
Definition: font_description.h:52
Definition: font_description.h:81
Charset charset() const
Get the font charset
void set_anti_alias(bool setting=true)
Sets the font anti-alias setting (defaults to true)
void set_weight(FontWeight value=FontWeight::normal)
Sets the font weight.
bool subpixel() const
Get the font subpixel rendering setting (defaults to true)
Font description class.
Definition: font_description.h:62
Definition: font_description.h:83
Definition: Application/application.h:35