Comparing version 4.0.1 to 4.0.2
@@ -0,1 +1,7 @@ | ||
4.0.2 / 2016-08-04 | ||
------------------ | ||
- Added option to customize version string. | ||
4.0.1 / 2016-06-03 | ||
@@ -2,0 +8,0 @@ ------------------ |
20
index.js
@@ -16,2 +16,6 @@ /* | ||
var VERSION_RE = /^(Version )?(\d+[.]\d+)$/i; | ||
function svg2ttf(svgString, options) { | ||
@@ -28,3 +32,17 @@ var font = new sfnt.Font(); | ||
font.sfntNames.push({ id: 4, value: options.fullname || svgFont.id }); // full name | ||
font.sfntNames.push({ id: 5, value: 'Version 1.0' }); // version ID for TTF name table | ||
var versionString = options.version || 'Version 1.0'; | ||
if (typeof versionString !== 'string') { | ||
throw new Error('svg2ttf: version option should be a string'); | ||
} | ||
if (!VERSION_RE.test(versionString)) { | ||
throw new Error('svg2ttf: invalid option, version - "' + options.version + '"'); | ||
} | ||
versionString = 'Version ' + versionString.match(VERSION_RE)[2]; | ||
font.sfntNames.push({ id: 5, value: versionString }); // version ID for TTF name table | ||
font.sfntNames.push({ id: 6, value: options.fullname || svgFont.id }); // Postscript name for the font, required for OSX Font Book | ||
@@ -31,0 +49,0 @@ |
{ | ||
"name": "svg2ttf", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Converts SVG font to TTF font", | ||
@@ -35,5 +35,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "^2.3.0", | ||
"mocha": "^2.4.5" | ||
"eslint": "~3.2.2", | ||
"mocha": "^3.0.0" | ||
} | ||
} |
@@ -43,2 +43,3 @@ svg2ttf | ||
- `ts` - Unix timestamp (in seconds) to override creation time (optional) | ||
- `version` - font version string, can be `Version x.y` or `x.y`. | ||
- `buf` - internal [byte buffer](https://github.com/fontello/microbuffer) | ||
@@ -45,0 +46,0 @@ object, similar to DataView. It's `buffer` property is `Uin8Array` or `Array` |
@@ -43,2 +43,11 @@ #!/usr/bin/env node | ||
parser.addArgument( | ||
[ '--vs' ], | ||
{ | ||
help: 'Override default font version string (Version 1.0), can be "x.y" or "Version x.y"', | ||
required: false, | ||
type: 'string' | ||
} | ||
); | ||
parser.addArgument( | ||
[ 'infile' ], | ||
@@ -71,10 +80,8 @@ { | ||
if (args.copyright) { | ||
options.copyright = args.copyright; | ||
} | ||
if (args.copyright) options.copyright = args.copyright; | ||
if (args.ts !== null) { | ||
options.ts = args.ts; | ||
} | ||
if (args.ts !== null) options.ts = args.ts; | ||
if (args.vs) options.version = args.vs; | ||
fs.writeFileSync(args.outfile[0], new Buffer(svg2ttf(svg, options).buffer)); |
76661
2083
70