googlefonts / nanoemoji

A wee tool to build color fonts.
Apache License 2.0
239 stars 19 forks source link

Add support for quantizing PNGs with pngquant #394

Closed anthrotype closed 2 years ago

anthrotype commented 2 years ago

The pngquant command is now available as 'pngquant-cli' on PyPI so we can install it with pip like the rest of the dependencies: https://pypi.org/project/pngquant-cli

I still had to wrap the pngquant command with a script that handles two special error codes 98 (output larger than input) and 99 (conversion quality below minimum) by copying the input file to the output file. The noto-emoji Makefile has a similar rule. If we don't add that, then a bunch of noto-emojis would fail to quantize (e.g. the standalone skin tone modifiers e.g. 🏽), as ninja sees the non-zero exit code and stops early.

I tried running this on my local machine and I now get a CBDT noto-emoji font which is around 10MB large (only 220KB larger than the original, not sure exactly where the extra bytes come from but I think it's a good start).

I'm going to add some tests that check that everything runs as expected

rsheeter commented 2 years ago

Give or take 200KB sounds good enough to me