TestPlan20-Format

From Fonts WG

Plan for testing all the assertions which apply to the WOFF file format itself. The majority of these will be tested by a validation tool.

Text color highlights on this page are as follows: red text indicates questions that need to be addressed by the Working Group, gray text indicates portions of the test suite that are not yet implemented

Testable Assertions

noextraneous

There are four potential locations for extraneous data: between header and table directory, between table data and metadata, between metadata and private data, and after private data. Verify that extraneous data is rejected in all four locations.

A validator needs to parse and decompress the WOFF2 to determine the correct locations of the data blocks and that no extraneous data is there (besides required padding). (For data after private, there is a separate assertion).

magicNumber

Create a font with invalid header signature field (e.g. "XXXX" or "wOFF" instead of "wOF2"). The validator must reject it.

mustSetReservedToZero

Ensure the reserved field in the header is set to zero.

noExtraData

Create a WOFF 2.0 file with the compressed data stream that contains a gap (binary data insert) between tables referenced in the table directory. The validator decompresses the data stream, checks for continuity of table data defined by their corresponding offsets/lengths definitions and must reject the file that has extra data inserted.

mustUseBrotli-FontData

Create a font for which the font data was compressed with GZIP. The validator must reject it.

mustMatchUncompressedSize

The validator checks that sum of the origLength (for non-transformed tables) and transformLength (for transformed tables) fields in the table directory is equal the size of the uncompressed table data block.

mustHaveCompositeBBox

The validator parses the font and, if composite glyphs are present, checks they have explicit bounding boxes.

Test data is one font with only simple glyphs and the other with composite glyphs (e.g. composite of P, A, and S).

transformedLocaMustBeZero

The validator parses the font and, if 'glyf' and 'loca' tables are present, checks that the value of transform length for 'loca' is zero.

OriginalLocaSize

The validator parses the font and checks that, if loca is present, original length of loca is numGlyphs+1 times the size per glyph (as defined by the index format of the transform glyph header).

Test with two fonts, one with loca and one without (such as a CFF font). Validator must pass both.

transformFlagsMustBeSet

This case will be covered with two test inputs:

  1. Create an input woff2 font file with transformed 'hmtx' table indicating a valid transform number "1" applied where the transform Flags field indicates a valid transform (bits 0 or 1 must be set as applicable) - validator must check that the corresponding lsb[] and/or leftSideBearing[] arrays are removed and must accept the file if the conditions are met.
  2. Create an input woff2 font file with transformed 'hmtx' table indicating a valid transform number "1" applied where the transform Flags field is set to zero (indicating a null transform) - validator must reject the file as invalid.

mustIncludeTransformLength

Create input woff2 file with transformed tables but without transformLength in the table directory - validator must reject the file as invalid.

transformedLocaMustAccompanyGlyf

Create two input woff2 fonts one with transformed glyf and untransformed loca, and one with untransformed glyf and transformed loca - validator must reject the files as invalid.

reservedFlagsMustBeZero

Create an input woff2 font file with the transformed 'hmtx' table indicating a valid transform number "1" applied where transform Flags field indicates an invalid transform with non-zero reserved bit values (we can re-use one of the UA test font files). Validator must reject the file as invalid.

tableOrdering

Validator checks that the tables are in the expected order in the WOFF2 file. Test with two pairs of fonts (single font file and a font collection), one pair with correct order and another one mis-ordered.

metadata-optional

Create a font without metadata. Ensure that the validator accepts it

mustBeBrotliCompressedMetadata

Create a font for which the metadata was compressed with GZIP. Ensure the validator rejects it.

Create a font for which the metadata was not compressed with Brotli. Ensure the validator rejects it.

Validator accepts either no metadata, or metadata which has been separately compressed with brotli. It rejects one where metadata is separately gzipped and one where it is uncompressed xml. Make a test font with metadata block compressed in the same brotli stream as table data. Ensure the validator rejects it.

metadata-wellformed

Make fonts with
- well-formed metadata (pass)
- non well formed metadata (fail)

metadata-encoding

Make fonts with
- no metadata (pass)
- well formed metadata, BOM, no xml declaration, in UTF-8 (pass)
- well formed metadata, no BOM, xml declaration, in UTF-8 (pass)
- well formed metadata, BOM, no xml declaration, in UTF-16 (fail)
- well formed metadata, no BOM, xml declaration, in UTF-16 or 8859-1 or whatever (fail)

metadata-afterfonttable

Validator checks there zero to three null bytes (as needed to reach a 4-byte boundary)

metadata-padalign

Make font with metadata without padding the beginning of it.

metadata-noprivatepad

Validator checks that, if there is metadata and there is no private data, there is no trailing padding after metadata. Test with several fonts:

  • meta and padding
  • meta and no padding
  • meta and private

The second and third pass, the first fails.

private

Make fonts with private data block (pass), without private data block (pass).

private-last

Dummy compressed font, for which the private data block is not last. Ensure the decoder rejects it.

Dummy compressed font, for which the private data block is last. Ensure the decoder accepts it.

private-padalign

Validator checks there zero to three null bytes (as needed to reach a 4-byte boundary)

private-end

Validator checks there is no space after the private block, if present. Test fonts - one with data after private (fail), one with private and no trailing data (pass)