Merge pull request #5221 from nnethercote/dont-scale-single-char-text-divs
Don't scale single-char text divs.
This commit is contained in:
commit
b3be74d81c
@ -83,14 +83,21 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
var width = ctx.measureText(textDiv.textContent).width;
|
var width = ctx.measureText(textDiv.textContent).width;
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
textLayerFrag.appendChild(textDiv);
|
textLayerFrag.appendChild(textDiv);
|
||||||
// Dataset values come of type string.
|
var transform;
|
||||||
var textScale = textDiv.dataset.canvasWidth / width;
|
if (textDiv.dataset.canvasWidth !== undefined) {
|
||||||
|
// Dataset values come of type string.
|
||||||
|
var textScale = textDiv.dataset.canvasWidth / width;
|
||||||
|
transform = 'scaleX(' + textScale + ')';
|
||||||
|
} else {
|
||||||
|
transform = '';
|
||||||
|
}
|
||||||
var rotation = textDiv.dataset.angle;
|
var rotation = textDiv.dataset.angle;
|
||||||
var transform = 'scale(' + textScale + ', 1)';
|
|
||||||
if (rotation) {
|
if (rotation) {
|
||||||
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
transform = 'rotate(' + rotation + 'deg) ' + transform;
|
||||||
}
|
}
|
||||||
CustomStyle.setProp('transform' , textDiv, transform);
|
if (transform) {
|
||||||
|
CustomStyle.setProp('transform' , textDiv, transform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,10 +172,15 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
if (angle !== 0) {
|
if (angle !== 0) {
|
||||||
textDiv.dataset.angle = angle * (180 / Math.PI);
|
textDiv.dataset.angle = angle * (180 / Math.PI);
|
||||||
}
|
}
|
||||||
if (style.vertical) {
|
// We don't bother scaling single-char text divs, because it has very
|
||||||
textDiv.dataset.canvasWidth = geom.height * this.viewport.scale;
|
// little effect on text highlighting. This makes scrolling on docs with
|
||||||
} else {
|
// lots of such divs a lot faster.
|
||||||
textDiv.dataset.canvasWidth = geom.width * this.viewport.scale;
|
if (textDiv.textContent.length > 1) {
|
||||||
|
if (style.vertical) {
|
||||||
|
textDiv.dataset.canvasWidth = geom.height * this.viewport.scale;
|
||||||
|
} else {
|
||||||
|
textDiv.dataset.canvasWidth = geom.width * this.viewport.scale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user