diff --git a/src/layout/index.js b/src/layout/index.js index 7b9ca3c..38ec5c0 100644 --- a/src/layout/index.js +++ b/src/layout/index.js @@ -79,7 +79,7 @@ module.exports = function layoutFormattedText(text, options) { if (options.trimVerticalWhitespace) { startHeightCorrection = -(adjustedLineHeights[0] / 2) - (lines[0].minAscender / 2); - endHeightCorrection = -(last(adjustedLineHeights) / 2) - (last(lines).minAscender / 2) + (last(lines).maxDescender); + endHeightCorrection = -(last(adjustedLineHeights) / 2) - (last(lines).minAscender / 2); } else { startHeightCorrection = 0; endHeightCorrection = 0; @@ -117,7 +117,7 @@ module.exports = function layoutFormattedText(text, options) { return { width: Math.ceil(max(lines.map(line => line.width))), - height: Math.ceil(sum(adjustedLineHeights) + startHeightCorrection + endHeightCorrection), + height: Math.ceil(sum(adjustedLineHeights) + startHeightCorrection + endHeightCorrection + (last(lines).maxDescender)), items: positionedItems, drawDebugLines: function drawDebugLines(context) { debugLines.forEach((debugLine) => { @@ -154,7 +154,7 @@ module.exports = function layoutFormattedText(text, options) { if (options.trimVerticalWhitespace) { startHeightCorrection = -(adjustedLineHeights[0] / 2) - (lines[0].measurements.ascender / 2); - endHeightCorrection = -(last(adjustedLineHeights) / 2) - (last(lines).measurements.ascender / 2) + (last(lines).measurements.descender); + endHeightCorrection = -(last(adjustedLineHeights) / 2) - (last(lines).measurements.ascender / 2); } else { startHeightCorrection = 0; endHeightCorrection = 0; @@ -186,7 +186,7 @@ module.exports = function layoutFormattedText(text, options) { return { width: Math.ceil(max(lines.map(line => line.measurements.width))), - height: Math.ceil(sum(adjustedLineHeights) + startHeightCorrection + endHeightCorrection), + height: Math.ceil(sum(adjustedLineHeights) + startHeightCorrection + endHeightCorrection + (last(lines).measurements.descender)), items: positionedItems, drawDebugLines: function drawDebugLines(context) { debugLines.forEach((debugLine) => {