[TextLayer] Only measure the width of the text, in _layoutText
, for multi-char text divs
For performance reasons single-char text divs aren't being scaled, as outlined in a comment in `appendText`. Hence it doesn't seem necessary, or even a good idea, to unconditionally measuring the width of the text in `_layoutText`.
This commit is contained in:
parent
56ae7a6690
commit
b68f7bb404
@ -541,12 +541,14 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
this._layoutTextLastFontFamily = fontFamily;
|
this._layoutTextLastFontFamily = fontFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
let width = this._layoutTextCtx.measureText(textDiv.textContent).width;
|
|
||||||
|
|
||||||
let transform = '';
|
let transform = '';
|
||||||
if (textDivProperties.canvasWidth !== 0 && width > 0) {
|
if (textDivProperties.canvasWidth !== 0) {
|
||||||
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
// Only measure the width for multi-char text divs, see `appendText`.
|
||||||
transform = `scaleX(${textDivProperties.scale})`;
|
const { width, } = this._layoutTextCtx.measureText(textDiv.textContent);
|
||||||
|
if (width > 0) {
|
||||||
|
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
||||||
|
transform = `scaleX(${textDivProperties.scale})`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (textDivProperties.angle !== 0) {
|
if (textDivProperties.angle !== 0) {
|
||||||
transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
|
transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user