font_description.h Source File - ClanLib SDK
Description: font_description.h Source File

font_description.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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#pragma once
31
32#include <memory>
33
34namespace clan
35{
38
39 class DisplayWindow;
40 class FontDescription_Impl;
41
42 enum class FontWeight : int
43 {
44 thin = 100,
45 extra_light = 200,
46 light = 300,
47 normal = 400,
48 medium = 500,
49 semi_bold = 600,
50 bold = 700,
51 extra_bold = 800,
52 heavy = 900
53 };
54
55 enum class FontStyle
56 {
57 normal,
58 italic,
59 oblique // Currently not supported by ClanLib
60 };
61
65 class FontDescription
66 {
67 public:
69 FontDescription();
70
71 virtual ~FontDescription();
72
76 static FontDescription create_null_object();
77
78 enum Charset
79 {
80 charset_default,
81 charset_ansi,
82 charset_baltic,
83 charset_chinesebig5,
84 charset_easteurope,
85 charset_gb2312,
86 charset_greek,
87 charset_hangul,
88 charset_mac,
89 charset_oem,
90 charset_russian,
91 charset_shiftjis,
92 charset_symbol,
93 charset_turkish,
94 charset_vietnamese,
95 charset_johab,
96 charset_arabic,
97 charset_hebrew,
98 charset_thai
99 };
100
102 bool is_null() const { return !impl; }
103 explicit operator bool() const { return bool(impl); }
104
106 void throw_if_null() const;
107
109 float get_height() const;
110
112 float get_line_height() const;
113
117 float get_average_width() const;
118
120 float get_escapement() const;
121
123 float get_orientation() const;
124
126 FontWeight get_weight() const;
127
129 FontStyle get_style() const;
130
132 bool get_anti_alias() const;
133
135 bool get_subpixel() const;
136
138 Charset get_charset() const;
139
142 bool operator==(const FontDescription &other) const;
143
148 std::string get_unique_id() const;
149
151 FontDescription &operator =(const FontDescription &copy);
152
153 // \brief Copy the entire font description (not just the implementation)
154 FontDescription clone() const;
155
157 void set_height(float value = 20.0f);
158
162 void set_average_width(float value = 0.0f);
163
165 void set_escapement(float value);
166
168 void set_orientation(float value);
169
171 void set_weight(FontWeight value = FontWeight::normal);
172
174 void set_line_height(float height);
175
177 void set_style(FontStyle setting = FontStyle::normal);
178
180 void set_anti_alias(bool setting = true);
181
183 void set_subpixel(bool setting = true);
184
188 void set_charset(Charset new_charset);
189
190 private:
191 std::shared_ptr<FontDescription_Impl> impl;
192 };
193
195}
clan::DisplayWindow
Top-level window class.
Definition display_window.h:101
clan::FontDescription::set_average_width
void set_average_width(float value=0.0f)
Sets the font average width.
clan::FontDescription::get_style
FontStyle get_style() const
Returns the font style.
clan::FontDescription::operator==
bool operator==(const FontDescription &other) const
Returns true if the font is identical Line_height is excluded.
clan::FontDescription::get_weight
FontWeight get_weight() const
Returns the font weight.
clan::FontDescription::FontDescription
FontDescription()
Constructs a font description with default values.
clan::FontDescription::get_average_width
float get_average_width() const
Returns the font average width.
clan::FontDescription::create_null_object
static FontDescription create_null_object()
Create null object.
clan::FontDescription::set_weight
void set_weight(FontWeight value=FontWeight::normal)
Sets the font weight.
clan::FontDescription::get_line_height
float get_line_height() const
Returns the distance between each line.
clan::FontDescription::set_orientation
void set_orientation(float value)
Sets the font orientation.
clan::FontDescription::get_anti_alias
bool get_anti_alias() const
Get the font anti-alias setting (defaults to true).
clan::FontDescription::get_orientation
float get_orientation() const
Returns the font orientation.
clan::FontDescription::clone
FontDescription clone() const
clan::FontDescription::~FontDescription
virtual ~FontDescription()
clan::FontDescription::set_height
void set_height(float value=20.0f)
Sets the font height.
clan::FontDescription::get_height
float get_height() const
Returns the font height.
clan::FontDescription::set_charset
void set_charset(Charset new_charset)
Sets the font charset (defaults to charset_default).
clan::FontDescription::set_style
void set_style(FontStyle setting=FontStyle::normal)
Sets the font style.
clan::FontDescription::is_null
bool is_null() const
Returns true if this object is invalid.
Definition font_description.h:102
clan::FontDescription::Charset
Charset
Definition font_description.h:79
clan::FontDescription::charset_greek
@ charset_greek
Definition font_description.h:86
clan::FontDescription::charset_russian
@ charset_russian
Definition font_description.h:90
clan::FontDescription::charset_chinesebig5
@ charset_chinesebig5
Definition font_description.h:83
clan::FontDescription::charset_turkish
@ charset_turkish
Definition font_description.h:93
clan::FontDescription::charset_ansi
@ charset_ansi
Definition font_description.h:81
clan::FontDescription::charset_hangul
@ charset_hangul
Definition font_description.h:87
clan::FontDescription::charset_easteurope
@ charset_easteurope
Definition font_description.h:84
clan::FontDescription::charset_gb2312
@ charset_gb2312
Definition font_description.h:85
clan::FontDescription::charset_symbol
@ charset_symbol
Definition font_description.h:92
clan::FontDescription::charset_thai
@ charset_thai
Definition font_description.h:98
clan::FontDescription::charset_arabic
@ charset_arabic
Definition font_description.h:96
clan::FontDescription::charset_baltic
@ charset_baltic
Definition font_description.h:82
clan::FontDescription::charset_vietnamese
@ charset_vietnamese
Definition font_description.h:94
clan::FontDescription::charset_oem
@ charset_oem
Definition font_description.h:89
clan::FontDescription::charset_default
@ charset_default
Definition font_description.h:80
clan::FontDescription::charset_mac
@ charset_mac
Definition font_description.h:88
clan::FontDescription::charset_hebrew
@ charset_hebrew
Definition font_description.h:97
clan::FontDescription::charset_shiftjis
@ charset_shiftjis
Definition font_description.h:91
clan::FontDescription::charset_johab
@ charset_johab
Definition font_description.h:95
clan::FontDescription::get_escapement
float get_escapement() const
Returns the font escapement.
clan::FontDescription::get_charset
Charset get_charset() const
\biref Get the font charset
clan::FontDescription::set_escapement
void set_escapement(float value)
Sets the font escapement.
clan::FontDescription::set_line_height
void set_line_height(float height)
Sets the distance between each line.
clan::FontDescription::get_unique_id
std::string get_unique_id() const
Returns an unique string identifying this font description.
clan::FontDescription::set_subpixel
void set_subpixel(bool setting=true)
Sets the font subpixel rendering setting (defaults to true).
clan::FontDescription::get_subpixel
bool get_subpixel() const
Get the font subpixel rendering setting (defaults to true).
clan::FontDescription::operator=
FontDescription & operator=(const FontDescription &copy)
Copy assignment operator (does not copy the description, use clone() if you want that).
clan::FontDescription::set_anti_alias
void set_anti_alias(bool setting=true)
Sets the font anti-alias setting (defaults to true).
clan::FontDescription::throw_if_null
void throw_if_null() const
Throw an exception if this object is invalid.
clan::FontWeight
FontWeight
Definition font_description.h:43
clan::FontStyle
FontStyle
Definition font_description.h:56
clan::FontWeight::medium
@ medium
Definition font_description.h:48
clan::FontWeight::light
@ light
Definition font_description.h:46
clan::FontWeight::semi_bold
@ semi_bold
Definition font_description.h:49
clan::FontWeight::thin
@ thin
Definition font_description.h:44
clan::FontWeight::bold
@ bold
Definition font_description.h:50
clan::FontWeight::heavy
@ heavy
Definition font_description.h:52
clan::FontWeight::extra_light
@ extra_light
Definition font_description.h:45
clan::FontWeight::extra_bold
@ extra_bold
Definition font_description.h:51
clan::FontWeight::normal
@ normal
Definition font_description.h:47
clan::FontStyle::italic
@ italic
Definition font_description.h:58
clan::FontStyle::oblique
@ oblique
Definition font_description.h:59
clan::FontStyle::normal
@ normal
Definition font_description.h:57
clan
Definition clanapp.h:36