summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson Benítez León <nbenitezl@gmail.com>2024-03-23 12:40:07 +0000
committerAlbert Astals Cid <aacid@kde.org>2024-03-30 10:33:11 +0000
commit7a435135a1bfb8c3f9f5984d88bbe5dd8977335a (patch)
tree2c44c021ec1fd627bffb5efa44daf51ca3148005
parenta10901554010bc5bbc0f24a8d14fdcdecc1b8367 (diff)
Fix regression on issue #157
Redo the fix for issue #157 which is about doing transparent selection for glyphless documents (eg. tesseract scanned documents) because it stopped working after commit 29f32a47
-rw-r--r--poppler/TextOutputDev.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 6fe1def1..6e6f55d6 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -4805,6 +4805,16 @@ bool TextSelectionPainter::hasGlyphLessFont()
void TextSelectionPainter::endPage()
{
+ /* Take a shortcut for glyphless fonts (eg. Tesseract scanned documents)
+ * cause we just paint a transparent fill over existent text.Issue #157 */
+ if (hasGlyphLessFont()) {
+ state->setFillOpacity(glyphlessSelectionOpacity);
+ out->updateFillOpacity(state);
+ out->fill(state);
+ out->endPage();
+ return;
+ }
+
out->fill(state);
out->saveState(state);
@@ -4814,12 +4824,6 @@ void TextSelectionPainter::endPage()
state->setFillColor(glyph_color);
- bool usingGlyphLessFont = hasGlyphLessFont();
- /* Paint transparent selection when using tesseract glyphless font. Issue #157 */
- if (usingGlyphLessFont) {
- state->setFillOpacity(glyphlessSelectionOpacity);
- }
-
out->updateFillColor(state);
for (const TextWordSelection *sel : *selectionList) {
@@ -4844,13 +4848,11 @@ void TextSelectionPainter::endPage()
GooString *string = new GooString((char *)sel->word->charcode, fEnd - begin);
out->beginString(state, string);
- if (!usingGlyphLessFont) {
- for (int j = begin; j < fEnd; j++) {
- if (j != begin && sel->word->charPos[j] == sel->word->charPos[j - 1]) {
- continue;
- }
- out->drawChar(state, sel->word->textMat[j].m[4], sel->word->textMat[j].m[5], 0, 0, 0, 0, sel->word->charcode[j], 1, nullptr, 0);
+ for (int j = begin; j < fEnd; j++) {
+ if (j != begin && sel->word->charPos[j] == sel->word->charPos[j - 1]) {
+ continue;
}
+ out->drawChar(state, sel->word->textMat[j].m[4], sel->word->textMat[j].m[5], 0, 0, 0, 0, sel->word->charcode[j], 1, nullptr, 0);
}
out->endString(state);
delete string;