Named exports from ol/render/canvas/TextReplay
This commit is contained in:
@@ -143,17 +143,16 @@ inherits(CanvasTextReplay, CanvasReplay);
|
|||||||
* each line.
|
* each line.
|
||||||
* @return {number} Width of the whole text.
|
* @return {number} Width of the whole text.
|
||||||
*/
|
*/
|
||||||
CanvasTextReplay.measureTextWidths = function(font, lines, widths) {
|
export function measureTextWidths(font, lines, widths) {
|
||||||
const numLines = lines.length;
|
const numLines = lines.length;
|
||||||
let width = 0;
|
let width = 0;
|
||||||
let currentWidth, i;
|
for (let i = 0; i < numLines; ++i) {
|
||||||
for (i = 0; i < numLines; ++i) {
|
const currentWidth = measureTextWidth(font, lines[i]);
|
||||||
currentWidth = measureTextWidth(font, lines[i]);
|
|
||||||
width = Math.max(width, currentWidth);
|
width = Math.max(width, currentWidth);
|
||||||
widths.push(currentWidth);
|
widths.push(currentWidth);
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -296,7 +295,7 @@ CanvasTextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey
|
|||||||
const lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
const numLines = lines.length;
|
const numLines = lines.length;
|
||||||
const widths = [];
|
const widths = [];
|
||||||
const width = CanvasTextReplay.measureTextWidths(textState.font, lines, widths);
|
const width = measureTextWidths(textState.font, lines, widths);
|
||||||
const lineHeight = measureTextHeight(textState.font);
|
const lineHeight = measureTextHeight(textState.font);
|
||||||
const height = lineHeight * numLines;
|
const height = lineHeight * numLines;
|
||||||
const renderWidth = (width + strokeWidth);
|
const renderWidth = (width + strokeWidth);
|
||||||
|
|||||||
Reference in New Issue
Block a user