Panda3D
textGlyph.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 textGlyph.h
10  * @author drose
11  * @date 2002-02-08
12  */
13 
14 #ifndef TEXTGLYPH_H
15 #define TEXTGLYPH_H
16 
17 #include "pandabase.h"
18 #include "renderState.h"
19 #include "referenceCount.h"
20 #include "geom.h"
21 #include "pointerTo.h"
22 #include "dcast.h"
23 
24 /**
25  * A representation of a single glyph (character) from a font. This is a
26  * piece of renderable geometry of some kind.
27  */
28 class EXPCL_PANDA_TEXT TextGlyph : public TypedReferenceCount {
29 public:
30  INLINE TextGlyph(int character, PN_stdfloat advance=0);
31  INLINE TextGlyph(int character, const Geom *geom,
32  const RenderState *state, PN_stdfloat advance);
33  INLINE TextGlyph(const TextGlyph &copy);
34  INLINE void operator = (const TextGlyph &copy);
35  virtual ~TextGlyph();
36 
37 PUBLISHED:
38  INLINE int get_character() const;
39  INLINE bool has_quad() const;
40  INLINE bool get_quad(LVecBase4 &dimensions, LVecBase4 &texcoords) const;
41  INLINE const RenderState *get_state() const;
42  INLINE PN_stdfloat get_advance() const;
43 
44  MAKE_PROPERTY(character, get_character);
45  MAKE_PROPERTY(state, get_state);
46  MAKE_PROPERTY(advance, get_advance);
47 
48  virtual bool is_whitespace() const;
49 
50  PT(Geom) get_geom(Geom::UsageHint usage_hint) const;
51 
52 public:
53  void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
54  bool &found_any, Thread *current_thread) const;
55 
56  void set_quad(const LVecBase4 &dimensions, const LVecBase4 &texcoords,
57  const RenderState *state);
58 
59  void set_geom(GeomVertexData *vdata, GeomPrimitive *prim,
60  const RenderState *state);
61 
62 private:
63  void check_quad_geom();
64  void make_quad_geom();
65 
66 protected:
67  int _character;
68  CPT(Geom) _geom;
69  CPT(RenderState) _state;
70  PN_stdfloat _advance;
71 
72  bool _has_quad;
73  // top, left, bottom, right
74  LVecBase4 _quad_dimensions;
75  LVecBase4 _quad_texcoords;
76 
77  friend class GeomTextGlyph;
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
84  TypedReferenceCount::init_type();
85  register_type(_type_handle, "TextGlyph",
86  TypedReferenceCount::get_class_type());
87  }
88  virtual TypeHandle get_type() const {
89  return get_class_type();
90  }
91  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
92 
93 private:
94  static TypeHandle _type_handle;
95 };
96 
97 #include "textGlyph.I"
98 
99 #endif
Geom
A container for geometry primitives.
Definition: geom.h:54
GeomTextGlyph
This is a specialization on Geom for containing a primitive intended to represent a TextGlyph.
Definition: geomTextGlyph.h:27
GeomVertexData
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
Definition: geomVertexData.h:68
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dcast.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
TypedReferenceCount
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
Definition: typedReferenceCount.h:31
RenderState
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
renderState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TextGlyph
A representation of a single glyph (character) from a font.
Definition: textGlyph.h:28
geom.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
textGlyph.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
GeomPrimitive
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:56