Merge pull request #11727 from Snuffleupagus/issue-11713

Add a heuristic to scale even single-char text, when the horizontal/vertical scaling differs significantly (issue 11713)
This commit is contained in:
Tim van der Meij 2020-04-07 23:13:02 +02:00 committed by GitHub
commit 4fe92605b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 0 deletions

View File

@ -113,7 +113,22 @@ var renderTextLayer = (function renderTextLayerClosure() {
// We don't bother scaling single-char text divs, because it has very
// little effect on text highlighting. This makes scrolling on docs with
// lots of such divs a lot faster.
let shouldScaleText = false;
if (geom.str.length > 1) {
shouldScaleText = true;
} else if (geom.transform[0] !== geom.transform[3]) {
const absScaleX = Math.abs(geom.transform[0]),
absScaleY = Math.abs(geom.transform[3]);
// When the horizontal/vertical scaling differs significantly, also scale
// even single-char text to improve highlighting (fixes issue11713.pdf).
if (
absScaleX !== absScaleY &&
Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5
) {
shouldScaleText = true;
}
}
if (shouldScaleText) {
if (style.vertical) {
textDivProperties.canvasWidth = geom.height * task._viewport.scale;
} else {

View File

@ -143,6 +143,7 @@
!issue6621.pdf
!issue6286.pdf
!issue1055r.pdf
!issue11713.pdf
!issue1293r.pdf
!issue1655r.pdf
!issue6541.pdf

BIN
test/pdfs/issue11713.pdf Normal file

Binary file not shown.

View File

@ -1107,6 +1107,12 @@
"link": false,
"type": "text"
},
{ "id": "issue11713",
"file": "pdfs/issue11713.pdf",
"md5": "bafe5801234feeb95969da106f2ce6d8",
"rounds": 1,
"type": "text"
},
{ "id": "bug1250079",
"file": "pdfs/bug1250079.pdf",
"md5": "a1dd21a70ae7097d96273e85a80b26ef",