Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::fonts::Woff2Parser Class Reference

Decompress a WOFF2 font file into a raw TTF/OTF byte stream. More...

#include "donner/base/fonts/Woff2Parser.h"

Classes

struct  Options
 Resource ceilings and pinned-font constraints for one WOFF2 decode. More...

Static Public Member Functions

static ParseResult< std::vector< uint8_t > > Decompress (std::span< const uint8_t > woff2Data)
 Decompress WOFF2 data into a flat TTF/OTF byte stream.
static ParseResult< std::vector< uint8_t > > Decompress (std::span< const uint8_t > woff2Data, const Options &options)
 Decompress using explicit compressed and expanded byte limits.

Detailed Description

Decompress a WOFF2 font file into a raw TTF/OTF byte stream.

WOFF2 fonts use Brotli compression and a custom table transform to achieve higher compression ratios than WOFF 1.0. This parser delegates to the Google woff2 library (decode-only) to reconstruct the sfnt byte stream.

See also
https://www.w3.org/TR/WOFF2/ for the WOFF2 specification.

Class Documentation

◆ donner::fonts::Woff2Parser::Options

struct donner::fonts::Woff2Parser::Options

Resource ceilings and pinned-font constraints for one WOFF2 decode.

Class Members
size_t expectedOutputSize = 0
size_t maximumBrotliMemory = 0 Zero preserves generic decoder allocation behavior. Nonzero bounds all live Brotli allocations for this decode, including state, buffers and aligned accounting headers.
size_t maximumInputSize = 16 * 1024 * 1024 Encoded WOFF2 input bytes.
size_t maximumIntermediateSize = 16 * 1024 * 1024 Intermediate decode storage bytes.
size_t maximumOutputSize = 64 * 1024 * 1024 Reconstructed sfnt output bytes.
size_t maximumTableCount = 4096 Accepted sfnt table records. Nonzero for a build-pinned font whose exact reconstructed length is known. Uses one fixed output vector instead of a growing string followed by a copy; header and result must match.
size_t maximumTransformedGlyfSize = 4 * 1024 * 1024 Transformed glyf table bytes.
bool requireTrueTypeOutlines = false Restrict a pinned TrueType-only catalog without weakening generic full-text format support.

Member Function Documentation

◆ Decompress()

ParseResult< std::vector< uint8_t > > donner::fonts::Woff2Parser::Decompress ( std::span< const uint8_t > woff2Data)
static

Decompress WOFF2 data into a flat TTF/OTF byte stream.

Parameters
woff2DataThe WOFF2 file data as a byte span.
Returns
A ParseResult containing the decompressed sfnt bytes on success, or a ParseDiagnostic on failure.

The documentation for this class was generated from the following file: