28 #include "config_auto.h"
32 "Max allowed bending of chop cells");
34 "Max distance of chop pt from vertex");
52 int16_t prev_chop_coord;
55 C_OUTLINE_LIST left_coutlines;
56 C_OUTLINE_LIST right_coutlines;
58 C_BLOB_IT cblob_it = &cblobs;
60 WERD_IT word_it = &words;
62 WERD_IT rep_it = &row->rep_words;
67 BLOBNBOX_IT box_it = row->blob_list ();
69 ICOORDELT_IT cell_it = &row->char_cells;
71 #ifndef GRAPHICS_DISABLED
83 rep_left = rep_it.data ()->bounding_box ().left ();
86 xstarts[0] = box_it.data ()->bounding_box ().left ();
87 if (rep_left < xstarts[0]) {
88 xstarts[0] = rep_left;
90 if (cell_it.empty () || row->char_cells.singleton ()) {
91 tprintf (
"Row without enough char cells!\n");
92 tprintf (
"Leftmost blob is at (%d,%d)\n",
93 box_it.data ()->bounding_box ().left (),
94 box_it.data ()->bounding_box ().bottom ());
97 ASSERT_HOST (!cell_it.empty () && !row->char_cells.singleton ());
98 prev_chop_coord = cell_it.data ()->x ();
100 while (rep_left < cell_it.data ()->x ()) {
102 blanks, row->fixed_pitch, &word_it);
104 cell_it.mark_cycle_pt ();
105 if (prev_chop_coord >= cell_it.data ()->x ())
107 for (; !cell_it.cycled_list (); cell_it.forward ()) {
108 chop_coord = cell_it.data ()->x ();
109 while (!box_it.empty ()
110 && box_it.data ()->bounding_box ().left () <= chop_coord) {
111 if (box_it.data ()->bounding_box ().right () > prev_x)
112 prev_x = box_it.data ()->bounding_box ().right ();
118 while (!box_it.empty() && box_it.data()->cblob() ==
nullptr) {
119 delete box_it.extract();
123 if (!right_coutlines.empty() && left_coutlines.empty())
128 if (!left_coutlines.empty()) {
129 cblob_it.add_after_then_move(
new C_BLOB(&left_coutlines));
131 if (rep_left < chop_coord) {
132 if (rep_left > prev_chop_coord)
133 new_blanks = static_cast<uint8_t>(floor ((rep_left - prev_chop_coord)
134 / row->fixed_pitch + 0.5));
139 if (chop_coord > prev_chop_coord)
140 new_blanks = static_cast<uint8_t>(floor ((chop_coord - prev_chop_coord)
141 / row->fixed_pitch + 0.5));
145 if (!cblob_it.empty()) {
146 if (blanks < 1 && word != nullptr && !word->flag (
W_REP_CHAR))
148 word =
new WERD (&cblobs, blanks,
nullptr);
149 cblob_it.set_to_list (&cblobs);
151 word_it.add_after_then_move (word);
159 blanks += new_blanks;
160 while (rep_left < chop_coord) {
162 blanks, row->fixed_pitch, &word_it);
165 if (prev_chop_coord < chop_coord)
166 prev_chop_coord = chop_coord;
168 if (!cblob_it.empty()) {
169 word =
new WERD(&cblobs, blanks,
nullptr);
171 word_it.add_after_then_move (word);
176 while (!rep_it.empty ()) {
178 blanks, row->fixed_pitch, &word_it);
181 word_it.data ()->set_flag (
W_EOL,
true);
182 if (prev_chop_coord > prev_x)
183 prev_x = prev_chop_coord;
184 xstarts[1] = prev_x + 1;
185 real_row =
new ROW (row, static_cast<int16_t>(row->kern_size), static_cast<int16_t>(row->space_size));
186 word_it.set_to_list (real_row->
word_list ());
188 word_it.add_list_after (&words);
203 int16_t &prev_chop_coord,
211 if (rep_left > prev_chop_coord) {
212 new_blanks = static_cast<uint8_t>(floor ((rep_left - prev_chop_coord) / pitch + 0.5));
213 blanks += new_blanks;
215 word = rep_it->extract ();
217 word_it->add_after_then_move (word);
220 if (rep_it->empty ())
221 rep_left = INT16_MAX;
223 rep_left = rep_it->data ()->bounding_box ().left ();
240 C_OUTLINE_LIST *left_coutlines,
241 C_OUTLINE_LIST *right_coutlines) {
244 if (blob !=
nullptr) {
245 real_cblob = blob->
cblob();
247 real_cblob =
nullptr;
249 if (!right_coutlines->empty() || real_cblob !=
nullptr)
270 C_OUTLINE_LIST *left_outlines,
271 C_OUTLINE_LIST *right_outlines
274 C_OUTLINE_LIST new_outlines;
276 C_OUTLINE_IT left_it = left_outlines;
278 C_OUTLINE_IT right_it = right_outlines;
279 C_OUTLINE_IT new_it = &new_outlines;
280 C_OUTLINE_IT blob_it;
282 if (!right_it.empty ()) {
283 while (!right_it.empty ()) {
284 old_right = right_it.extract ();
292 right_it.add_list_before (&new_outlines);
294 if (blob !=
nullptr) {
295 blob_it.set_to_list (blob->
out_list ());
296 for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();
299 &left_it, &right_it);
316 C_OUTLINE_IT *left_it,
317 C_OUTLINE_IT *right_it
321 C_OUTLINE_LIST left_ch;
322 C_OUTLINE_LIST right_ch;
323 C_OUTLINE_FRAG_LIST left_frags;
324 C_OUTLINE_FRAG_LIST right_frags;;
325 C_OUTLINE_IT left_ch_it = &left_ch;
327 C_OUTLINE_IT right_ch_it = &right_ch;
329 C_OUTLINE_IT child_it = srcline->
child ();
332 if (srcbox.
left() + srcbox.
right() <= chop_coord * 2
333 && srcbox.
right() < chop_coord + pitch_error) {
336 left_it->add_after_then_move(srcline);
337 }
else if (srcbox.
left() + srcbox.
right() > chop_coord * 2
338 && srcbox.
left () > chop_coord - pitch_error) {
341 right_it->add_before_stay_put(srcline);
345 &left_frags, &right_frags)) {
346 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
347 child_it.forward()) {
348 child = child_it.extract();
350 if (srcbox.
right() < chop_coord) {
352 left_ch_it.add_after_then_move(child);
353 }
else if (srcbox.
left() > chop_coord) {
355 right_ch_it.add_after_then_move (child);
360 &left_frags, &right_frags)) {
363 if (srcbox.
left() + srcbox.
right() <= chop_coord * 2)
364 left_ch_it.add_after_then_move(child);
366 right_ch_it.add_after_then_move(child);
377 if (srcbox.
left() + srcbox.
right() <= chop_coord * 2)
378 left_it->add_after_then_move(srcline);
380 right_it->add_before_stay_put(srcline);
398 C_OUTLINE_FRAG_LIST* left_frags,
399 C_OUTLINE_FRAG_LIST* right_frags
411 int16_t first_index = 0;
416 left_edge = pos.
x ();
419 for (stepindex = 0; stepindex < length; stepindex++) {
420 if (pos.
x () < left_edge) {
421 left_edge = pos.
x ();
422 tail_index = stepindex;
425 pos += srcline->
step (stepindex);
427 if (left_edge >= chop_coord - pitch_error)
430 startindex = tail_index;
432 head_index = tail_index;
436 tail_pos += srcline->
step (tail_index);
438 if (tail_index == length)
441 while (tail_pos.
x () != chop_coord && tail_index != startindex);
442 if (tail_index == startindex) {
458 first_index = tail_index;
459 first_pos = tail_pos;
462 while (srcline->
step (tail_index).
x () == 0) {
463 tail_pos += srcline->
step (tail_index);
465 if (tail_index == length)
468 head_index = tail_index;
470 while (srcline->
step (tail_index).
x () > 0) {
472 tail_pos += srcline->
step (tail_index);
474 if (tail_index == length)
477 while (tail_pos.
x () != chop_coord);
485 while (srcline->
step (tail_index).
x () == 0) {
486 tail_pos += srcline->
step (tail_index);
488 if (tail_index == length)
491 head_index = tail_index;
495 while (tail_index != startindex);
517 C_OUTLINE_FRAG_LIST *frags
527 stepcount = tail_index - head_index;
530 jump = tail_pos.
y () - head_pos.
y ();
533 if (jump == stepcount)
535 tail_y = tail_pos.
y ();
537 head_index, tail_index);
565 if (end_index > start_index) {
566 for (
int i = start_index; i < end_index; ++i)
575 for (; i < end_index + len; ++i)
604 C_OUTLINE_FRAG_LIST *frags
607 C_OUTLINE_FRAG_IT frag_it = frags;
609 if (!frags->empty ()) {
610 for (frag_it.mark_cycle_pt (); !frag_it.cycled_list ();
611 frag_it.forward ()) {
612 if (frag_it.data ()->ycoord > frag->
ycoord
613 || (frag_it.data ()->ycoord == frag->
ycoord
615 frag_it.add_before_then_move (frag);
620 frag_it.add_to_end (frag);
632 C_OUTLINE_FRAG_LIST *frags,
633 C_OUTLINE_LIST *children,
635 C_OUTLINE_IT *dest_it
638 C_OUTLINE_FRAG_IT frag_it = frags;
643 C_OUTLINE_IT child_it = children;
644 C_OUTLINE_IT olchild_it;
646 while (!frag_it.empty()) {
647 frag_it.move_to_first();
649 bottom_frag = frag_it.extract();
651 top_frag = frag_it.data();
652 if ((bottom_frag->
steps ==
nullptr && top_frag->
steps ==
nullptr)
653 || (bottom_frag->
steps !=
nullptr && top_frag->
steps !=
nullptr)) {
654 if (frag_it.data_relative(1)->ycoord == top_frag->
ycoord)
657 top_frag = frag_it.extract();
658 if (top_frag->
other_end != bottom_frag) {
663 if (outline !=
nullptr) {
664 olchild_it.set_to_list(outline->
child());
665 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
666 child_it.forward()) {
667 child = child_it.data();
668 if (*child < *outline)
669 olchild_it.add_to_end(child_it.extract());
672 dest_it->add_after_then_move(outline);
678 while (!child_it.empty ()) {
679 dest_it->add_after_then_move (child_it.extract ());
699 if (bottom->
steps ==
nullptr)
700 outline = top->
close ();
702 outline = bottom->
close ();
707 if (bottom->
steps ==
nullptr) {
739 fake_count = top->
start.
y () - bottom->
end.
y ();
740 if (fake_count < 0) {
741 fake_count = -fake_count;
748 steps =
new DIR128[stepcount];
754 bottom->
steps = steps;
769 int32_t new_stepcount;
775 if (fake_count < 0) {
776 fake_count = -fake_count;
785 new_steps =
new DIR128[new_stepcount];