TextMetrics.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_TEXTMETRICS_H
30 #define PT_GFX_TEXTMETRICS_H
31 
32 #include <Pt/Gfx/Api.h>
33 
34 namespace Pt {
35 
36 namespace Gfx {
37 
45 class PT_GFX_API TextMetrics
46 {
47  public:
51 
54  Float advance() const
55  {
56  return _advance;
57  }
58 
61  void setAdvance(Float n)
62  {
63  _advance = n;
64  }
65 
68  Float bearingX() const
69  {
70  return _bearingX;
71  }
72 
75  void setBearingX(Float n)
76  {
77  _bearingX = n;
78  }
79 
82  Float bearingY() const
83  {
84  return _bearingY;
85  }
86 
89  void setBearingY(Float n)
90  {
91  _bearingY = n;
92  }
93 
96  Float boundingWidth() const
97  {
98  return _boundingWidth;
99  }
100 
103  void setBoundingWidth(Float n)
104  {
105  _boundingWidth = n;
106  }
107 
110  Float boundingHeight() const
111  {
112  return _boundingHeight;
113  }
114 
117  void setBoundingHeight(Float n)
118  {
119  _boundingHeight = n;
120  }
121 
122  private:
123  Float _advance;
124  Float _bearingX;
125  Float _bearingY;
126  Float _boundingWidth;
127  Float _boundingHeight;
128 };
129 
130 } // namespace
131 
132 } // namespace
133 
134 #endif // include guard
void setBoundingHeight(Float n)
Sets the bounding box height.
Definition: TextMetrics.h:117
Core module.
Definition: Allocator.h:33
Float bearingX() const
Returns the horizontal bearing from origin to bounding box.
Definition: TextMetrics.h:68
void setAdvance(Float n)
Sets the advance width of the text.
Definition: TextMetrics.h:61
void setBearingY(Float n)
Sets the vertical bearing.
Definition: TextMetrics.h:89
Float advance() const
Returns the advance width of the text.
Definition: TextMetrics.h:54
Metrics for a measured line of text.
Definition: TextMetrics.h:46
Float bearingY() const
Returns the vertical bearing from baseline to top of bounding box.
Definition: TextMetrics.h:82
Float boundingHeight() const
Returns the height of the bounding box.
Definition: TextMetrics.h:110
void setBoundingWidth(Float n)
Sets the bounding box width.
Definition: TextMetrics.h:103
TextMetrics()
Constructs empty text metrics.
Float boundingWidth() const
Returns the width of the bounding box.
Definition: TextMetrics.h:96
void setBearingX(Float n)
Sets the horizontal bearing.
Definition: TextMetrics.h:75