font_metrics.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 ** Magnus Norddahl
27 ** Harry Storbacka
28 ** Mark Page
29 */
30 
31 
32 #pragma once
33 
34 #include "../api_display.h"
35 #include <memory>
36 
37 namespace clan
38 {
41 
42 class FontMetrics_Impl;
43 
47 class CL_API_DISPLAY FontMetrics
48 {
51 
52 public:
54  float height=0.0f,
55  float ascent=0.0f,
56  float descent=0.0f,
57  float internal_leading=0.0f,
58  float external_leading=0.0f,
59  float average_character_width=0.0f,
60  float max_character_width=0.0f,
61  float weight=0.0f,
62  float overhang=0.0f,
63  float digitized_aspect_x=0.0f,
64  float digitized_aspect_y=0.0f,
65  bool italic=false,
66  bool underlined=false,
67  bool struck_out=false,
68  bool fixed_pitch=false
69  );
70 
71  ~FontMetrics();
72 
76 
77 public:
79  float get_height() const;
80 
82  float get_ascent() const;
83 
85  float get_descent() const;
86 
88  float get_internal_leading() const;
89 
91  float get_external_leading() const;
92 
94 
96  float get_average_character_width() const;
97 
99  float get_max_character_width() const;
100 
102  float get_weight() const;
103 
105  float get_overhang() const;
106 
108  float get_digitized_aspect_x() const;
109 
111  float get_digitized_aspect_y() const;
112 
114  std::string::value_type get_first_char() const;
115 
117  std::string::value_type get_last_char() const;
118 
120  std::string::value_type get_default_char() const;
121 
123  std::string::value_type get_word_break_char() const;
124 
126  bool is_italic() const;
127 
129  bool is_underlined() const;
130 
132  bool is_struck_out() const;
133 
135  bool is_fixed_pitch() const;
136 
140 
141 public:
142 
146  void set_height(float value);
147 
151  void set_ascent(float value);
152 
156  void set_descent(float value);
157 
161  void set_internal_leading(float value);
162 
166  void set_external_leading(float value);
167 
171  void set_average_character_width(float value);
172 
176  void set_max_character_width(float value);
177 
181  void set_weight(float value);
182 
186  void set_overhang(float value);
187 
191  void set_digitized_aspect_x(float value);
192 
196  void set_digitized_aspect_y(float value);
197 
201  void set_italic(bool value);
202 
206  void set_underlined(bool value);
207 
211  void set_struck_out(bool value);
212 
216  void set_fixed_pitch(bool value);
217 
218 
222 
223 private:
224  std::shared_ptr<FontMetrics_Impl> impl;
226 };
227 
228 }
229 
231 
Font metrics class.
Definition: font_metrics.h:47