c2pa_fonts/lib.rs
1// Copyright 2026 WritersLogic. All rights reserved.
2// Licensed under the Apache License, Version 2.0 or the MIT license,
3// at your option.
4
5//! C2PA manifest embedding, hard binding, and verification for OpenType/TrueType
6//! (SFNT) fonts.
7//!
8//! Implements the C2PA font embedding method — storing a C2PA Manifest Store
9//! and/or a remote manifest URI in a `C2PA` SFNT table — together with its
10//! `c2pa.hash.data` hard binding. Embedding re-serializes the font so the table
11//! directory, offsets, and checksums (including `head.checkSumAdjustment`) stay
12//! valid.
13//!
14//! This crate owns the two format-specific validation steps: locating and
15//! extracting the manifest (step 1) and the hard binding (step 5). COSE
16//! signature verification, X.509 trust evaluation, and assertion/ingredient
17//! validation are delegated to the official
18//! [`c2pa`](https://crates.io/crates/c2pa) SDK via the optional `validation`
19//! feature. Manifest construction and signing remain the SDK's job.
20//!
21//! The `C2PA` font table format is **preliminary** in the C2PA specification and
22//! is not yet defined in the OpenType/OFF specifications.
23
24mod binding;
25mod error;
26#[cfg(all(feature = "python", not(target_arch = "wasm32")))]
27mod python;
28mod reader;
29mod sfnt;
30mod table;
31#[cfg(feature = "validation")]
32mod validate;
33mod verify;
34#[cfg(target_arch = "wasm32")]
35mod wasm;
36mod writer;
37
38pub use binding::{data_hash_exclusions, Exclusion};
39pub use error::Error;
40pub use reader::{read_c2pa_table, read_manifest, read_manifest_uri};
41pub use table::{C2paTable, C2PA_TAG, MAJOR_VERSION, MINOR_VERSION};
42pub use verify::{verify, Compliance};
43pub use writer::{
44 embed_manifest, fill_manifest, remove_manifest, reserve_manifest, ManifestSource, ReservedFont,
45};
46
47#[cfg(feature = "validation")]
48pub use binding::{compute_data_hash, data_hash_ranges, verify_data_hash};
49#[cfg(feature = "validation")]
50pub use validate::{validate, Validation};