113 {
114 size_t prev_i = SIZE_MAX;
115 int max_shift = 0;
116 for (size_t i = 0; i < boxes->size(); ++i) {
117 Box *
box = (*boxes)[i]->box_;
118 if (
box ==
nullptr) {
119 if (prev_i == SIZE_MAX || prev_i + 1 < i || i + 1 == boxes->size()) {
120
121 do {
122 delete (*boxes)[i];
123 boxes->erase(boxes->begin() + i);
124 if (i == 0) {
125 break;
126 }
127 } while (i-- == boxes->size() && (*boxes)[i]->box_ == nullptr);
128 }
129 continue;
130 }
131 if (prev_i != SIZE_MAX) {
132 Box *prev_box = (*boxes)[prev_i]->box_;
133 int shift =
box->x - prev_box->x;
134 if (vertical_rules) {
135 shift =
box->y - prev_box->y;
136 } else if (rtl_rules) {
137 shift = -shift;
138 }
139 if (-shift > max_shift) {
140
141
142
143 int width = 1;
144 int height = 1;
145 int x = prev_box->x + prev_box->w;
146 int y = prev_box->y;
147 if (vertical_rules) {
148 x = prev_box->x;
149 y = prev_box->y + prev_box->h;
150 } else if (rtl_rules) {
151 x = prev_box->x - width;
152 if (x < 0) {
153 tprintf(
"prev x = %d, width=%d\n", prev_box->x, width);
154 x = 0;
155 }
156 }
157 if (prev_i + 1 == i) {
158
159 auto *new_box =
new BoxChar(
"\t", 1);
160 new_box->AddBox(x, y, width, height);
161 new_box->page_ = (*boxes)[i]->page_;
162 boxes->insert(boxes->begin() + i, new_box);
163 ++i;
164 } else {
165 (*boxes)[i - 1]->AddBox(x, y, width, height);
166 (*boxes)[i - 1]->ch_ = "\t";
167 }
168 max_shift = 0;
169 } else if (shift > max_shift) {
170 max_shift = shift;
171 }
172 }
173 prev_i = i;
174 }
175}
BoxChar(const char *utf8_str, int len)