* Correct the textOrder, all layout recognition works here */
| 1622 | * Correct the textOrder, all layout recognition works here |
| 1623 | */ |
| 1624 | void TextPagePrivate::correctTextOrder() |
| 1625 | { |
| 1626 | // m_page->width() and m_page->height() are in pixels at |
| 1627 | // 100% zoom level, and thus depend on display DPI. |
| 1628 | // To avoid Okular failing on lowDPI displays, |
| 1629 | // we scale pageWidth and pageHeight so their sum equals 2000. |
| 1630 | const double scalingFactor = 2000.0 / (m_page->width() + m_page->height()); |
| 1631 | const int pageWidth = (int)(scalingFactor * m_page->width()); |
| 1632 | const int pageHeight = (int)(scalingFactor * m_page->height()); |
| 1633 | |
| 1634 | TextEntity::List characters = m_words; |
| 1635 | |
| 1636 | /** |
| 1637 | * Remove spaces from the text |
| 1638 | */ |
| 1639 | removeSpace(characters); |
| 1640 | |
| 1641 | /** |
| 1642 | * Construct words from characters |
| 1643 | */ |
| 1644 | const QList<WordWithCharacters> wordsWithCharacters = makeWordFromCharacters(characters, pageWidth, pageHeight); |
| 1645 | |
| 1646 | /** |
| 1647 | * Make a XY Cut tree for segmentation of the texts |
| 1648 | */ |
| 1649 | RegionTextList tree = XYCutForBoundingBoxes(wordsWithCharacters, pageWidth, pageHeight); |
| 1650 | |
| 1651 | /** |
| 1652 | * Add spaces to the word |
| 1653 | */ |
| 1654 | const auto listOfCharacters = addNecessarySpace(std::move(tree), pageWidth, pageHeight); |
| 1655 | |
| 1656 | setWordList(listOfCharacters); |
| 1657 | } |
| 1658 | |
| 1659 | TextEntity::List TextPage::words(const RegularAreaRect *area, TextAreaInclusionBehaviour b) const |
| 1660 | { |
no test coverage detected