Panda3D
dynamicTextGlyph.h
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.h
10  * @author drose
11  * @date 2002-02-09
12  */
13 
14 #ifndef DYNAMICTEXTGLYPH_H
15 #define DYNAMICTEXTGLYPH_H
16 
17 #include "pandabase.h"
18 
19 #ifdef HAVE_FREETYPE
20 
21 #include "textGlyph.h"
22 
23 class DynamicTextPage;
24 class DynamicTextFont;
25 
26 /**
27  * A specialization on TextGlyph that is generated and stored by a
28  * DynamicTextFont. This keeps some additional information, such as where the
29  * glyph appears on a texture map.
30  */
31 class EXPCL_PANDA_TEXT DynamicTextGlyph : public TextGlyph {
32 public:
33  INLINE DynamicTextGlyph(int character, DynamicTextPage *page,
34  int x, int y, int x_size, int y_size,
35  int margin, PN_stdfloat advance);
36  INLINE DynamicTextGlyph(int character, PN_stdfloat advance);
37  DynamicTextGlyph(const DynamicTextGlyph &copy) = delete;
38 
39  DynamicTextGlyph &operator = (const DynamicTextGlyph &copy) = delete;
40 
41 PUBLISHED:
42  virtual ~DynamicTextGlyph();
43 
44  INLINE DynamicTextPage *get_page() const;
45  MAKE_PROPERTY(page, get_page);
46 
47  INLINE bool intersects(int x, int y, int x_size, int y_size) const;
48 
49  INLINE PN_stdfloat get_left() const;
50  INLINE PN_stdfloat get_bottom() const;
51  INLINE PN_stdfloat get_right() const;
52  INLINE PN_stdfloat get_top() const;
53 
54  INLINE PN_stdfloat get_uv_left() const;
55  INLINE PN_stdfloat get_uv_bottom() const;
56  INLINE PN_stdfloat get_uv_right() const;
57  INLINE PN_stdfloat get_uv_top() const;
58 
59 public:
60  unsigned char *get_row(int y);
61  void erase(DynamicTextFont *font);
62  virtual bool is_whitespace() const;
63 
64  DynamicTextPage *_page;
65 
66  int _x, _y;
67  int _x_size, _y_size;
68  int _margin;
69 
70  friend class DynamicTextFont;
71 
72 public:
73  static TypeHandle get_class_type() {
74  return _type_handle;
75  }
76  static void init_type() {
77  TextGlyph::init_type();
78  register_type(_type_handle, "DynamicTextGlyph",
79  TextGlyph::get_class_type());
80  }
81  virtual TypeHandle get_type() const {
82  return get_class_type();
83  }
84  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85 
86 private:
87  static TypeHandle _type_handle;
88 };
89 
90 #include "dynamicTextGlyph.I"
91 
92 #endif // HAVE_FREETYPE
93 
94 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool is_whitespace() const
Returns true if this glyph represents invisible whitespace, or false if it corresponds to some visibl...
Definition: textGlyph.cxx:37
A representation of a single glyph (character) from a font.
Definition: textGlyph.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81