MCPcopy Create free account
hub / github.com/KDE/okular / correctTextOrder

Method correctTextOrder

core/textpage.cpp:1624–1657  ·  view source on GitHub ↗

* Correct the textOrder, all layout recognition works here */

Source from the content-addressed store, hash-verified

1622 * Correct the textOrder, all layout recognition works here
1623 */
1624void 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
1659TextEntity::List TextPage::words(const RegularAreaRect *area, TextAreaInclusionBehaviour b) const
1660{

Callers 1

setTextPageMethod · 0.80

Calls 6

removeSpaceFunction · 0.85
makeWordFromCharactersFunction · 0.85
XYCutForBoundingBoxesFunction · 0.85
addNecessarySpaceFunction · 0.85
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected