Increase 0.2px width for "@" and unicodes

pull/6/head
Amio 2018-07-20 17:31:35 +08:00
rodzic acb7a2fc73
commit 53ca750fb9
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] + 2 // Slightly increase width of "@" by 0.2px
widthTable[64] = widthTable[64] + 4 // Slightly increase width of "@" by 0.4px
return function (text, astral) {
typeAssert(typeof text === 'string', 'Input must be string')

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`] = `
56
57
`
exports[`test/calc-text-width.spec.js TAP calc width for emojis > result is correct 1`] = `
33.6
34.2
`