ClanLib  2.3.7
font_metrics.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 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 
33 
34 #pragma once
35 
36 #include "../api_display.h"
37 #include "../../Core/System/sharedptr.h"
38 
39 class CL_FontMetrics_Impl;
40 
45 {
48 
49 public:
52 
54  float height,
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  ~CL_FontMetrics();
72 
76 
77 public:
79  bool is_null() const { return !impl; }
80 
82  void throw_if_null() const;
83 
85  float get_height() const;
86 
88  float get_ascent() const;
89 
91  float get_descent() const;
92 
94  float get_internal_leading() const;
95 
97  float get_external_leading() const;
98 
100 
102  float get_average_character_width() const;
103 
105  float get_max_character_width() const;
106 
108  float get_weight() const;
109 
111  float get_overhang() const;
112 
114  float get_digitized_aspect_x() const;
115 
117  float get_digitized_aspect_y() const;
118 
120  CL_String::char_type get_first_char() const;
121 
123  CL_String::char_type get_last_char() const;
124 
126  CL_String::char_type get_default_char() const;
127 
129  CL_String::char_type get_word_break_char() const;
130 
132  bool is_italic() const;
133 
135  bool is_underlined() const;
136 
138  bool is_struck_out() const;
139 
141  bool is_fixed_pitch() const;
142 
146 
147 public:
148 
152  void set_height(float value);
153 
157  void set_ascent(float value);
158 
162  void set_descent(float value);
163 
167  void set_internal_leading(float value);
168 
172  void set_external_leading(float value);
173 
177  void set_average_character_width(float value);
178 
182  void set_max_character_width(float value);
183 
187  void set_weight(float value);
188 
192  void set_overhang(float value);
193 
197  void set_digitized_aspect_x(float value);
198 
202  void set_digitized_aspect_y(float value);
203 
207  void set_italic(bool value);
208 
212  void set_underlined(bool value);
213 
217  void set_struck_out(bool value);
218 
222  void set_fixed_pitch(bool value);
223 
224 
228 
229 private:
230  CL_SharedPtr<CL_FontMetrics_Impl> impl;
232 };
233 
235