From ddf8f9133b4ad1ecbd65f0bfc4c697094d7bd579 Mon Sep 17 00:00:00 2001 From: mmghv Date: Fri, 10 Apr 2020 15:33:48 +0200 Subject: [PATCH] Fix cell align with padding --- src/tableDrawer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tableDrawer.ts b/src/tableDrawer.ts index d59c0c70..b70f0451 100644 --- a/src/tableDrawer.ts +++ b/src/tableDrawer.ts @@ -219,13 +219,15 @@ function printRow(row) { } else if (cell.styles.valign === 'bottom') { cell.textPos.y = table.cursor.y + cell.height - cell.padding('bottom') } else { - cell.textPos.y = table.cursor.y + cell.height / 2 + const netHeight = cell.height - cell.padding('vertical') + cell.textPos.y = table.cursor.y + netHeight / 2 + cell.padding('top') } if (cell.styles.halign === 'right') { cell.textPos.x = cell.x + cell.width - cell.padding('right') } else if (cell.styles.halign === 'center') { - cell.textPos.x = cell.x + cell.width / 2 + const netWidth = cell.width - cell.padding('horizontal') + cell.textPos.x = cell.x + netWidth / 2 + cell.padding('left') } else { cell.textPos.x = cell.x + cell.padding('left') }