Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

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

Closed
scottmcnab opened this issue Dec 20, 2015 · 14 comments

Comments

@scottmcnab
Copy link

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
Copy link
Member

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
Copy link

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

@IngwiePhoenix
Copy link
Member

@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
Copy link

@IngwiePhoenix
Copy link
Member

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 [email protected]:

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
Copy link

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
Copy link
Contributor

mrbar42 commented Mar 24, 2016

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
Copy link
Member

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

Awesomely done @mrbar42 !

@IngwiePhoenix
Copy link
Member

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

@IngwiePhoenix
Copy link
Member

Use 0.2.1, it has the fix now.

@mrbar42
Copy link
Contributor

mrbar42 commented Mar 26, 2016

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
Copy link
Member

IngwiePhoenix commented Mar 26, 2016 via email

@mrbar42
Copy link
Contributor

mrbar42 commented Mar 27, 2016

Merged and published.
Latest version is 0.3.3

@cristinecula
Copy link

Nice work guys! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants