Skip to main content

glifo/
lib.rs

1// Copyright 2026 the Vello Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! Glifo provides APIs for efficiently rendering glyphs and paint styles like underline.
5//!
6//! # Goals
7//!
8//! Glifo is under rapid development. Consider it experimental for now. Its goals are to:
9//!
10//! - Provide an API surface that accepts glyphs and their positions and renders them to a surface.
11//! - Cache those glyphs so that repeated renders of a glyph are fast.
12//! - Support rendering paint styles like underline, strikethrough, and brush color.
13//! - Share expensive structs and data between the shaper and renderer like the hinting instance and hinted advance.
14//!
15//! # Features
16//!
17//! - `std` (enabled by default): Get floating point functions from the standard library
18//!   (likely using your target's libc).
19//! - `libm`: Use floating point implementations from `libm`.
20//! - `png`: Enables PNG support for drawing bitmap glyphs.
21//!
22//! At least one of `std` and `libm` is required.
23
24// LINEBENDER LINT SET - lib.rs - v3
25// See https://linebender.org/wiki/canonical-lints/
26// These lints shouldn't apply to examples or tests.
27#![cfg_attr(not(test), warn(unused_crate_dependencies))]
28// These lints shouldn't apply to examples.
29#![warn(clippy::print_stdout, clippy::print_stderr)]
30// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
31#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
32// END LINEBENDER LINT SET
33#![cfg_attr(docsrs, feature(doc_cfg))]
34#![no_std]
35
36extern crate alloc;
37#[cfg(all(feature = "std", feature = "libm"))]
38use core_maths as _;
39
40// Currently used for debugging in `cache.rs`, but only in debug build.
41use log as _;
42#[cfg(feature = "png")]
43use png as _;
44#[cfg(feature = "std")]
45extern crate std;
46
47use peniko::{self, color, kurbo};
48use vello_common::pixmap::Pixmap;
49
50pub mod atlas;
51mod colr;
52mod glyph;
53mod interface;
54pub mod renderer;
55mod util;
56
57pub use atlas::{
58    AtlasCommand, AtlasCommandRecorder, AtlasConfig, AtlasPaint, AtlasSlot, GLYPH_PADDING,
59    GlyphAtlas, GlyphCacheConfig, GlyphCacheKey, ImageCache, PendingClearRect, RasterMetrics,
60};
61pub use glyph::{
62    AtlasCacher, FontEmbolden, Glyph, GlyphCaches, GlyphColr, GlyphPrepCache, GlyphPrepCacheMut,
63    GlyphRun, GlyphRunBackend, GlyphRunBuilder, GlyphRunRenderer, HintCache, HintKey,
64    NormalizedCoord, OutlineCache,
65};
66pub use interface::{DrawSink, GlyphRenderer};