28 _usage_hint = usage_hint;
78 _dynamic_merge = dynamic_merge;
89 return _dynamic_merge;
100 _multiline_mode = flag;
111 return _multiline_mode;
123 _initial_cprops =
new ComputedProperties(properties);
135 return _initial_cprops->_properties;
210 return _text_string.size();
223 nassertr(n >= 0 && n < (
int)_text_string.size(), 0);
224 return _text_string[n]._character;
237 nassertr(n >= 0 && n < (
int)_text_string.size(), 0);
238 return _text_string[n]._graphic;
250 nassertr(n >= 0 && n < (
int)_text_string.size(), *(
new TextProperties()));
251 return _text_string[n]._cprops->_properties;
262 nassertr(n >= 0 && n < (
int)_text_string.size(), 0.0f);
275 return _text_block.size();
286 nassertr(r >= 0 && r <= (
int)_text_block.size(), 0);
287 if (r == (
int)_text_block.size()) {
290 return _text_block[r]._string.size();
302 nassertr(r >= 0 && r < (
int)_text_block.size(), 0);
303 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), 0);
304 return _text_block[r]._string[c]._character;
317 nassertr(r >= 0 && r < (
int)_text_block.size(), 0);
318 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), 0);
319 return _text_block[r]._string[c]._graphic;
330 nassertr(r >= 0 && r < (
int)_text_block.size(), *(
new TextProperties()));
331 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), *(
new TextProperties()));
332 return _text_block[r]._string[c]._cprops->_properties;
343 nassertr(r >= 0 && r < (
int)_text_block.size(), 0.0f);
344 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), 0.0f);
360 nassertr(r >= 0 && r <= (
int)_text_block.size(), 0.0f);
361 if (r == (
int)_text_block.size()) {
362 return _next_row_ypos;
364 return _text_block[r]._ypos;
377 return calc_width(tch._graphic, tch._cprops->_properties);
379 return calc_width(tch._character, tch._cprops->_properties);
388 INLINE TextAssembler::TextCharacter::
389 TextCharacter(
wchar_t character,
390 TextAssembler::ComputedProperties *cprops) :
391 _character(character),
402 INLINE TextAssembler::TextCharacter::
403 TextCharacter(
const TextGraphic *graphic,
const wstring &graphic_wname,
404 TextAssembler::ComputedProperties *cprops) :
407 _graphic_wname(graphic_wname),
417 INLINE TextAssembler::TextCharacter::
418 TextCharacter(
const TextAssembler::TextCharacter ©) :
419 _character(copy._character),
420 _graphic(copy._graphic),
421 _graphic_wname(copy._graphic_wname),
422 _cprops(copy._cprops)
431 INLINE
void TextAssembler::TextCharacter::
432 operator = (
const TextAssembler::TextCharacter ©) {
433 _character = copy._character;
434 _graphic = copy._graphic;
435 _graphic_wname = copy._graphic_wname;
436 _cprops = copy._cprops;
444 INLINE TextAssembler::TextRow::
445 TextRow(
int row_start) :
446 _row_start(row_start),
447 _got_soft_hyphens(false),
458 INLINE TextAssembler::TextRow::
459 TextRow(
const TextAssembler::TextRow ©) :
460 _string(copy._string),
461 _row_start(copy._row_start),
462 _got_soft_hyphens(copy._got_soft_hyphens),
465 _eol_cprops(copy._eol_cprops)
474 INLINE
void TextAssembler::TextRow::
475 operator = (
const TextAssembler::TextRow ©) {
476 _string = copy._string;
477 _row_start = copy._row_start;
478 _got_soft_hyphens = copy._got_soft_hyphens;
481 _eol_cprops = copy._eol_cprops;
489 INLINE TextAssembler::ComputedProperties::
493 _properties(orig_properties)
502 INLINE TextAssembler::ComputedProperties::
503 ComputedProperties(ComputedProperties *based_on,
const wstring &wname,
506 _depth(_based_on->_depth + 1),
508 _properties(based_on->_properties)
522 <<
"Unknown TextProperties: " << name <<
"\n";
536 INLINE
void TextAssembler::GlyphPlacement::
540 piece._state = state;
541 _pieces.push_back(piece);
549 INLINE TextAssembler::GeomCollectorKey::
550 GeomCollectorKey(
const RenderState *state,
const GeomVertexFormat *format) :
561 INLINE
bool TextAssembler::GeomCollectorKey::
562 operator < (
const TextAssembler::GeomCollectorKey &other)
const {
563 if (_state != other._state) {
564 return _state < other._state;
566 return _format < other._format;
581 INLINE
void TextAssembler::GeomCollector::
582 count_geom(
const Geom *geom) {
584 _geom->count_geom(geom);
int get_num_characters() const
Returns the number of characters of text, before wordwrapping.
int get_num_cols(int r) const
Returns the number of characters and/or graphic objects in the nth row.
int get_num_rows() const
Returns the number of rows of text after it has all been wordwrapped and assembled.
void add_properties(const TextProperties &other)
Sets any properties that are explicitly specified in other on this object.
This class can be used to convert text between multiple representations, e.g.
bool get_multiline_mode() const
Returns the multline_mode flag.
const TextProperties & get_properties() const
Returns the default TextProperties that are applied to the text in the absence of any nested property...
string encode_wtext(const wstring &wtext) const
Encodes a wide-text string into a single-char string, according to the current encoding.
wchar_t get_character(int n) const
Returns the character at the indicated position in the pre-wordwrapped string.
int calc_r(int n) const
Computes the row index of the nth character or graphic object in the text and returns it...
int get_max_rows() const
If max_rows is greater than zero, no more than max_rows will be accepted.
void set_properties(const TextProperties &properties)
Specifies the default TextProperties that are applied to the text in the absence of any nested proper...
void set_multiline_mode(bool flag)
Sets the multiline mode flag.
static TextPropertiesManager * get_global_ptr()
Returns the pointer to the global TextPropertiesManager object.
const LVector2 & get_lr() const
Returns the lower-right corner of the assembled text, in 2-d text coordinates.
const LVector2 & get_ul() const
Returns the upper-left corner of the assembled text, in 2-d text coordinates.
static PN_stdfloat calc_width(wchar_t character, const TextProperties &properties)
Returns the width of a single character, according to its associated font.
Geom::UsageHint get_usage_hint() const
Returns the UsageHint that will be applied to generated geometry.
A container for geometry primitives.
const TextProperties * get_properties_ptr(const string &name)
Returns a pointer to the TextProperties with the indicated name, or NULL if there is no properties wi...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PN_stdfloat get_width(int n) const
Returns the width of the character or object at the indicated position in the pre-wordwrapped string...
void set_max_rows(int max_rows)
If max_rows is greater than zero, no more than max_rows will be accepted.
This is a two-component vector offset.
const TextGraphic * get_graphic(int n) const
Returns the graphic object at the indicated position in the pre-wordwrapped string.
This defines the set of visual properties that may be assigned to the individual characters of the te...
void set_usage_hint(Geom::UsageHint usage_hint)
Specifies the UsageHint that will be applied to generated geometry.
PN_stdfloat get_ypos(int r, int c) const
Returns the y position of the origin of all of the characters or graphic objects in the indicated row...
This defines all of the TextProperties structures that might be referenced by name from an embedded t...
This defines a special model that has been constructed for the purposes of embedding an arbitrary gra...
void set_dynamic_merge(bool dynamic_merge)
Sets the dynamic_merge flag.
bool get_dynamic_merge() const
Returns the dynamic_merge flag.
bool calc_r_c(int &r, int &c, int n) const
Computes the row and column index of the nth character or graphic object in the text.
int calc_c(int n) const
Computes the column index of the nth character or graphic object in the text and returns it...