kopia lustrzana https://github.com/badgen/badgen
Font size 12px => 11px
rodzic
bf248d24d7
commit
44d164b423
|
@ -1,7 +1,7 @@
|
|||
// Generate on https://codesandbox.io/s/lr4ynm652m
|
||||
/* eslint-disable comma-spacing */
|
||||
const Arial12Widths = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3.33,3.33,4.26,6.67,6.67,10.7,8,2.29,4,4,4.67,7.01,3.33,4,3.33,3.33,6.67,6.67,6.67,6.67,6.67,6.67,6.67,6.67,6.67,6.67,3.33,3.33,7.01,7.01,7.01,6.67,12.2,8,8,8.67,8.67,8,7.33,9.33,8.67,3.33,6,8,6.67,10,8.67,9.33,8,9.33,8.67,8,7.33,8.67,8,11.3,8,8,7.33,3.33,3.33,3.33,5.63,6.67,4,6.67,6.67,6,6.67,6.67,3.33,6.67,6.67,2.67,2.67,6,2.67,10,6.67,6.67,6.67,6.67,4,6,3.33,6.67,6,8.67,6,6,6,4.01,3.12,4.01,7.01]
|
||||
const Verdana12Widths = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.22,4.72,5.51,9.82,7.63,12.9,8.72,3.22,5.45,5.45,7.63,9.82,4.37,5.45,4.37,5.45,7.63,7.63,7.63,7.63,7.63,7.63,7.63,7.63,7.63,7.63,5.45,5.45,9.82,9.82,9.82,6.54,12,8.2,8.23,8.38,9.25,7.59,6.9,9.3,9.02,5.05,5.46,8.31,6.68,10.1,8.98,9.45,7.24,9.45,8.34,8.2,7.39,8.78,8.2,11.9,8.22,7.38,8.22,5.45,5.45,5.45,9.82,7.63,7.63,7.21,7.48,6.25,7.48,7.15,4.22,7.48,7.59,3.29,4.13,7.1,3.29,11.7,7.59,7.28,7.48,7.48,5.12,6.25,4.73,7.59,7.1,9.82,7.1,7.1,6.3,7.62,5.45,7.62,9.82]
|
||||
const Verdana11Widths = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3.87,4.33,5.05,9,6.99,11.8,7.99,2.95,5,5,6.99,9,4,5,4,5,6.99,6.99,6.99,6.99,6.99,6.99,6.99,6.99,6.99,6.99,5,5,9,9,9,6,11,7.52,7.54,7.68,8.48,6.96,6.32,8.53,8.27,4.63,5,7.62,6.12,9.27,8.23,8.66,6.63,8.66,7.65,7.52,6.78,8.05,7.52,10.9,7.54,6.77,7.54,5,5,5,9,6.99,6.99,6.61,6.85,5.73,6.85,6.55,3.87,6.85,6.96,3.02,3.79,6.51,3.02,10.7,6.96,6.68,6.85,6.85,4.69,5.73,4.33,6.96,6.51,9,6.51,6.51,5.78,6.98,5,6.98,9]
|
||||
|
||||
function calcWidth (charWidthTable) {
|
||||
const SCALE = 100
|
||||
|
@ -24,5 +24,5 @@ function calcWidth (charWidthTable) {
|
|||
|
||||
module.exports = {
|
||||
Arial12: calcWidth(Arial12Widths),
|
||||
Verdana12: calcWidth(Verdana12Widths)
|
||||
Verdana11: calcWidth(Verdana11Widths)
|
||||
}
|
||||
|
|
12
lib/index.js
12
lib/index.js
|
@ -1,4 +1,4 @@
|
|||
const calcWidth = require('./calc-text-width.js').Verdana12
|
||||
const calcWidth = require('./calc-text-width.js').Verdana11
|
||||
const colorPresets = require('./color-presets.js')
|
||||
|
||||
module.exports = function ({subject, status, color}) {
|
||||
|
@ -20,11 +20,11 @@ module.exports = function ({subject, status, color}) {
|
|||
<rect rx="3" x="0" width="${sbRectWidth}" height="20" fill="#555"/>
|
||||
<path fill="#555" d="M${sbRectWidth} 0v20h-4v-20h4z"/>
|
||||
<rect rx="3" width="${width}" height="20" fill="url(#a)"/>
|
||||
<g fill="#fff" text-anchor="start" font-family="DejaVu Sans,Verdana,sans-serif" font-size="12">
|
||||
<text x="6" y="15" fill="#000" opacity="0.2">${subject}</text>
|
||||
<text x="5" y="14">${subject}</text>
|
||||
<text x="${stTextStart + 1}" y="15" fill="#000" opacity="0.2">${status}</text>
|
||||
<text x="${stTextStart}" y="14">${status}</text>
|
||||
<g fill="#fff" text-anchor="start" font-family="DejaVu Sans,Verdana,sans-serif" font-size="11">
|
||||
<text x="6" y="14" fill="#000" opacity="0.2">${subject}</text>
|
||||
<text x="5" y="13">${subject}</text>
|
||||
<text x="${stTextStart + 1}" y="14" fill="#000" opacity="0.2">${status}</text>
|
||||
<text x="${stTextStart}" y="13">${status}</text>
|
||||
</g><script/>
|
||||
</svg>
|
||||
`
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const tap = require('tap')
|
||||
const { Verdana12 } = require('../lib/calc-text-width.js')
|
||||
const calcWidth = require('../lib/calc-text-width.js').Verdana11
|
||||
|
||||
tap.test('calc width for "npm"', t => {
|
||||
t.ok(typeof Verdana12 === 'function', 'export function: Verdana12')
|
||||
t.ok(Number.isFinite(Verdana12('npm')), 'result is a number')
|
||||
t.is(Verdana12('npm'), 26.77, 'result is correct value')
|
||||
t.ok(typeof calcWidth === 'function', 'export function: Verdana12')
|
||||
t.ok(Number.isFinite(calcWidth('npm')), 'result is a number')
|
||||
t.is(calcWidth('npm'), 24.51, 'result is correct value')
|
||||
t.end()
|
||||
})
|
||||
|
|
Ładowanie…
Reference in New Issue