726 {
727 bool changed = false;
728 if (
num_chars() <= 1 || estimated_pitch_ == 0.0f) {
729 return false;
730 }
733 continue;
734 }
735
737 bool intersecting = false;
738 bool not_intersecting = false;
739
741
742
743
744 bool skipped_whitespaces = false;
745 float c1 =
center_x(
i + 1) - 1.5 * estimated_pitch_;
746 while (c1 >
box(
i).right()) {
747 skipped_whitespaces = true;
748 c1 -= estimated_pitch_;
749 }
750 TBOX ibody(c1,
box(
i).bottom(), c1 + estimated_pitch_,
box(
i).top());
751
752
753
756 while (j >= 0 && !
is_final(j) && mostly_overlap(ibody,
box(j)) &&
757 merged.bounding_union(
box(j)).
height() < estimated_pitch_ * (1 + kFPTolerance)) {
759 j--;
760 }
761
762 if (j >= 0 && significant_overlap(ibody,
box(j))) {
763
764
766 intersecting = true;
767 }
768 } else {
769 not_intersecting = true;
771
772
774
775 if (!skipped_whitespaces) {
777 }
778
779
780
781 if (
box(
i).width() <= estimated_pitch_ * 0.5) {
784 }
787 } else {
788 for (
int k =
i; k > j + 1; k--) {
790 }
791 }
792 }
793 }
794 }
796
797
798
799 bool skipped_whitespaces = false;
800 float c1 =
center_x(
i - 1) + 1.5 * estimated_pitch_;
801 while (c1 <
box(
i).left()) {
802 skipped_whitespaces = true;
803 c1 += estimated_pitch_;
804 }
805 TBOX ibody(c1 - estimated_pitch_,
box(
i).bottom(), c1,
box(
i).top());
806
810 merged.bounding_union(
box(j)).
height() < estimated_pitch_ * (1 + kFPTolerance)) {
812 j++;
813 }
814
815 if (j <
num_chars() && significant_overlap(ibody,
box(j))) {
817 intersecting = true;
818 }
819 } else {
820 not_intersecting = true;
823 if (!skipped_whitespaces) {
825 }
826 if (
box(
i).width() <= estimated_pitch_ * 0.5) {
829 }
832 } else {
833 for (
size_t k =
i + 1; k < j; k++) {
835 }
836 }
837 }
838 }
839 }
840
841
842
843 if (intersecting && !not_intersecting) {
845 }
847 changed = true;
848 }
849 }
850
851 return changed;
852}
const Alignment & alignment() const
void set_box(const TBOX &box)