Named exports from ol/render/canvas/TextReplay

This commit is contained in:
Frederic Junod
2018-02-21 09:13:33 +01:00
parent f1d32e71cd
commit 16b732472f
+5 -6
View File
@@ -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);