wuff-capi 0.2.0

C API for the wuff WOFF2 decoder, compatible with the woff2 C library's decoding API
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 15.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 269.83 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • nicoburns/wuff
    12 6 7
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nicoburns

wuff-capi

C++ API for the wuff pure-Rust WOFF2 decoder, compatible with the decoding API of the woff2 C++ library.

Note: only the decoding API (woff2/decode.h and woff2/output.h) is provided. The encoding API (woff2/encode.h) is not yet implemented.

What this crate provides

  • extern "C" symbols exported from Rust:
    • wuff_woff2_compute_final_size — reads the totalSfntSize field of a WOFF2 header (equivalent to woff2::ComputeWOFF2FinalSize)
    • wuff_woff2_decode — decompresses a WOFF2 font into a newly-allocated buffer
    • wuff_woff2_free — frees a buffer returned by wuff_woff2_decode
  • C++ headers (in include/woff2) that provide a drop-in replacement for the C++ woff2 library's decoding API as header-only wrappers around the C symbols above.

Usage (from Rust)

Add wuff-capi as a dependency of the crate whose build script compiles the C/C++ code that consumes the woff2 API. This crate sets links = "wuff", and its build script exports the location of its headers, which is available in dependent build scripts as the DEP_WUFF_INCLUDE_DIR environment variable:

// build.rs of a dependent crate
let woff2_include_dir = std::env::var("DEP_WUFF_INCLUDE_DIR").unwrap();
cc::Build::new()
    .cpp(true)
    .include(woff2_include_dir)
    // ...

The Rust symbols are linked automatically as part of the normal Rust build.