DragonsInn / fontgen-loader

Automated webfont generation from SVG icons. Use with WebPack!
125 stars 42 forks source link

Generating a font multiple times with the same icons & font config results in different hash and file contents #10

Closed scottmcnab closed 8 years ago

scottmcnab commented 8 years ago

If the fileName in the font config includes the [hash] parameter, then the generated hash (and hence target filename) is different every time webpack is run.

For example, the default fileName setting of "[hash]-[fontname][ext]" has this issue.

This is problematic if generated files are committed to source control, since new files will be generated for every single build, even if none of the source icons or config files have changed!

Note: the contents of the generated font files (the .eot, .ttf and .woff files) are also different for each build, even if the source files have not changed. This is true even if using a fileName configuration without a hash in it, such as "[fontname][ext]".

For the same set of input icons, and exact same font config, then the generated files should be binary identical, and also the [hash] used to generate the target fileName.

IngwiePhoenix commented 8 years ago

That is indeed weird.

I use WebPack’s functions to generate me a hash, but that the files themselves also tend to be "unique" is interesting.

If you look at the project’s package.json, youll see the module that is actually used to generate the fonts. Maybe you should open the issue there, as this loader is merely a proxy to that module.

But, very interesting. I should at least add it to the readme, because I have no idea where this is comming from, except that it might be from the underlying module.

cristinecula commented 8 years ago

I've also bumped into this behavior. I have a hunch that it might be an embedded timestamp (generated at ...).

IngwiePhoenix commented 8 years ago

@chunksnbits @scottmcnab I checked again in my source, but I have no idea where this is coming from. You might want to see if you find something within the underlying tool here? https://github.com/sunflowerdeath/webfonts-generator

cristinecula commented 8 years ago

I think it's caused by the svg2ttf package, which embeds the current date in the generated ttf font:

https://github.com/fontello/svg2ttf/blob/875ed81a4f1cd6414351ed5eec636af595e043ad/lib/sfnt.js#L8 https://github.com/fontello/svg2ttf/blob/49aa894cc169f1f08f76f94512edc6f9169b07fc/lib/ttf/tables/head.js#L26-L27

IngwiePhoenix commented 8 years ago

Nice finding. Should we raise an isse then? a potential fix would be to use a constant string or user controlled value.

Von meinem iPhone gesendet

Am 22.02.2016 um 09:30 schrieb Cristian Necula notifications@github.com:

I think it's caused by the svg2ttf package, which embeds the current date in the generated ttf font:

https://github.com/fontello/svg2ttf/blob/875ed81a4f1cd6414351ed5eec636af595e043ad/lib/sfnt.js#L8 https://github.com/fontello/svg2ttf/blob/49aa894cc169f1f08f76f94512edc6f9169b07fc/lib/ttf/tables/head.js#L26-L27

— Reply to this email directly or view it on GitHub.

cristinecula commented 8 years ago

I would like to test my hypothesis first and eventually submit a pull request, but I have few hours to spare right now. I'll eventually get to it, but it's not a huge priority for me :)

mrbar42 commented 8 years ago

I too verified this coming from the deeper font generators with the exception of svg that has persistent output and therefor persistent hash.

the svg2ttf package supports options.ts the would solve this, but webfonts-generator package is not allowing passing the option down to the generator.

I've created sunflowerdeath/webfonts-generator#6 to allow passing arbitrary options directly to the generators.

I will update here once there is progress with the PR

UPDATE The PR was merged - waiting for it to be published

IngwiePhoenix commented 8 years ago

Oooooooh, fancy! I'll see if I need to adjust anything on my loader end to bridge the gap!

Awesomely done @mrbar42 !

IngwiePhoenix commented 8 years ago

Working on an update. You can simply pass down a formatOptions property and it'll get forwarded.

IngwiePhoenix commented 8 years ago

Use 0.2.1, it has the fix now.

mrbar42 commented 8 years ago

One last note... Unfortunately the webfonts-generator uses older version of the underlying ttf generator so it's not in effect yet. But I made another PR to update the versions and we'll have to wait for it to be published. The new version would be within the version range in package.json so no further changes to this repository are needed.

IngwiePhoenix commented 8 years ago

Yeah I saw that PR. Waiting for it to be merged too!

mrbar42 commented 8 years ago

Merged and published. Latest version is 0.3.3

cristinecula commented 8 years ago

Nice work guys! :+1: