static */
| 613 | |
| 614 | /* static */ |
| 615 | ScriptPos WERD_CHOICE::ScriptPositionOf(bool print_debug, |
| 616 | const UNICHARSET& unicharset, |
| 617 | const TBOX& blob_box, |
| 618 | UNICHAR_ID unichar_id) { |
| 619 | ScriptPos retval = tesseract::SP_NORMAL; |
| 620 | int top = blob_box.top(); |
| 621 | int bottom = blob_box.bottom(); |
| 622 | int min_bottom, max_bottom, min_top, max_top; |
| 623 | unicharset.get_top_bottom(unichar_id, |
| 624 | &min_bottom, &max_bottom, |
| 625 | &min_top, &max_top); |
| 626 | |
| 627 | int sub_thresh_top = min_top - kMinSubscriptOffset; |
| 628 | int sub_thresh_bot = kBlnBaselineOffset - kMinSubscriptOffset; |
| 629 | int sup_thresh_bot = max_bottom + kMinSuperscriptOffset; |
| 630 | if (bottom <= kMaxDropCapBottom) { |
| 631 | retval = tesseract::SP_DROPCAP; |
| 632 | } else if (top < sub_thresh_top && bottom < sub_thresh_bot) { |
| 633 | retval = tesseract::SP_SUBSCRIPT; |
| 634 | } else if (bottom > sup_thresh_bot) { |
| 635 | retval = tesseract::SP_SUPERSCRIPT; |
| 636 | } |
| 637 | |
| 638 | if (print_debug) { |
| 639 | const char *pos = ScriptPosToString(retval); |
| 640 | tprintf("%s Character %s[bot:%d top: %d] " |
| 641 | "bot_range[%d,%d] top_range[%d, %d] " |
| 642 | "sub_thresh[bot:%d top:%d] sup_thresh_bot %d\n", |
| 643 | pos, unicharset.id_to_unichar(unichar_id), |
| 644 | bottom, top, |
| 645 | min_bottom, max_bottom, min_top, max_top, |
| 646 | sub_thresh_bot, sub_thresh_top, |
| 647 | sup_thresh_bot); |
| 648 | } |
| 649 | return retval; |
| 650 | } |
| 651 | |
| 652 | // Returns the script-id (eg Han) of the dominant script in the word. |
| 653 | int WERD_CHOICE::GetTopScriptID() const { |
nothing calls this directly
no test coverage detected