* Given a recognized blob, see if a contiguous collection of sub-pieces * (chopped blobs) starting at its left might qualify as being a subscript * or superscript letter based only on y position. Also do this for the * right side. */
| 44 | * right side. |
| 45 | */ |
| 46 | void YOutlierPieces(WERD_RES *word, int rebuilt_blob_index, |
| 47 | int super_y_bottom, int sub_y_top, |
| 48 | ScriptPos *leading_pos, int *num_leading_outliers, |
| 49 | ScriptPos *trailing_pos, int *num_trailing_outliers) { |
| 50 | ScriptPos sp_unused1, sp_unused2; |
| 51 | int unused1, unused2; |
| 52 | if (!leading_pos) leading_pos = &sp_unused1; |
| 53 | if (!num_leading_outliers) num_leading_outliers = &unused1; |
| 54 | if (!trailing_pos) trailing_pos = &sp_unused2; |
| 55 | if (!num_trailing_outliers) num_trailing_outliers = &unused2; |
| 56 | |
| 57 | *num_leading_outliers = *num_trailing_outliers = 0; |
| 58 | *leading_pos = *trailing_pos = SP_NORMAL; |
| 59 | |
| 60 | int chopped_start = LeadingUnicharsToChopped(word, rebuilt_blob_index); |
| 61 | int num_chopped_pieces = word->best_state[rebuilt_blob_index]; |
| 62 | ScriptPos last_pos = SP_NORMAL; |
| 63 | int trailing_outliers = 0; |
| 64 | for (int i = 0; i < num_chopped_pieces; i++) { |
| 65 | TBOX box = word->chopped_word->blobs[chopped_start + i]->bounding_box(); |
| 66 | ScriptPos pos = SP_NORMAL; |
| 67 | if (box.bottom() >= super_y_bottom) { |
| 68 | pos = SP_SUPERSCRIPT; |
| 69 | } else if (box.top() <= sub_y_top) { |
| 70 | pos = SP_SUBSCRIPT; |
| 71 | } |
| 72 | if (pos == SP_NORMAL) { |
| 73 | if (trailing_outliers == i) { |
| 74 | *num_leading_outliers = trailing_outliers; |
| 75 | *leading_pos = last_pos; |
| 76 | } |
| 77 | trailing_outliers = 0; |
| 78 | } else { |
| 79 | if (pos == last_pos) { |
| 80 | trailing_outliers++; |
| 81 | } else { |
| 82 | trailing_outliers = 1; |
| 83 | } |
| 84 | } |
| 85 | last_pos = pos; |
| 86 | } |
| 87 | *num_trailing_outliers = trailing_outliers; |
| 88 | *trailing_pos = last_pos; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Attempt to split off any high (or low) bits at the ends of the word with poor |
no test coverage detected