FontMetrics.h
1/* Copyright (C) 2015-2024 Marc Boris Duerner
2
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Lesser General Public
5 License as published by the Free Software Foundation; either
6 version 2.1 of the License, or (at your option) any later version.
7
8 As a special exception, you may use this file as part of a free
9 software library without restriction. Specifically, if other files
10 instantiate templates or use macros or inline functions from this
11 file, or you compile this file and link it with other files to
12 produce an executable, this file does not by itself cause the
13 resulting executable to be covered by the GNU General Public
14 License. This exception does not however invalidate any other
15 reasons why the executable file might be covered by the GNU Library
16 General Public License.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 MA 02110-1301 USA
27*/
28
29#ifndef PT_GFX_FONTMETRICS_H
30#define PT_GFX_FONTMETRICS_H
31
32#include <Pt/Gfx/Api.h>
33
34namespace Pt {
35
36namespace Gfx {
37
49class PT_GFX_API FontMetrics
50{
51 public:
55
58 Float ascent() const
59 {
60 return _ascent;
61 }
62
65 void setAscent(Float n)
66 {
67 _ascent = n;
68 }
69
72 Float descent() const
73 {
74 return _descent;
75 }
76
79 void setDescent(Float n)
80 {
81 _descent = n;
82 }
83
86 Float height() const
87 {
88 return _ascent + _descent;
89 }
90
93 Float capHeight() const
94 {
95 return _capHeight;
96 }
97
100 void setCapHeight(Float n)
101 {
102 _capHeight = n;
103 }
104
107 Float xHeight() const
108 {
109 return _xHeight;
110 }
111
114 void setXHeight(Float n)
115 {
116 _xHeight = n;
117 }
118
121 Float leading() const
122 {
123 return _leading;
124 }
125
128 void setLeading(Float n)
129 {
130 _leading = n;
131 }
132
135 Float lineHeight() const
136 {
137 return _ascent + _descent + _leading;
138 }
139
142 Float underlinePos() const
143 {
144 return _underlinePos;
145 }
146
149 void setUnderlinePos(Float n)
150 {
151 _underlinePos = n;
152 }
153
156 Float underlineThickness() const
157 {
158 return _underlineThickness;
159 }
160
164 {
165 _underlineThickness = n;
166 }
167
170 Float strikeoutPos() const
171 {
172 return _strikeoutPos;
173 }
174
177 void setStrikeoutPos(Float n)
178 {
179 _strikeoutPos = n;
180 }
181
184 Float strikeoutThickness() const
185 {
186 return _strikeoutThickness;
187 }
188
192 {
193 _strikeoutThickness = n;
194 }
195
196 private:
197 Float _ascent;
198 Float _descent;
199 Float _capHeight;
200 Float _xHeight;
201 Float _leading;
202 Float _underlinePos;
203 Float _underlineThickness;
204 Float _strikeoutPos;
205 Float _strikeoutThickness;
206};
207
208} // namespace
209
210} // namespace
211
212#endif
void setLeading(Float n)
Sets the leading.
Definition FontMetrics.h:128
Float leading() const
Returns the external leading between lines.
Definition FontMetrics.h:121
Float strikeoutThickness() const
Returns the strikeout line thickness.
Definition FontMetrics.h:184
Float underlinePos() const
Returns the underline position below the baseline.
Definition FontMetrics.h:142
void setAscent(Float n)
Sets the ascent.
Definition FontMetrics.h:65
Float height() const
Returns the font height (ascent + descent).
Definition FontMetrics.h:86
void setUnderlinePos(Float n)
Sets the underline position.
Definition FontMetrics.h:149
Float underlineThickness() const
Returns the underline thickness.
Definition FontMetrics.h:156
void setStrikeoutPos(Float n)
Sets the strikeout position.
Definition FontMetrics.h:177
Float ascent() const
Returns the ascent above the baseline.
Definition FontMetrics.h:58
void setXHeight(Float n)
Sets the x-height.
Definition FontMetrics.h:114
void setDescent(Float n)
Sets the descent.
Definition FontMetrics.h:79
Float lineHeight() const
Returns the line height (ascent + descent + leading).
Definition FontMetrics.h:135
void setUnderlineThickness(Float n)
Sets the underline thickness.
Definition FontMetrics.h:163
void setCapHeight(Float n)
Sets the cap height.
Definition FontMetrics.h:100
Float strikeoutPos() const
Returns the strikeout position above the baseline.
Definition FontMetrics.h:170
void setStrikeoutThickness(Float n)
Sets the strikeout thickness.
Definition FontMetrics.h:191
Float xHeight() const
Returns the height of lowercase x.
Definition FontMetrics.h:107
Float capHeight() const
Returns the height of capital letters.
Definition FontMetrics.h:93
Float descent() const
Returns the descent below the baseline.
Definition FontMetrics.h:72
FontMetrics()
Constructs empty font metrics.
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33