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 
34 namespace Pt {
35 
36 namespace Gfx {
37 
45 class PT_GFX_API FontMetrics
46 {
47  public:
51 
54  Float ascent() const
55  {
56  return _ascent;
57  }
58 
61  void setAscent(Float n)
62  {
63  _ascent = n;
64  }
65 
68  Float descent() const
69  {
70  return _descent;
71  }
72 
75  void setDescent(Float n)
76  {
77  _descent = n;
78  }
79 
82  Float height() const
83  {
84  return _ascent + _descent;
85  }
86 
89  Float capHeight() const
90  {
91  return _capHeight;
92  }
93 
96  void setCapHeight(Float n)
97  {
98  _capHeight = n;
99  }
100 
103  Float xHeight() const
104  {
105  return _xHeight;
106  }
107 
110  void setXHeight(Float n)
111  {
112  _xHeight = n;
113  }
114 
117  Float leading() const
118  {
119  return _leading;
120  }
121 
124  void setLeading(Float n)
125  {
126  _leading = n;
127  }
128 
131  Float lineHeight() const
132  {
133  return _ascent + _descent + _leading;
134  }
135 
138  Float underlinePos() const
139  {
140  return _underlinePos;
141  }
142 
145  void setUnderlinePos(Float n)
146  {
147  _underlinePos = n;
148  }
149 
152  Float underlineThickness() const
153  {
154  return _underlineThickness;
155  }
156 
159  void setUnderlineThickness(Float n)
160  {
161  _underlineThickness = n;
162  }
163 
166  Float strikeoutPos() const
167  {
168  return _strikeoutPos;
169  }
170 
173  void setStrikeoutPos(Float n)
174  {
175  _strikeoutPos = n;
176  }
177 
180  Float strikeoutThickness() const
181  {
182  return _strikeoutThickness;
183  }
184 
187  void setStrikeoutThickness(Float n)
188  {
189  _strikeoutThickness = n;
190  }
191 
192  private:
193  Float _ascent;
194  Float _descent;
195  Float _capHeight;
196  Float _xHeight;
197  Float _leading;
198  Float _underlinePos;
199  Float _underlineThickness;
200  Float _strikeoutPos;
201  Float _strikeoutThickness;
202 };
203 
204 } // namespace
205 
206 } // namespace
207 
208 #endif
Core module.
Definition: pt-gfx-images.dox:14
Float leading() const
Returns the external leading between lines.
Definition: FontMetrics.h:117
Float height() const
Returns the font height (ascent + descent).
Definition: FontMetrics.h:82
Float capHeight() const
Returns the height of capital letters.
Definition: FontMetrics.h:89
void setXHeight(Float n)
Sets the x-height.
Definition: FontMetrics.h:110
void setAscent(Float n)
Sets the ascent.
Definition: FontMetrics.h:61
Float xHeight() const
Returns the height of lowercase x.
Definition: FontMetrics.h:103
Metrics that describe a font face at a given size.
Definition: FontMetrics.h:46
Float underlineThickness() const
Returns the underline thickness.
Definition: FontMetrics.h:152
void setCapHeight(Float n)
Sets the cap height.
Definition: FontMetrics.h:96
Float underlinePos() const
Returns the underline position below the baseline.
Definition: FontMetrics.h:138
Float strikeoutPos() const
Returns the strikeout position above the baseline.
Definition: FontMetrics.h:166
void setStrikeoutThickness(Float n)
Sets the strikeout thickness.
Definition: FontMetrics.h:187
Float descent() const
Returns the descent below the baseline.
Definition: FontMetrics.h:68
void setUnderlineThickness(Float n)
Sets the underline thickness.
Definition: FontMetrics.h:159
void setUnderlinePos(Float n)
Sets the underline position.
Definition: FontMetrics.h:145
void setDescent(Float n)
Sets the descent.
Definition: FontMetrics.h:75
void setLeading(Float n)
Sets the leading.
Definition: FontMetrics.h:124
Float lineHeight() const
Returns the line height (ascent + descent + leading).
Definition: FontMetrics.h:131
FontMetrics()
Constructs empty font metrics.
void setStrikeoutPos(Float n)
Sets the strikeout position.
Definition: FontMetrics.h:173
Float strikeoutThickness() const
Returns the strikeout line thickness.
Definition: FontMetrics.h:180
Float ascent() const
Returns the ascent above the baseline.
Definition: FontMetrics.h:54