WOFF2 is a font file format that is a more compressed version of the Web Open Font Format (WOFF). It was developed as a way to reduce the file size of web fonts, allowing them to load faster and use less bandwidth. WOFF2 uses a compression algorithm called Brotli to compress the font data, which can result in file sizes that are significantly smaller than equivalent WOFF fonts. This format is supported by most modern web browsers including Chrome, Firefox, Safari, Opera and Edge (version 14 onwards).
WOFF2 File Format - More Information
The internal file structure of a WOFF2 font file is composed of several different parts, including a header, metadata, a table directory, and the font data itself.
The header contains information about the overall format of the file, including the version number and the number of tables that are present in the file.
Metadata section contains information such as font name, copyright, and other font-related information.
The table directory contains information about the different tables that make up the font, including their location in the file and their length.
The font data itself is divided into several different tables, each of which contains specific information about the font, such as its characters and their corresponding glyphs. These tables may include:
The ‘glyf’ table contains the actual font outlines, including the shape and size of each character.
The ‘head’ table contains general information about the font, such as its version number, design size, and so on.
The ‘hmtx’ table contains information about the metrics of the font, including the widths and positions of the characters.
Each table is compressed and stored in WOFF2 file format after it completed the process of encoding.
The structure overall is designed to allow for fast parsing and decoding, so that web browsers can quickly and efficiently load and display the font on a website.
The WOFF header comprises of an identifying signature which indicates the the kind of data included in the file. The WOFF header along with its fields is as follow.
The “sfnt version” of the input font.
Total size of the WOFF file.
Number of entries in directory of font tables.
Reserved; set to zero.
Total size needed for the uncompressed font data, including the sfnt header, directory, and font tables (including padding).
totalCompressedSize Total length of the compressed data block.
Major version of the WOFF file.
Minor version of the WOFF file.
Offset to metadata block, from beginning of WOFF file.
Length of compressed metadata block.
Uncompressed size of metadata block.
Offset to private data block, from beginning of WOFF file.