chore: slightly increase width for unicode & "@"

pull/6/head
Amio 2018-07-25 15:58:22 +08:00
rodzic 72f879e605
commit 081fdf9eae
2 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -4,7 +4,7 @@ const astralRegex = require('unicode-astral-regex')
function calcWidth (charWidthTable) {
const SCALE = 10 // Prevent results like 60.599999999999994
const widthTable = charWidthTable.map(w => Math.round(w * SCALE))
widthTable[64] = widthTable[64] + 4 // Slightly increase width of "@" by 0.4px
widthTable[64] = widthTable[64] + 6 // Slightly increase width of "@" by 0.6px
return function (text, astral) {
if (astral) text = text.match(astralRegex)

Wyświetl plik

@ -10,9 +10,9 @@ exports[`test/calc-text-width.spec.js TAP calc width for "npm" > result is corre
`
exports[`test/calc-text-width.spec.js TAP calc width for unicode > result is correct 1`] = `
57
58
`
exports[`test/calc-text-width.spec.js TAP calc width for emojis > result is correct 1`] = `
34.2
34.8
`