Merge pull request #11097 from Snuffleupagus/textLayer-measure-width
[TextLayer] Only measure the width of the text, in `_layoutText`, for multi-char text divs
This commit is contained in:
commit
184d416639
@ -541,13 +541,15 @@ 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) {
|
||||||
|
// Only measure the width for multi-char text divs, see `appendText`.
|
||||||
|
const { width, } = this._layoutTextCtx.measureText(textDiv.textContent);
|
||||||
|
if (width > 0) {
|
||||||
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
||||||
transform = `scaleX(${textDivProperties.scale})`;
|
transform = `scaleX(${textDivProperties.scale})`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (textDivProperties.angle !== 0) {
|
if (textDivProperties.angle !== 0) {
|
||||||
transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
|
transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
|
||||||
}
|
}
|
||||||
@ -634,11 +636,8 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
transformBuf.length = 0;
|
transformBuf.length = 0;
|
||||||
paddingBuf.length = 0;
|
paddingBuf.length = 0;
|
||||||
|
|
||||||
if (divProps.angle !== 0) {
|
if (divProps.originalTransform) {
|
||||||
transformBuf.push(`rotate(${divProps.angle}deg)`);
|
transformBuf.push(divProps.originalTransform);
|
||||||
}
|
|
||||||
if (divProps.scale !== 1) {
|
|
||||||
transformBuf.push(`scaleX(${divProps.scale})`);
|
|
||||||
}
|
}
|
||||||
if (divProps.paddingTop > 0) {
|
if (divProps.paddingTop > 0) {
|
||||||
paddingBuf.push(`${divProps.paddingTop}px`);
|
paddingBuf.push(`${divProps.paddingTop}px`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user