Closed AGavrashenko closed 8 years ago
Since ttf font version strings have a fairly restrictive format, I would go for
options.version = options.version || {
major: 1,
minor: 0,
suffix: null
};
var verString = 'Version ' + (options.version.major || 1) + '.' + (options.version.minor || 0) + font.version.suffix !== null ? '; ' + font.version.suffix : '';
font.sfntNames.push({ id: 5, value: verString }); // version ID for TTF name table
PR welcome. Just accept string & validate with regexp (and throw error on bad data).
@puzrin Pull request submitted with this functionality
IMHO it has too complex API for such trivial feature. I'd prefer a simple string, with regex validation
It does support a simple string with regex. -version "Version 2.1" works fine. In the code I'm using I tend to have separate variables for major, minor, and revision/build info. Hence why I made it able to take either.
When we generate .ttf file we haven't possibility to change version because it fixed value in code:
font.sfntNames.push({ id: 5, value: 'Version 1.0' });
It would be great to have something like this:
font.sfntNames.push({ id: 5, value: options.version || 'v1.0' });