TL;DR: font-squirrel is not lossless!
and as RoelN says:
Simply doing WOFF compression should yield very similar file sizes, regardless of tool used.
If you already know how to parse TTF files, then converting them to WOFF is not too difficult.
It mainly compresses the tables from the original ttf. If compression is needed for a table, zlib
is used for compression.
Below is the structure of woff.
type Woff struct {
Header struct {
Signature [4]byte
Flavor [4]byte
Length uint32
NumTables uint16
Reserved uint16
TotalSFNTSize uint32
MajorVersion uint16
MinorVersion uint16
MetaOffset uint32
MetaLength uint32
MetaOrigLength uint32
PrivateOffset uint32
PrivateLength uint32
}
TableDirectoryEntry []struct{
Tag [4]byte
Offset uint32
CompLength uint32
OrigLength uint32
OrigChecksum uint32
}
TableRawData []byte
MetaData []byte
PrivateData []byte
}
For details, please refer to the documentation
https://www.w3.org/TR/WOFF/
Therefore, the content is limited.
small differences, such as whether cmap.format4 should use idDelta or rangeOffset... (of course, there are many other reasons),
so the results from different parsing tools may differ, but not significantly. (that is why WOFF compression should yield very similar file sizes, regardless of tool used.
)
The main difference is that WOFF includes privateData
and metaData
.
If there is a lot of data in these areas of the woff file, the resulting data will be relatively large.
So, you can check if these two optional areas have data. If there is no data in both areas but the resulting files are significantly different, then it cannot be lossless.
I indeed tested the results from font-squirrel with test data and compared them with the results I parsed myself.
The glyf
table of the font occupies a large space because the point information of each outline is recorded here.
So, you can start from here.
However, glyf corresponds to loca.
Therefore, you can check if the number of loca is correct.
You will find that it writes much fewer loca,
so the content of glyf can also be written much less, resulting in a much smaller file size.