Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Woff2 file has different checksum each time it is saved. #3385

Closed
inklinea opened this issue Dec 10, 2023 · 4 comments
Closed

Woff2 file has different checksum each time it is saved. #3385

inklinea opened this issue Dec 10, 2023 · 4 comments

Comments

@inklinea
Copy link

I'm using fonttools 4.29.1 with python 3.10.12.
Ubuntu 22
``
For this simple code:

font_object = TTFont(ttf_filepath)
font_object.flavor = 'woff2'
font_file_disk = f'/filepath/{font_name}.woff2'
font_object.save(font_file_disc)

The checksum of the woff2 file changes every time the same font is saved.
I not sure why this is ?

At a guess I think it might be due to the way Brotli compresses to woff2, and the compression although valid is not the exactly the same each time ?

I'm converting the woff2 font into a base64 @font-face for use on the web.

If I can have the same base64 string each time, it gives a simple way to check if the document already contains this font (even if the name is different)

Many thanks for any advice.

@Lorp
Copy link

Lorp commented Dec 10, 2023

More likely to be the timestamps in the head table.

@Lorp
Copy link

Lorp commented Dec 10, 2023

If you use the command line tool woff2_compress, the resulting WOFF2 file will be identical each time.

@inklinea
Copy link
Author

inklinea commented Dec 10, 2023

Fantastic, thanks for your quick response.

All I needed was

font_object.recalcTimestamp = False

and the problem is solved :)

@Lorp
Copy link

Lorp commented Dec 10, 2023

Great!

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

No branches or pull requests

3 participants