22 _usage_hint = usage_hint;
29 INLINE Geom::UsageHint TextAssembler::
30 get_usage_hint()
const {
50 INLINE
int TextAssembler::
51 get_max_rows()
const {
60 _dynamic_merge = dynamic_merge;
66 INLINE
bool TextAssembler::
67 get_dynamic_merge()
const {
68 return _dynamic_merge;
77 _multiline_mode = flag;
83 INLINE
bool TextAssembler::
84 get_multiline_mode()
const {
85 return _multiline_mode;
94 _initial_cprops =
new ComputedProperties(properties);
102 get_properties()
const {
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;
193 get_properties(
int n)
const {
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;
259 get_properties(
int r,
int c)
const {
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);
309 INLINE TextAssembler::TextCharacter::
310 TextCharacter(
wchar_t character,
311 TextAssembler::ComputedProperties *cprops) :
312 _character(character),
321 INLINE TextAssembler::TextCharacter::
322 TextCharacter(
const TextGraphic *graphic,
const std::wstring &graphic_wname,
323 TextAssembler::ComputedProperties *cprops) :
326 _graphic_wname(graphic_wname),
334 INLINE TextAssembler::TextCharacter::
335 TextCharacter(
const TextAssembler::TextCharacter ©) :
336 _character(copy._character),
337 _graphic(copy._graphic),
338 _graphic_wname(copy._graphic_wname),
339 _cprops(copy._cprops)
346 INLINE
void TextAssembler::TextCharacter::
347 operator = (
const TextAssembler::TextCharacter ©) {
348 _character = copy._character;
349 _graphic = copy._graphic;
350 _graphic_wname = copy._graphic_wname;
351 _cprops = copy._cprops;
357 INLINE TextAssembler::TextRow::
358 TextRow(
int row_start) :
359 _row_start(row_start),
360 _got_soft_hyphens(false),
369 INLINE TextAssembler::TextRow::
370 TextRow(
const TextAssembler::TextRow ©) :
371 _string(copy._string),
372 _row_start(copy._row_start),
373 _got_soft_hyphens(copy._got_soft_hyphens),
376 _eol_cprops(copy._eol_cprops)
383 INLINE
void TextAssembler::TextRow::
384 operator = (
const TextAssembler::TextRow ©) {
385 _string = copy._string;
386 _row_start = copy._row_start;
387 _got_soft_hyphens = copy._got_soft_hyphens;
390 _eol_cprops = copy._eol_cprops;
396 INLINE TextAssembler::ComputedProperties::
400 _properties(orig_properties)
407 INLINE TextAssembler::ComputedProperties::
408 ComputedProperties(ComputedProperties *based_on,
const std::wstring &wname,
411 _depth(_based_on->_depth + 1),
413 _properties(based_on->_properties)
423 if (named_props !=
nullptr) {
427 <<
"Unknown TextProperties: " << name <<
"\n";
434 INLINE TextAssembler::GeomCollectorKey::
444 INLINE
bool TextAssembler::GeomCollectorKey::
445 operator < (
const TextAssembler::GeomCollectorKey &other)
const {
446 if (_state != other._state) {
447 return _state < other._state;
449 return _format < other._format;
460 INLINE
void TextAssembler::GeomCollector::
461 count_geom(
const Geom *geom) {
463 _geom->count_geom(geom);
set_max_rows
If max_rows is greater than zero, no more than max_rows will be accepted.
PN_stdfloat get_width(int n) const
Returns the width of the character or object at the indicated position in the pre-wordwrapped string.
int get_num_cols(int r) const
Returns the number of characters and/or graphic objects in the nth row.
const TextGraphic * get_graphic(int n) const
Returns the graphic object at the indicated position in the pre-wordwrapped string.
set_usage_hint
Specifies the UsageHint that will be applied to generated geometry.
int get_num_characters() const
Returns the number of characters of text, before wordwrapping.
set_multiline_mode
Sets the multiline mode flag.
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.
const LVector2 & get_ul() const
Returns the upper-left corner of the assembled text, in 2-d text coordinates.
wchar_t get_character(int n) const
Returns the character at the indicated position in the pre-wordwrapped string.
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...
int get_num_rows() const
Returns the number of rows of text after it has all been wordwrapped and assembled.
static TextPropertiesManager * get_global_ptr()
Returns the pointer to the global TextPropertiesManager object.
set_dynamic_merge
Sets the dynamic_merge flag.
static PN_stdfloat calc_width(wchar_t character, const TextProperties &properties)
Returns the width of a single character, according to its associated font.
A container for geometry primitives.
set_properties
Specifies the default TextProperties that are applied to the text in the absence of any nested proper...
const LVector2 & get_lr() const
Returns the lower-right corner of the assembled text, in 2-d text coordinates.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
int calc_c(int n) const
Computes the column index of the nth character or graphic object in the text and returns it.
std::string encode_wtext(const std::wstring &wtext) const
Encodes a wide-text string into a single-char string, according to the current encoding.
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.
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...
int calc_r(int n) const
Computes the row index of the nth character or graphic object in the text and returns it.
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...