mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 16:24:38 +00:00
- Every zstd frame is decoded; anything but tar padding after the archive is refused. - pack.toml must name the index entry's locale; the files the index promises (spelling, hyphenation) must be in the archive. - Allow-list: pack.toml, spelling.aff, spelling.dic, hyphenation.pat at the root, LICENCES/<[A-Za-z0-9._-]> without a leading or trailing dot; Windows device names (con, prn, aux, nul, com1-9, lpt1-9, any extension) refused in names and locales. - Pack names lose control and bidi/format (Cf) characters before they are stored or listed. - An unreadable language-packs.json is kept as .bad and rebuilt from the pack folders (each pack.toml); no pack drops out. - A bad hand-made entry is Error::Index(IndexError::Invalid), not BadUrl; index parse errors are Index errors too. - Dead file:// handling removed. - language_pack_index_overridden() exposes the developer override; README says it bypasses the pin and works in release builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FypgCX8LsYYE8fsj4byBm2
58 lines
2.4 KiB
Rust
58 lines
2.4 KiB
Rust
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
|
|
|
//! The suite's font store: the font indexes of every source (Google Fonts, Noto, indexes the user
|
|
//! adds), exact lookup of a missing font, and verified installs into the one folder every app's
|
|
//! font catalog reads.
|
|
//!
|
|
//! ```no_run
|
|
//! # #[cfg(not(target_arch = "wasm32"))] {
|
|
//! use craft_font_store::{Cancel, FontStore, Index, PINNED_INDEX};
|
|
//! use craft_font_catalog::{Catalog, FontEnv};
|
|
//!
|
|
//! let store = FontStore::for_user(&FontEnv::from_process()).unwrap().with_catalog(Catalog::global().clone());
|
|
//! let index = store.cached_indexes(&PINNED_INDEX).unwrap();
|
|
//! if let Ok(face) = index.find_face("Lato", "Bold Italic") {
|
|
//! store.enable_network().unwrap(); // the user clicked Install
|
|
//! store.install_face(&index, face, &Cancel::new(), &mut |p| println!("{}/{}", p.done, p.total)).unwrap();
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//!
|
|
//! The index and its lookups, [`verify_font`] and [`IndexPin`] build on every target. The store,
|
|
//! the HTTP client and Language packs (the store's second item kind, `language-pack`: see
|
|
//! [`FontStore::install_language_pack`]) are native only.
|
|
|
|
mod index;
|
|
mod pin;
|
|
mod source;
|
|
mod sources;
|
|
mod verify;
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
mod http;
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
mod language_packs;
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
mod store;
|
|
|
|
pub use index::{
|
|
Axis, Face, Family, FontFile, FontSource, GOOGLE_FONTS, Index, IndexError, LICENSES, Language, LicenseFile, MAJOR_VERSION, MAX_FILE_BYTES,
|
|
MAX_INDEX_BYTES, MAX_LICENSE_BYTES, Script, SourceProblem, Unavailable, parse_style,
|
|
};
|
|
pub use pin::{IndexPin, PINNED_INDEX};
|
|
pub use sources::{SourceEntry, SourcesFile};
|
|
pub use verify::{VerifyError, is_font, sha256_hex, verify_font};
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub use http::{Cancel, Client, FetchError, Timeouts, USER_AGENT};
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub use language_packs::{
|
|
InstalledLanguagePack, LANGUAGE_PACK_INDEX_ENV, LANGUAGE_PACKS, MAX_PACK_ARCHIVE_BYTES, MAX_PACK_ENTRIES, MAX_PACK_FILE_BYTES,
|
|
MAX_PACK_INDEX_BYTES, MAX_PACK_UNPACKED_BYTES, PackEntry, PackIndex, PackIndexPin, language_pack_index_overridden,
|
|
};
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub use store::{Caller, Error, FontStore, InstalledFamily, InstalledFile, Network, Problem, Progress, UserSource};
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|