22 _usage_hint = usage_hint;
60 _dynamic_merge = dynamic_merge;
68 return _dynamic_merge;
77 _multiline_mode = flag;
85 return _multiline_mode;
94 _initial_cprops =
new ComputedProperties(properties);
103 return _initial_cprops->_properties;
163 return _text_string.size();
173 nassertr(n >= 0 && n < (
int)_text_string.size(), 0);
174 return _text_string[n]._character;
184 nassertr(n >= 0 && n < (
int)_text_string.size(), 0);
185 return _text_string[n]._graphic;
194 nassertr(n >= 0 && n < (
int)_text_string.size(), *(
new TextProperties()));
195 return _text_string[n]._cprops->_properties;
204 nassertr(n >= 0 && n < (
int)_text_string.size(), 0.0f);
215 return _text_block.size();
223 nassertr(r >= 0 && r <= (
int)_text_block.size(), 0);
224 if (r == (
int)_text_block.size()) {
227 return _text_block[r]._string.size();
237 nassertr(r >= 0 && r < (
int)_text_block.size(), 0);
238 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), 0);
239 return _text_block[r]._string[c]._character;
249 nassertr(r >= 0 && r < (
int)_text_block.size(), 0);
250 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), 0);
251 return _text_block[r]._string[c]._graphic;
260 nassertr(r >= 0 && r < (
int)_text_block.size(), *(
new TextProperties()));
261 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), *(
new TextProperties()));
262 return _text_block[r]._string[c]._cprops->_properties;
271 nassertr(r >= 0 && r < (
int)_text_block.size(), 0.0f);
272 nassertr(c >= 0 && c < (
int)_text_block[r]._string.size(), 0.0f);
286 nassertr(r >= 0 && r <= (
int)_text_block.size(), 0.0f);
287 if (r == (
int)_text_block.size()) {
288 return _next_row_ypos;
290 return _text_block[r]._ypos;
299 if (tch._graphic !=
nullptr) {
300 return calc_width(tch._graphic, tch._cprops->_properties);
302 return calc_width(tch._character, tch._cprops->_properties);
309INLINE TextAssembler::TextCharacter::
310TextCharacter(
wchar_t character,
311 TextAssembler::ComputedProperties *cprops) :
312 _character(character),
321INLINE TextAssembler::TextCharacter::
322TextCharacter(
char32_t character,
323 TextAssembler::ComputedProperties *cprops) :
324 _character(character),
333INLINE TextAssembler::TextCharacter::
334TextCharacter(
const TextGraphic *graphic,
const std::wstring &graphic_wname,
335 TextAssembler::ComputedProperties *cprops) :
338 _graphic_wname(graphic_wname),
346INLINE TextAssembler::TextCharacter::
347TextCharacter(
const TextAssembler::TextCharacter ©) :
348 _character(copy._character),
349 _graphic(copy._graphic),
350 _graphic_wname(copy._graphic_wname),
351 _cprops(copy._cprops)
358INLINE
void TextAssembler::TextCharacter::
359operator = (
const TextAssembler::TextCharacter ©) {
360 _character = copy._character;
361 _graphic = copy._graphic;
362 _graphic_wname = copy._graphic_wname;
363 _cprops = copy._cprops;
369INLINE TextAssembler::TextRow::
370TextRow(
int row_start) :
371 _row_start(row_start),
372 _got_soft_hyphens(false),
381INLINE TextAssembler::TextRow::
382TextRow(
const TextAssembler::TextRow ©) :
383 _string(copy._string),
384 _row_start(copy._row_start),
385 _got_soft_hyphens(copy._got_soft_hyphens),
388 _eol_cprops(copy._eol_cprops)
395INLINE
void TextAssembler::TextRow::
396operator = (
const TextAssembler::TextRow ©) {
397 _string = copy._string;
398 _row_start = copy._row_start;
399 _got_soft_hyphens = copy._got_soft_hyphens;
402 _eol_cprops = copy._eol_cprops;
408INLINE TextAssembler::ComputedProperties::
412 _properties(orig_properties)
419INLINE TextAssembler::ComputedProperties::
420ComputedProperties(ComputedProperties *based_on,
const std::wstring &wname,
423 _depth(_based_on->_depth + 1),
425 _properties(based_on->_properties)
435 if (named_props !=
nullptr) {
439 <<
"Unknown TextProperties: " << name <<
"\n";
446INLINE TextAssembler::GeomCollectorKey::
456INLINE
bool TextAssembler::GeomCollectorKey::
457operator < (
const TextAssembler::GeomCollectorKey &other)
const {
458 if (_state != other._state) {
459 return _state < other._state;
461 return _format < other._format;
472INLINE
void TextAssembler::GeomCollector::
473count_geom(
const Geom *geom) {
475 _geom->count_geom(geom);
A container for geometry primitives.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
set_usage_hint
Specifies the UsageHint that will be applied to generated geometry.
set_multiline_mode
Sets the multiline mode flag.
const LVector2 & get_ul() const
Returns the upper-left corner of the assembled text, in 2-d text coordinates.
int get_num_rows() const
Returns the number of rows of text after it has all been wordwrapped and assembled.
get_multiline_mode
Returns the multline_mode 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.
set_max_rows
If max_rows is greater than zero, no more than max_rows will be accepted.
int calc_c(int n) const
Computes the column index of the nth character or graphic object in the text and returns it.
int get_num_cols(int r) const
Returns the number of characters and/or graphic objects in the nth row.
get_properties
Returns the default TextProperties that are applied to the text in the absence of any nested property...
int get_num_characters() const
Returns the number of characters of text, before wordwrapping.
get_usage_hint
Returns the UsageHint that will be applied to generated geometry.
get_max_rows
If max_rows is greater than zero, no more than max_rows will be accepted.
get_dynamic_merge
Returns the dynamic_merge flag.
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...
static PN_stdfloat calc_width(wchar_t character, const TextProperties &properties)
Returns the width of a single character, according to its associated font.
const TextGraphic * get_graphic(int n) const
Returns the graphic object 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.
PN_stdfloat get_width(int n) const
Returns the width of the character or object at the indicated position in the pre-wordwrapped string.
const LVector2 & get_lr() const
Returns the lower-right corner of the assembled text, in 2-d text coordinates.
set_dynamic_merge
Sets the dynamic_merge flag.
char32_t get_character(int n) const
Returns the character at the indicated position in the pre-wordwrapped string.
set_properties
Specifies the default TextProperties that are applied to the text in the absence of any nested proper...
This class can be used to convert text between multiple representations, e.g.
std::string encode_wtext(const std::wstring &wtext) const
Encodes a wide-text string into a single-char string, according to the current encoding.
This defines a special model that has been constructed for the purposes of embedding an arbitrary gra...
This defines all of the TextProperties structures that might be referenced by name from an embedded t...
static TextPropertiesManager * get_global_ptr()
Returns the pointer to the global TextPropertiesManager object.
const TextProperties * get_properties_ptr(const std::string &name)
Returns a pointer to the TextProperties with the indicated name, or NULL if there is no properties wi...
This defines the set of visual properties that may be assigned to the individual characters of the te...
void add_properties(const TextProperties &other)
Sets any properties that are explicitly specified in other on this object.