Skip to content

Commit caff12e

Browse files
committed
ALTO renderer: indent SP, add Variant
1 parent 6cd6b3e commit caff12e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/api/altorenderer.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,18 @@ char* TessBaseAPI::GetAltoText(ETEXT_DESC* monitor, int page_number) {
209209
if (grapheme && grapheme[0] != 0) {
210210
alto_str << HOcrEscape(grapheme.get()).c_str();
211211
}
212-
alto_str << "\"/>";
212+
alto_str << "\">";
213+
ChoiceIterator choice_it(*res_it);
214+
do {
215+
int vc = choice_it.Confidence();
216+
alto_str << "\n\t\t\t\t\t\t\t\t\t<Variant VC=\"0." << vc << "\"";
217+
alto_str << " CONTENT=\"";
218+
const char* variant = choice_it.GetUTF8Text();
219+
if (variant && variant[0] != 0)
220+
alto_str << HOcrEscape(variant).c_str();
221+
alto_str << "\"/>";
222+
} while (choice_it.Next());
223+
alto_str << "\n\t\t\t\t\t\t\t\t</Glyph>";
213224
res_it->Next(RIL_SYMBOL);
214225

215226
scnt++;
@@ -227,8 +238,12 @@ char* TessBaseAPI::GetAltoText(ETEXT_DESC* monitor, int page_number) {
227238
int vpos = top;
228239
res_it->BoundingBox(RIL_WORD, &left, &top, &right, &bottom);
229240
int width = left - hpos;
230-
alto_str << "<SP WIDTH=\"" << width << "\" VPOS=\"" << vpos
231-
<< "\" HPOS=\"" << hpos << "\"/>\n";
241+
int height = bottom - top;
242+
alto_str << "\n\t\t\t\t\t\t\t<SP";
243+
alto_str << " HPOS=\"" << hpos << "\"";
244+
alto_str << " VPOS=\"" << vpos << "\"";
245+
alto_str << " WIDTH=\"" << width << "\"";
246+
alto_str << " HEIGHT=\"" << height << "\"/>\n";
232247
}
233248

234249
if (last_word_in_tblock) {

0 commit comments

Comments
 (0)