From 8f32a545bd5d71ebb0fe905ec7b87f8922f48868 Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Tue, 11 Dec 2018 16:47:20 -0700 Subject: [PATCH] Centered text should ignore trailing whitespace. --- lib/mixins/text.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mixins/text.js b/lib/mixins/text.js index d6cc17a33..fef3201c0 100644 --- a/lib/mixins/text.js +++ b/lib/mixins/text.js @@ -253,7 +253,8 @@ export default { break; case 'center': - x += (options.lineWidth / 2) - (options.textWidth / 2); + textWidth = this.widthOfString(text.replace(/\s+$/, ''), options); + x += (options.lineWidth / 2) - (textWidth / 2); break; case 'justify':