Panda3D
Loading...
Searching...
No Matches
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 */
19get_advance() const {
20 return _int_advance;
21}
22
23/**
24 * Returns the x coordinate of the leftmost pixel in the glyph.
25 */
27get_left() const {
28 return _left;
29}
30
31/**
32 * Returns the x coordinate of the rightmost pixel in the glyph.
33 */
35get_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 */
43get_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 */
51get_top() const {
52 return _top;
53}
54
55/**
56 * Returns the height of the glyph in pixels.
57 */
59get_height() const {
60 return _image.get_y_size();
61}
62
63/**
64 * Returns the width of the glyph in pixels.
65 */
67get_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 */
76INLINE double PNMTextGlyph::
77get_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 */
88INLINE bool PNMTextGlyph::
89get_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_x_size() const
Returns the number of pixels in the X direction.
int get_y_size() const
Returns the number of pixels in the Y direction.
float get_blue(int x, int y) const
Returns the blue component color at the indicated pixel.
Definition pnmImage.I:788
xelval get_red_val(int x, int y) const
Returns the red component color at the indicated pixel.
Definition pnmImage.I:452
int get_top() const
Returns the y coordinate of the topmost pixel in the glyph.
int get_advance() const
Returns the number of pixels by which the pen should be advanced after rendering this glyph.
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,...
int get_width() const
Returns the width of the glyph in pixels.
int get_left() const
Returns the x coordinate of the leftmost pixel in the glyph.
double get_value(int x, int y) const
Returns the value of the indicated pixel of the glyph.
int get_height() const
Returns the height of the glyph in pixels.
int get_bottom() const
Returns the y coordinate of the bottommost pixel in the glyph.
int get_right() const
Returns the x coordinate of the rightmost pixel in the glyph.