From b72e29d7937855792ebbfdfd473294d99aeb0e82 Mon Sep 17 00:00:00 2001 From: Thaddee Tyl Date: Sun, 13 Mar 2016 23:55:06 +0100 Subject: [PATCH] Increase chances of pixel grid alignment --- badge.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/badge.js b/badge.js index 37206e778f7b2..e6049c1faefb1 100644 --- a/badge.js +++ b/badge.js @@ -63,10 +63,15 @@ function makeImage(data, cb) { if (data.text[0].length === 0) { data.logoPadding = 0; } + + var textWidth1 = (measureTextWidth(data.text[0])|0); + var textWidth2 = (measureTextWidth(data.text[1])|0); + // Increase chances of pixel grid alignment. + if (textWidth1 % 2 === 0) { textWidth1++; } + if (textWidth2 % 2 === 0) { textWidth2++; } data.widths = [ - (measureTextWidth(data.text[0])|0) + 10 - + data.logoWidth + data.logoPadding, - (measureTextWidth(data.text[1])|0) + 10, + textWidth1 + 10 + data.logoWidth + data.logoPadding, + textWidth2 + 10, ]; if (data.links === undefined) { data.links = ['', ''];