Better naming with astral/emoji things

pull/3/merge
Amio 2018-07-19 00:50:28 +08:00
rodzic 0a8bb96868
commit 42c4de58cb
4 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -6,9 +6,9 @@ function calcWidth (charWidthTable) {
const widthTable = charWidthTable.map(w => Math.round(w * SCALE))
widthTable[64] = widthTable[64] + 2 // Slightly increase width of "@" by 0.2px
return function (text, containsEmoji) {
return function (text, astral) {
typeAssert(typeof text === 'string', 'Input must be string')
if (containsEmoji) text = text.match(astralRegex)
if (astral) text = text.match(astralRegex)
let total = 0
let code = 0

Wyświetl plik

@ -1,11 +1,11 @@
const calcWidth = require('./calc-text-width.js').Verdana11
const colorPresets = require('./color-presets.js')
module.exports = function ({subject, status, color, style, unicode}) {
module.exports = function ({subject, status, color, style, emoji}) {
color = colorPresets[color] || color || colorPresets['blue']
const stTextWidth = calcWidth(status, unicode)
const sbRectWidth = calcWidth(subject, unicode) + 10
const stTextWidth = calcWidth(status, emoji)
const sbRectWidth = calcWidth(subject, emoji) + 10
const stRectWidth = stTextWidth + 10
const width = sbRectWidth + stRectWidth

Wyświetl plik

@ -30,9 +30,9 @@
|![](/license/Apache-2.0/blue?style=flat) | [/license/Apache-2.0/blue?style=flat](/license/Apache-2.0/blue?style=flat) |
|![](/Language/Swift%203.0.1/orange?style=flat) | [/Language/Swift%203.0.1/orange?style=flat](/Language/Swift%203.0.1/orange?style=flat) |
## Multibytes unicode
## Astral Plain Charset (emoji)
| Badge | URL |
| --- | --- |
|![](/emoji/💩🤱🦄/cyan?style=flat&unicode=1) | [/emoji/💩🤱🦄/cyan?style=flat&unicode=1](/emoji/💩🤱🦄/cyan?style=flat&unicode=1) |
|![](/emoji/💩🤱🦄/cyan?unicode=1) | [/emoji/💩🤱🦄/cyan?unicode=1](/emoji/💩🤱🦄/cyan?unicode=1) |
|![](/emoji/💩🤱🦄/cyan?style=flat&emoji=1) | [/emoji/💩🤱🦄/cyan?style=flat&emoji=1](/emoji/💩🤱🦄/cyan?style=flat&emoji=1) |
|![](/emoji/💩🤱🦄/cyan?emoji=1) | [/emoji/💩🤱🦄/cyan?emoji=1](/emoji/💩🤱🦄/cyan?emoji=1) |

Wyświetl plik

@ -9,13 +9,13 @@ const badgen = require('..')
// http://localhost:3000/npm/v1.2.3
const serveBadge = (req, res) => {
const { pathname, query } = url.parse(req.url)
const { style, unicode } = qs.parse(query)
const { style, emoji } = qs.parse(query)
const [ subject, status, color ] = pathname.split('/')
.filter(Boolean)
.map(s => qs.unescape(s))
res.writeHead(200, { 'Content-Type': 'image/svg+xml;charset=utf-8' })
res.end(badgen({subject, status, color, style, unicode}))
res.end(badgen({subject, status, color, style, emoji}))
}
// @example