15 #ifndef TEXTASSEMBLER_H
16 #define TEXTASSEMBLER_H
18 #include "pandabase.h"
20 #include "textProperties.h"
22 #include "unicodeLatinMap.h"
24 #include "pointerTo.h"
25 #include "geomTextGlyph.h"
26 #include "textPropertiesManager.h"
27 #include "textEncoder.h"
28 #include "geomVertexRewriter.h"
55 INLINE
void set_usage_hint(Geom::UsageHint usage_hint);
56 INLINE Geom::UsageHint get_usage_hint()
const;
58 INLINE
void set_max_rows(
int max_rows);
59 INLINE
int get_max_rows()
const;
61 INLINE
void set_dynamic_merge(
bool dynamic_merge);
62 INLINE
bool get_dynamic_merge()
const;
64 INLINE
void set_multiline_mode(
bool flag);
65 INLINE
bool get_multiline_mode()
const;
70 bool set_wtext(
const wstring &wtext);
71 bool set_wsubstr(
const wstring &wtext,
int start,
int count);
73 wstring get_plain_wtext()
const;
74 wstring get_wordwrapped_plain_wtext()
const;
75 wstring get_wtext()
const;
76 wstring get_wordwrapped_wtext()
const;
78 bool calc_r_c(
int &r,
int &c,
int n)
const;
79 INLINE
int calc_r(
int n)
const;
80 INLINE
int calc_c(
int n)
const;
81 int calc_index(
int r,
int c)
const;
83 INLINE
int get_num_characters()
const;
84 INLINE
wchar_t get_character(
int n)
const;
87 INLINE PN_stdfloat get_width(
int n)
const;
89 INLINE
int get_num_rows()
const;
90 INLINE
int get_num_cols(
int r)
const;
91 INLINE
wchar_t get_character(
int r,
int c)
const;
92 INLINE
const TextGraphic *get_graphic(
int r,
int c)
const;
94 INLINE PN_stdfloat get_width(
int r,
int c)
const;
95 PN_stdfloat get_xpos(
int r,
int c)
const;
96 INLINE PN_stdfloat get_ypos(
int r,
int c)
const;
100 INLINE
const LVector2 &get_ul()
const;
101 INLINE
const LVector2 &get_lr()
const;
103 static PN_stdfloat calc_width(
wchar_t character,
const TextProperties &properties);
106 static bool has_exact_character(
wchar_t character,
const TextProperties &properties);
107 static bool has_character(
wchar_t character,
const TextProperties &properties);
108 static bool is_whitespace(
wchar_t character,
const TextProperties &properties);
114 INLINE ComputedProperties(ComputedProperties *based_on,
116 void append_delta(wstring &wtext, ComputedProperties *other);
118 PT(ComputedProperties) _based_on;
128 class TextCharacter {
130 INLINE TextCharacter(
wchar_t character, ComputedProperties *cprops);
132 const wstring &graphic_wname,
133 ComputedProperties *cprops);
134 INLINE TextCharacter(
const TextCharacter ©);
135 INLINE
void operator = (
const TextCharacter ©);
139 wstring _graphic_wname;
140 PT(ComputedProperties) _cprops;
146 INLINE TextRow(
int row_start);
147 INLINE TextRow(
const TextRow ©);
148 INLINE
void operator = (
const TextRow ©);
152 bool _got_soft_hyphens;
155 PT(ComputedProperties) _eol_cprops;
159 PT(ComputedProperties) _initial_cprops;
167 #ifndef CPPPARSER // interrogate has a bit of trouble with wstring iterators.
169 wstring::const_iterator &si,
170 const wstring::const_iterator &send,
171 ComputedProperties *current_cprops);
174 bool wordwrap_text();
176 INLINE
static PN_stdfloat calc_width(
const TextCharacter &tch);
177 static PN_stdfloat calc_hyphen_width(
const TextCharacter &tch);
190 class GeomCollectorKey {
192 INLINE GeomCollectorKey(
const RenderState *state,
const GeomVertexFormat *format);
193 INLINE
bool operator < (
const GeomCollectorKey &other)
const;
196 CPT(GeomVertexFormat) _format;
201 class GeomCollector {
203 GeomCollector(
const GeomVertexFormat *format);
204 GeomCollector(
const GeomCollector ©);
206 INLINE
void count_geom(
const Geom *geom);
225 bool &found_any,
Thread *current_thread)
const;
243 void assemble_row(TextRow &row,
245 PN_stdfloat &row_width, PN_stdfloat &line_height,
246 TextProperties::Alignment &align, PN_stdfloat &wordwrap);
250 enum CheesyPosition {
257 enum CheesyTransform {
266 CT_squash_mirror_diag,
268 CT_small_squash_mirror_y,
269 CT_small_squash_mirror_diag,
279 PN_stdfloat underscore_start, PN_stdfloat underscore_end,
283 get_character_glyphs(
int character,
const TextProperties *properties,
284 bool &got_glyph,
const TextGlyph *&glyph,
286 UnicodeLatinMap::AccentType &accent_type,
287 int &additional_flags,
288 PN_stdfloat &glyph_scale, PN_stdfloat &advance_scale);
291 tack_on_accent(UnicodeLatinMap::AccentType accent_type,
294 const TextProperties *properties, GlyphPlacement *placement)
const;
296 tack_on_accent(
char accent_mark, CheesyPosition position,
297 CheesyTransform transform,
300 const TextProperties *properties, GlyphPlacement *placement)
const;
305 PN_stdfloat _next_row_ypos;
308 Geom::UsageHint _usage_hint;
311 bool _multiline_mode;
315 #include "textAssembler.I"
A basic node of the scene graph or data graph.
Defines a series of disconnected points.
This class can be used to convert text between multiple representations, e.g.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is a 4-by-4 transform matrix.
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
This class is not normally used directly by user code, but is used by the TextNode to lay out a block...
A representation of a single glyph (character) from a font.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Defines a series of disconnected line segments.
A base class for all things that want to be reference-counted.
This is a two-component vector offset.
A thread; that is, a lightweight process.
This defines the set of visual properties that may be assigned to the individual characters of the te...
Defines a series of disconnected triangles.
TypeHandle is the identifier used to differentiate C++ class types.
This defines a special model that has been constructed for the purposes of embedding an arbitrary gra...
A node that holds Geom objects, renderable pieces of geometry.