Panda3D
pnmTextGlyph.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 pnmTextGlyph.I
10  * @author drose
11  * @date 2003-09-07
12  */
13 
14 /**
15  * Returns the number of pixels by which the pen should be advanced after
16  * rendering this glyph.
17  */
18 INLINE int PNMTextGlyph::
19 get_advance() const {
20  return _int_advance;
21 }
22 
23 /**
24  * Returns the x coordinate of the leftmost pixel in the glyph.
25  */
26 INLINE int PNMTextGlyph::
27 get_left() const {
28  return _left;
29 }
30 
31 /**
32  * Returns the x coordinate of the rightmost pixel in the glyph.
33  */
34 INLINE int PNMTextGlyph::
35 get_right() const {
36  return _left + _image.get_x_size();
37 }
38 
39 /**
40  * Returns the y coordinate of the bottommost pixel in the glyph.
41  */
42 INLINE int PNMTextGlyph::
43 get_bottom() const {
44  return _top + _image.get_y_size();
45 }
46 
47 /**
48  * Returns the y coordinate of the topmost pixel in the glyph.
49  */
50 INLINE int PNMTextGlyph::
51 get_top() const {
52  return _top;
53 }
54 
55 /**
56  * Returns the height of the glyph in pixels.
57  */
58 INLINE int PNMTextGlyph::
59 get_height() const {
60  return _image.get_y_size();
61 }
62 
63 /**
64  * Returns the width of the glyph in pixels.
65  */
66 INLINE int PNMTextGlyph::
67 get_width() const {
68  return _image.get_x_size();
69 }
70 
71 /**
72  * Returns the value of the indicated pixel of the glyph. The result is in
73  * the range [0, 1], where 0 indicates the pixel is not part of the glyph, and
74  * 1 indicates it is. Intermediate values are used to represent antialiasing.
75  */
76 INLINE double PNMTextGlyph::
77 get_value(int x, int y) const {
78  nassertr(x >= 0 && x < get_width() &&
79  y >= 0 && y < get_height(), 0.0);
80  // By convention, the "value" attribute is stored in the blue component.
81  return _image.get_blue(x, y);
82 }
83 
84 /**
85  * Returns true if the indicated pixel represents a pixel in the interior of a
86  * hollow font, false otherwise.
87  */
88 INLINE bool PNMTextGlyph::
89 get_interior_flag(int x, int y) const {
90  nassertr(x >= 0 && x < get_width() &&
91  y >= 0 && y < get_height(), false);
92  // By convention, the "interior_value" attribute is stored in the red
93  // component.
94  return _image.get_red_val(x, y) != 0;
95 }
int get_advance() const
Returns the number of pixels by which the pen should be advanced after rendering this glyph.
Definition: pnmTextGlyph.I:19
float get_blue(int x, int y) const
Returns the blue component color at the indicated pixel.
Definition: pnmImage.I:774
bool get_interior_flag(int x, int y) const
Returns true if the indicated pixel represents a pixel in the interior of a hollow font,...
Definition: pnmTextGlyph.I:89
int get_top() const
Returns the y coordinate of the topmost pixel in the glyph.
Definition: pnmTextGlyph.I:51
int get_y_size() const
Returns the number of pixels in the Y direction.
int get_x_size() const
Returns the number of pixels in the X direction.
int get_height() const
Returns the height of the glyph in pixels.
Definition: pnmTextGlyph.I:59
int get_left() const
Returns the x coordinate of the leftmost pixel in the glyph.
Definition: pnmTextGlyph.I:27
int get_width() const
Returns the width of the glyph in pixels.
Definition: pnmTextGlyph.I:67
double get_value(int x, int y) const
Returns the value of the indicated pixel of the glyph.
Definition: pnmTextGlyph.I:77
xelval get_red_val(int x, int y) const
Returns the red component color at the indicated pixel.
Definition: pnmImage.I:363
int get_right() const
Returns the x coordinate of the rightmost pixel in the glyph.
Definition: pnmTextGlyph.I:35
int get_bottom() const
Returns the y coordinate of the bottommost pixel in the glyph.
Definition: pnmTextGlyph.I:43