fontello / svg2ttf

SVG -> TTF font convertor
MIT License
518 stars 79 forks source link

Possibility to change version of font #49

Closed AGavrashenko closed 8 years ago

AGavrashenko commented 8 years ago

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' });

CZEMacLeod commented 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

See https://www.microsoft.com/typography/otspec/name.htm

puzrin commented 8 years ago

PR welcome. Just accept string & validate with regexp (and throw error on bad data).

CZEMacLeod commented 8 years ago

@puzrin Pull request submitted with this functionality

puzrin commented 8 years ago

IMHO it has too complex API for such trivial feature. I'd prefer a simple string, with regex validation

CZEMacLeod commented 8 years ago

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.

puzrin commented 8 years ago

Fixed by https://github.com/fontello/svg2ttf/commit/3602e7c3802a283f8ea6ca0f337f9846ae99c675