35 #include "config_auto.h"
41 "Max allowed bending of chop cells");
43 "Max distance of chop pt from vertex");
61 inT16 prev_chop_coord;
64 C_OUTLINE_LIST left_coutlines;
65 C_OUTLINE_LIST right_coutlines;
67 C_BLOB_IT cblob_it = &cblobs;
69 WERD_IT word_it = &words;
71 WERD_IT rep_it = &row->rep_words;
77 BLOBNBOX_IT box_it = row->blob_list ();
79 ICOORDELT_IT cell_it = &row->char_cells;
81 #ifndef GRAPHICS_DISABLED
93 rep_left = rep_it.data ()->bounding_box ().left ();
96 xstarts[0] = box_it.data ()->bounding_box ().left ();
97 if (rep_left < xstarts[0]) {
98 xstarts[0] = rep_left;
100 if (cell_it.empty () || row->char_cells.singleton ()) {
101 tprintf (
"Row without enough char cells!\n");
102 tprintf (
"Leftmost blob is at (%d,%d)\n",
103 box_it.data ()->bounding_box ().left (),
104 box_it.data ()->bounding_box ().bottom ());
107 ASSERT_HOST (!cell_it.empty () && !row->char_cells.singleton ());
108 prev_chop_coord = cell_it.data ()->x ();
110 while (rep_left < cell_it.data ()->x ()) {
112 blanks, row->fixed_pitch, &word_it);
114 cell_it.mark_cycle_pt ();
115 if (prev_chop_coord >= cell_it.data ()->x ())
117 for (; !cell_it.cycled_list (); cell_it.forward ()) {
118 chop_coord = cell_it.data ()->x ();
119 while (!box_it.empty ()
120 && box_it.data ()->bounding_box ().left () <= chop_coord) {
121 if (box_it.data ()->bounding_box ().right () > prev_x)
122 prev_x = box_it.data ()->bounding_box ().right ();
128 while (!box_it.empty() && box_it.data()->cblob() ==
NULL) {
129 delete box_it.extract();
133 if (!right_coutlines.empty() && left_coutlines.empty())
138 if (!left_coutlines.empty ())
139 cblob_it.add_after_then_move (
new C_BLOB (&left_coutlines));
141 if (rep_left < chop_coord) {
142 if (rep_left > prev_chop_coord)
143 new_blanks = (
uinT8) floor ((rep_left - prev_chop_coord)
144 / row->fixed_pitch + 0.5);
149 if (chop_coord > prev_chop_coord)
150 new_blanks = (
uinT8) floor ((chop_coord - prev_chop_coord)
151 / row->fixed_pitch + 0.5);
155 if (!cblob_it.empty()) {
156 if (blanks < 1 && word != NULL && !word->flag (
W_REP_CHAR))
158 word =
new WERD (&cblobs, blanks,
NULL);
159 cblob_it.set_to_list (&cblobs);
161 word_it.add_after_then_move (word);
169 blanks += new_blanks;
170 while (rep_left < chop_coord) {
172 blanks, row->fixed_pitch, &word_it);
175 if (prev_chop_coord < chop_coord)
176 prev_chop_coord = chop_coord;
178 if (!cblob_it.empty()) {
179 word =
new WERD(&cblobs, blanks,
NULL);
181 word_it.add_after_then_move (word);
186 while (!rep_it.empty ()) {
188 blanks, row->fixed_pitch, &word_it);
192 if (prev_chop_coord > prev_x)
193 prev_x = prev_chop_coord;
194 xstarts[1] = prev_x + 1;
196 coeffs[1] = row->line_m ();
197 coeffs[2] = row->line_c ();
198 real_row =
new ROW (row, (
inT16) row->kern_size, (
inT16) row->space_size);
199 word_it.set_to_list (real_row->
word_list ());
201 word_it.add_list_after (&words);
216 inT16 &prev_chop_coord,
224 if (rep_left > prev_chop_coord) {
225 new_blanks = (
uinT8) floor ((rep_left - prev_chop_coord) / pitch + 0.5);
226 blanks += new_blanks;
228 word = rep_it->extract ();
230 word_it->add_after_then_move (word);
233 if (rep_it->empty ())
236 rep_left = rep_it->data ()->bounding_box ().left ();
253 C_OUTLINE_LIST *left_coutlines,
254 C_OUTLINE_LIST *right_coutlines) {
258 real_cblob = blob->
cblob();
262 if (!right_coutlines->empty() || real_cblob !=
NULL)
283 C_OUTLINE_LIST *left_outlines,
284 C_OUTLINE_LIST *right_outlines
287 C_OUTLINE_LIST new_outlines;
289 C_OUTLINE_IT left_it = left_outlines;
291 C_OUTLINE_IT right_it = right_outlines;
292 C_OUTLINE_IT new_it = &new_outlines;
293 C_OUTLINE_IT blob_it;
295 if (!right_it.empty ()) {
296 while (!right_it.empty ()) {
297 old_right = right_it.extract ();
305 right_it.add_list_before (&new_outlines);
308 blob_it.set_to_list (blob->
out_list ());
309 for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();
312 &left_it, &right_it);
329 C_OUTLINE_IT *left_it,
330 C_OUTLINE_IT *right_it
334 C_OUTLINE_LIST left_ch;
335 C_OUTLINE_LIST right_ch;
336 C_OUTLINE_FRAG_LIST left_frags;
337 C_OUTLINE_FRAG_LIST right_frags;;
338 C_OUTLINE_IT left_ch_it = &left_ch;
340 C_OUTLINE_IT right_ch_it = &right_ch;
342 C_OUTLINE_IT child_it = srcline->
child ();
346 if (srcbox.
left () + srcbox.
right () <= chop_coord * 2
348 && srcbox.
right () < chop_coord + pitch_error)
350 left_it->add_after_then_move (srcline);
351 else if (srcbox.
left () + srcbox.
right () > chop_coord * 2
352 && srcbox.
left () > chop_coord - pitch_error)
354 right_it->add_before_stay_put (srcline);
358 &left_frags, &right_frags)) {
359 for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
360 child_it.forward ()) {
361 child = child_it.extract ();
363 if (srcbox.
right () < chop_coord)
364 left_ch_it.add_after_then_move (child);
365 else if (srcbox.
left () > chop_coord)
366 right_ch_it.add_after_then_move (child);
369 &left_frags, &right_frags))
372 if (srcbox.
left () + srcbox.
right () <= chop_coord * 2)
373 left_ch_it.add_after_then_move (child);
375 right_ch_it.add_after_then_move (child);
381 ASSERT_HOST (left_ch.empty () && right_ch.empty ());
386 if (srcbox.
left () + srcbox.
right () <= chop_coord * 2)
388 left_it->add_after_then_move (srcline);
390 right_it->add_before_stay_put (srcline);
408 C_OUTLINE_FRAG_LIST *left_frags,
409 C_OUTLINE_FRAG_LIST *right_frags
422 inT16 first_index = 0;
428 left_edge = pos.
x ();
431 for (stepindex = 0; stepindex < length; stepindex++) {
432 if (pos.
x () < left_edge) {
433 left_edge = pos.
x ();
434 tail_index = stepindex;
437 pos += srcline->
step (stepindex);
439 if (left_edge >= chop_coord - pitch_error)
442 startindex = tail_index;
444 head_index = tail_index;
448 tail_pos += srcline->
step (tail_index);
450 if (tail_index == length)
453 while (tail_pos.
x () != chop_coord && tail_index != startindex);
454 if (tail_index == startindex) {
472 first_index = tail_index;
473 first_pos = tail_pos;
476 while (srcline->
step (tail_index).
x () == 0) {
477 tail_pos += srcline->
step (tail_index);
479 if (tail_index == length)
482 head_index = tail_index;
484 while (srcline->
step (tail_index).
x () > 0) {
486 tail_pos += srcline->
step (tail_index);
488 if (tail_index == length)
491 while (tail_pos.
x () != chop_coord);
501 while (srcline->
step (tail_index).
x () == 0) {
502 tail_pos += srcline->
step (tail_index);
504 if (tail_index == length)
507 head_index = tail_index;
511 while (tail_index != startindex);
546 test_index = tail_index;
548 *tail_pos += srcline->
step (tail_index);
549 prev_step = srcline->
step (tail_index);
551 if (tail_index >= length)
553 if (test_valid && tail_pos->
x () == chop_coord && prev_step.
x () < 0) {
554 if (tail_pos->
y () >= chop_starty) {
559 *tail_pos = test_pos;
560 tail_index = test_index;
564 if (tail_pos->
x () == chop_coord
565 && srcline->
step (tail_index).
x () > 0
566 && tail_pos->
y () > chop_starty) {
567 chop_starty = tail_pos->
y ();
568 test_index = tail_index;
569 test_pos = *tail_pos;
572 else if (tail_pos->
x () == chop_coord
573 && srcline->
step (tail_index).
y () < 0
574 && prev_step.
x () > 0 && tail_pos->
y () > chop_starty)
577 while (tail_index != startindex
578 && tail_pos->
x () < chop_coord + pitch_error);
607 test_index = tail_index;
610 *tail_pos += srcline->
step (tail_index);
611 prev_step = srcline->
step (tail_index);
613 if (tail_index >= length)
615 if (test_valid && tail_pos->
x () == chop_coord && prev_step.
x () > 0) {
616 if (tail_pos->
y () <= chop_starty) {
621 *tail_pos = test_pos;
622 tail_index = test_index;
626 if (tail_pos->
x () == chop_coord
627 && srcline->
step (tail_index).
x () < 0
628 && tail_pos->
y () < chop_starty) {
629 chop_starty = tail_pos->
y ();
630 test_index = tail_index;
631 test_pos = *tail_pos;
634 else if (tail_pos->
x () == chop_coord
635 && srcline->
step (tail_index).
y () > 0
636 && prev_step.
x () < 0 && tail_pos->
y () < chop_starty)
639 while (tail_index != startindex
640 && tail_pos->
x () > chop_coord - pitch_error);
669 test_index = tail_index;
671 *tail_pos += srcline->
step (tail_index);
672 prev_step = srcline->
step (tail_index);
674 if (tail_index >= length)
676 if (test_valid && tail_pos->
x () == chop_coord && prev_step.
x () < 0) {
677 if (tail_pos->
y () <= chop_starty) {
682 *tail_pos = test_pos;
683 tail_index = test_index;
687 if (tail_pos->
x () == chop_coord
688 && srcline->
step (tail_index).
x () > 0
689 && tail_pos->
y () < chop_starty) {
690 chop_starty = tail_pos->
y ();
691 test_index = tail_index;
692 test_pos = *tail_pos;
695 else if (tail_pos->
x () == chop_coord
696 && srcline->
step (tail_index).
y () > 0
697 && prev_step.
x () > 0 && tail_pos->
y () < chop_starty)
700 while (tail_index != startindex
701 && tail_pos->
x () < chop_coord + pitch_error);
730 test_index = tail_index;
733 *tail_pos += srcline->
step (tail_index);
734 prev_step = srcline->
step (tail_index);
736 if (tail_index >= length)
738 if (test_valid && tail_pos->
x () == chop_coord && prev_step.
x () > 0) {
739 if (tail_pos->
y () >= chop_starty) {
744 *tail_pos = test_pos;
745 tail_index = test_index;
749 if (tail_pos->
x () == chop_coord
750 && srcline->
step (tail_index).
x () < 0
751 && tail_pos->
y () > chop_starty) {
752 chop_starty = tail_pos->
y ();
753 test_index = tail_index;
754 test_pos = *tail_pos;
757 else if (tail_pos->
x () == chop_coord
758 && srcline->
step (tail_index).
y () < 0
759 && prev_step.
x () < 0 && tail_pos->
y () > chop_starty)
762 while (tail_index != startindex
763 && tail_pos->
x () > chop_coord - pitch_error);
780 C_OUTLINE_FRAG_LIST *frags
790 stepcount = tail_index - head_index;
793 jump = tail_pos.
y () - head_pos.
y ();
796 if (jump == stepcount)
798 tail_y = tail_pos.
y ();
800 head_index, tail_index);
828 if (end_index > start_index) {
829 for (
int i = start_index; i < end_index; ++i)
838 for (; i < end_index + len; ++i)
867 C_OUTLINE_FRAG_LIST *frags
870 C_OUTLINE_FRAG_IT frag_it = frags;
872 if (!frags->empty ()) {
873 for (frag_it.mark_cycle_pt (); !frag_it.cycled_list ();
874 frag_it.forward ()) {
875 if (frag_it.data ()->ycoord > frag->
ycoord
876 || (frag_it.data ()->ycoord == frag->
ycoord
878 frag_it.add_before_then_move (frag);
883 frag_it.add_to_end (frag);
895 C_OUTLINE_FRAG_LIST *frags,
896 C_OUTLINE_LIST *children,
898 C_OUTLINE_IT *dest_it
901 C_OUTLINE_FRAG_IT frag_it = frags;
906 C_OUTLINE_IT child_it = children;
907 C_OUTLINE_IT olchild_it;
909 while (!frag_it.empty ()) {
910 frag_it.move_to_first ();
912 bottom_frag = frag_it.extract ();
914 top_frag = frag_it.data ();
915 if ((bottom_frag->
steps == 0 && top_frag->
steps == 0)
916 || (bottom_frag->
steps != 0 && top_frag->
steps != 0)) {
917 if (frag_it.data_relative (1)->ycoord == top_frag->
ycoord)
920 top_frag = frag_it.extract ();
921 if (top_frag->
other_end != bottom_frag) {
928 olchild_it.set_to_list (outline->
child ());
929 for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
930 child_it.forward ()) {
931 child = child_it.data ();
932 if (*child < *outline)
933 olchild_it.add_to_end (child_it.extract ());
936 dest_it->add_after_then_move (outline);
941 while (!child_it.empty ()) {
942 dest_it->add_after_then_move (child_it.extract ());
962 if (bottom->
steps == 0)
963 outline = top->
close ();
965 outline = bottom->
close ();
970 if (bottom->
steps == 0) {
1003 fake_count = top->
start.
y () - bottom->
end.
y ();
1004 if (fake_count < 0) {
1005 fake_count = -fake_count;
1012 steps =
new DIR128[stepcount];
1017 delete [] bottom->
steps;
1018 bottom->
steps = steps;
1033 inT32 new_stepcount;
1039 if (fake_count < 0) {
1040 fake_count = -fake_count;
1047 new_steps =
new DIR128[new_stepcount];
1051 delete [] new_steps;