mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Add a heuristic to scale even single-char text, when the horizontal/vertical scaling differs significantly (issue 11713)
At this point in time, compared to when the "ignore single-char" code was added, we *should* generally be doing a much better job of combining text into as few chunks as possible. However, there's still bad cases where we're not able to combine text as much as one would like, which is why I'm *not* proposing to simply measure/scale all text. Instead this patch will to only measure/scale single-char text in cases where the horizontal/vertical scale is off significantly, since that's were you'd expect bad text-selection behaviour otherwise. Note that most of the movement caused by this patch is with Type3 fonts, which is a somewhat special font type and one where our current text-selection behaviour is probably the least good.
This commit is contained in:
parent
70c54ab9d9
commit
91efde5246
4 changed files with 22 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue