Panda3D
Loading...
Searching...
No Matches
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 */
28class EXPCL_PANDA_TEXT TextGlyph : public TypedReferenceCount {
29public:
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
37PUBLISHED:
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
52public:
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
62private:
63 void check_quad_geom();
64 void make_quad_geom();
65
66protected:
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
79public:
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
93private:
94 static TypeHandle _type_handle;
95};
96
97#include "textGlyph.I"
98
99#endif
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition geom.h:54
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
get_character
Returns the Unicode value that corresponds to the character this glyph represents.
Definition textGlyph.h:44
TextGlyph(int character, PN_stdfloat advance=0)
This constructor makes an empty glyph.
Definition textGlyph.I:18
void set_geom(GeomVertexData *vdata, GeomPrimitive *prim, const RenderState *state)
Sets the geom from a pre-built Geom object.
get_state
Returns the state in which the glyph should be rendered.
Definition textGlyph.h:45
bool has_quad() const
Returns true if this glyph contains the definition for a simple quad, rather than a more complex piec...
Definition textGlyph.I:92
get_advance
Returns the distance by which the character pointer should be advanced after placing this character; ...
Definition textGlyph.h:46
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
bool get_quad(LVecBase4 &dimensions, LVecBase4 &texcoords) const
Assuming that this glyph is representable as a textured quad, returns its dimensions and UV range.
Definition textGlyph.I:104
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.