14 #ifndef TEXTASSEMBLER_H
15 #define TEXTASSEMBLER_H
31 typedef struct hb_buffer_t hb_buffer_t;
52 INLINE
void set_usage_hint(Geom::UsageHint usage_hint);
53 INLINE Geom::UsageHint get_usage_hint()
const;
55 INLINE
void set_max_rows(
int max_rows);
56 INLINE
int get_max_rows()
const;
58 INLINE
void set_dynamic_merge(
bool dynamic_merge);
59 INLINE
bool get_dynamic_merge()
const;
61 INLINE
void set_multiline_mode(
bool flag);
62 INLINE
bool get_multiline_mode()
const;
67 bool set_wtext(
const std::wstring &wtext);
68 bool set_wsubstr(
const std::wstring &wtext,
int start,
int count);
70 std::wstring get_plain_wtext()
const;
71 std::wstring get_wordwrapped_plain_wtext()
const;
72 std::wstring get_wtext()
const;
73 std::wstring get_wordwrapped_wtext()
const;
75 bool calc_r_c(
int &r,
int &c,
int n)
const;
76 INLINE
int calc_r(
int n)
const;
77 INLINE
int calc_c(
int n)
const;
78 int calc_index(
int r,
int c)
const;
80 INLINE
int get_num_characters()
const;
81 INLINE
wchar_t get_character(
int n)
const;
84 INLINE PN_stdfloat get_width(
int n)
const;
86 INLINE
int get_num_rows()
const;
87 INLINE
int get_num_cols(
int r)
const;
88 INLINE
wchar_t get_character(
int r,
int c)
const;
89 INLINE
const TextGraphic *get_graphic(
int r,
int c)
const;
91 INLINE PN_stdfloat get_width(
int r,
int c)
const;
92 PN_stdfloat get_xpos(
int r,
int c)
const;
93 INLINE PN_stdfloat get_ypos(
int r,
int c)
const;
97 INLINE
const LVector2 &get_ul()
const;
98 INLINE
const LVector2 &get_lr()
const;
100 static PN_stdfloat calc_width(
wchar_t character,
const TextProperties &properties);
103 static bool has_exact_character(
wchar_t character,
const TextProperties &properties);
104 static bool has_character(
wchar_t character,
const TextProperties &properties);
105 static bool is_whitespace(
wchar_t character,
const TextProperties &properties);
108 MAKE_PROPERTY(usage_hint, get_usage_hint, set_usage_hint);
109 MAKE_PROPERTY(max_rows, get_max_rows, set_max_rows);
110 MAKE_PROPERTY(dynamic_merge, get_dynamic_merge, set_dynamic_merge);
111 MAKE_PROPERTY(multiline_mode, get_multiline_mode, set_multiline_mode);
112 MAKE_PROPERTY(properties, get_properties, set_properties);
118 INLINE ComputedProperties(ComputedProperties *based_on,
120 void append_delta(std::wstring &wtext, ComputedProperties *other);
122 PT(ComputedProperties) _based_on;
132 class TextCharacter {
134 INLINE TextCharacter(
wchar_t character, ComputedProperties *cprops);
136 const std::wstring &graphic_wname,
137 ComputedProperties *cprops);
138 INLINE TextCharacter(
const TextCharacter ©);
139 INLINE
void operator = (
const TextCharacter ©);
143 std::wstring _graphic_wname;
144 PT(ComputedProperties) _cprops;
150 INLINE TextRow(
int row_start);
151 INLINE TextRow(
const TextRow ©);
152 INLINE
void operator = (
const TextRow ©);
156 bool _got_soft_hyphens;
159 PT(ComputedProperties) _eol_cprops;
163 PT(ComputedProperties) _initial_cprops;
166 TextString _text_string;
169 TextBlock _text_block;
171 void scan_wtext(TextString &output_string,
172 std::wstring::const_iterator &si,
173 const std::wstring::const_iterator &send,
174 ComputedProperties *current_cprops);
176 bool wordwrap_text();
178 INLINE
static PN_stdfloat calc_width(
const TextCharacter &tch);
179 static PN_stdfloat calc_hyphen_width(
const TextCharacter &tch);
184 class GeomCollectorKey {
187 INLINE
bool operator < (
const GeomCollectorKey &other)
const;
195 class GeomCollector {
198 GeomCollector(
const GeomCollector ©);
200 INLINE
void count_geom(
const Geom *geom);
203 const LMatrix4 &xform);
216 LVecBase4 _dimensions;
218 PN_stdfloat _slantl, _slanth;
221 typedef epvector<QuadDef> QuadDefs;
224 void generate_quads(
GeomNode *geom_node,
const QuadMap &quad_map);
226 class GlyphPlacement {
229 const LVector2 &offset = LVector2::zero())
const;
231 void assign_append_to(GeomCollectorMap &geom_collector_map,
const RenderState *state,
232 const LVector2 &offset = LVector2::zero())
const;
233 void assign_quad_to(QuadMap &quad_map,
const RenderState *state,
234 const LVector2 &offset = LVector2::zero())
const;
239 PN_stdfloat _xpos, _ypos;
240 PN_stdfloat _scale, _slant;
245 void assemble_paragraph(PlacedGlyphs &placed_glyphs);
246 void assemble_row(TextRow &row,
247 PlacedGlyphs &row_placed_glyphs,
248 PN_stdfloat &row_width, PN_stdfloat &line_height,
249 TextProperties::Alignment &align, PN_stdfloat &wordwrap);
251 void shape_buffer(hb_buffer_t *buf, PlacedGlyphs &glyphs, PN_stdfloat &xpos,
256 enum CheesyPosition {
263 enum CheesyTransform {
272 CT_squash_mirror_diag,
274 CT_small_squash_mirror_y,
275 CT_small_squash_mirror_diag,
285 PN_stdfloat underscore_start, PN_stdfloat underscore_end,
289 get_character_glyphs(
int character,
const TextProperties *properties,
292 UnicodeLatinMap::AccentType &accent_type,
293 int &additional_flags,
294 PN_stdfloat &glyph_scale, PN_stdfloat &advance_scale);
297 tack_on_accent(UnicodeLatinMap::AccentType accent_type,
298 const LPoint3 &min_vert,
const LPoint3 &max_vert,
299 const LPoint3 ¢roid,
300 const TextProperties *properties, GlyphPlacement &placement)
const;
302 tack_on_accent(
wchar_t accent_mark, CheesyPosition position,
303 CheesyTransform transform,
304 const LPoint3 &min_vert,
const LPoint3 &max_vert,
305 const LPoint3 ¢roid,
306 const TextProperties *properties, GlyphPlacement &placement)
const;
311 PN_stdfloat _next_row_ypos;
314 Geom::UsageHint _usage_hint;
317 bool _multiline_mode;