Repository Public License
1// ORIX Convert — Packages/EngineFont/Sources/CWOFF2Shim/include/woff2shim.h2// Description: C interface over google/woff2 (C++) for the Swift font engine: bounded WOFF2 encode and decode.3// Author: Simon-Pierre Boucher — contact@spboucher.ai4#ifndef ORIX_WOFF2_SHIM_H5#define ORIX_WOFF2_SHIM_H67#include <stddef.h>8#include <stdint.h>910#ifdef __cplusplus11extern "C" {12#endif1314/// Upper bound of the WOFF2 size of an sfnt (font or collection) with optional extended metadata (XML, may be NULL).15/// Returns 0 when the input cannot be read as an sfnt.16size_t orix_woff2_max_compressed_size(const uint8_t *data, size_t length, const char *metadata, size_t metadata_length);1718/// Encodes an sfnt to WOFF2. `*out_length` is the capacity of `out` on entry and the size written on return.19/// `quality` is the Brotli quality (0…11). Returns 1 on success, 0 on failure.20int orix_woff2_encode(const uint8_t *data, size_t length, uint8_t *out, size_t *out_length, int quality,21 int allow_transforms, const char *metadata, size_t metadata_length);2223/// Size of the sfnt announced by a WOFF2 header (untrusted; 0 when the header cannot be read).24size_t orix_woff2_final_size(const uint8_t *data, size_t length);2526/// Decodes WOFF2 to an sfnt, never producing more than `max_size` bytes. On success returns 1 and a buffer the27/// caller releases with `orix_woff2_free`.28int orix_woff2_decode(const uint8_t *data, size_t length, size_t max_size, uint8_t **out, size_t *out_length);2930void orix_woff2_free(uint8_t *buffer);3132#ifdef __cplusplus33}34#endif35#endif36