Panda3D
dynamicTextGlyph.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file dynamicTextGlyph.I
10  * @author drose
11  * @date 2002-02-09
12  */
13 
14 /**
15  *
16  */
17 INLINE DynamicTextGlyph::
18 DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y,
19  int x_size, int y_size, int margin, PN_stdfloat advance) :
20  TextGlyph(character, advance),
21  _page(page),
22  _x(x), _y(y),
23  _x_size(x_size), _y_size(y_size),
24  _margin(margin)
25 {
26 }
27 
28 /**
29  * This constructor makes an empty glyph, whose only purpose is to remember
30  * its width. It has no bitmap and no Geom.
31  */
32 INLINE DynamicTextGlyph::
33 DynamicTextGlyph(int character, PN_stdfloat advance) :
34  TextGlyph(character, advance),
35  _page(nullptr),
36  _x(0), _y(0),
37  _x_size(0), _y_size(0),
38  _margin(0)
39 {
40 }
41 
42 /**
43  * Returns the DynamicTextPage that this glyph is on.
44  */
45 INLINE DynamicTextPage *DynamicTextGlyph::
46 get_page() const {
47  return _page;
48 }
49 
50 /**
51  * Returns true if the particular position this glyph has been assigned to
52  * overlaps the rectangle whose top left corner is at x, y and whose size is
53  * given by x_size, y_size, or false otherwise.
54  */
55 INLINE bool DynamicTextGlyph::
56 intersects(int x, int y, int x_size, int y_size) const {
57  int hright = x + x_size;
58  int hbot = y + y_size;
59 
60  int mright = _x + _x_size;
61  int mbot = _y + _y_size;
62 
63  return !(x >= mright || hright <= _x ||
64  y >= mbot || hbot <= _y);
65 }
66 
67 /**
68  * Returns the vertex coordinates that can be used when creating a custom text
69  * renderer.
70  */
71 INLINE PN_stdfloat DynamicTextGlyph::
72 get_left() const {
73  return _quad_dimensions[0];
74 }
75 
76 /**
77  * Returns the vertex coordinates that can be used when creating a custom text
78  * renderer.
79  */
80 INLINE PN_stdfloat DynamicTextGlyph::
81 get_bottom() const {
82  return _quad_dimensions[1];
83 }
84 
85 /**
86  * Returns the vertex coordinates that can be used when creating a custom text
87  * renderer.
88  */
89 INLINE PN_stdfloat DynamicTextGlyph::
90 get_right() const {
91  return _quad_dimensions[2];
92 }
93 
94 /**
95  * Returns the vertex coordinates that can be used when creating a custom text
96  * renderer.
97  */
98 INLINE PN_stdfloat DynamicTextGlyph::
99 get_top() const {
100  return _quad_dimensions[3];
101 }
102 
103 /**
104  * Returns the UV coordinates that can be used when creating a custom text
105  * renderer.
106  */
107 INLINE PN_stdfloat DynamicTextGlyph::
108 get_uv_left() const {
109  return _quad_texcoords[0];
110 }
111 
112 /**
113  * Returns the UV coordinates that can be used when creating a custom text
114  * renderer.
115  */
116 INLINE PN_stdfloat DynamicTextGlyph::
117 get_uv_bottom() const {
118  return _quad_texcoords[1];
119 }
120 
121 /**
122  * Returns the UV coordinates that can be used when creating a custom text
123  * renderer.
124  */
125 INLINE PN_stdfloat DynamicTextGlyph::
126 get_uv_right() const {
127  return _quad_texcoords[2];
128 }
129 
130 /**
131  * Returns the UV coordinates that can be used when creating a custom text
132  * renderer.
133  */
134 INLINE PN_stdfloat DynamicTextGlyph::
135 get_uv_top() const {
136  return _quad_texcoords[3];
137 }
A representation of a single glyph (character) from a font.
Definition: textGlyph.h:28