Skip to main content

Crate typf_core

Crate typf_core 

Source
Expand description

Core traits and shared types for Typf.

This crate defines the common contract used by the rest of the Typf workspace: pipeline stages, shaping and rendering traits, shared error types, caches, and the data structures that move from one stage to the next.

Typf models text rendering as six conceptual steps:

  1. read input text,
  2. analyse script and direction,
  3. choose a font,
  4. shape characters into positioned glyphs,
  5. render those glyphs into pixels or vector data,
  6. export the result.

The default pipeline currently exposes the shaping, rendering, and export steps directly. The earlier stages still matter because other crates may use them for bidi resolution, text segmentation, or font fallback.

To extend Typf, implement one or more of these traits:

Shared values passed between those steps live in types.

Re-exports§

pub use context::PipelineContext;
pub use error::Result;
pub use error::TypfError;
pub use pipeline::Pipeline;
pub use pipeline::PipelineBuilder;
pub use traits::Exporter;
pub use traits::Renderer;
pub use traits::Shaper;
pub use traits::Stage;

Modules§

cache
Scan-resistant caching with TinyLFU and byte-weighted eviction
cache_config
Global cache configuration
context
The traveling container that carries data through pipeline stages
error
When things go wrong in the pipeline
ffi
C-ABI compatible types for FFI consumers.
glyph_cache
Backend-neutral glyph/render cache with byte-weighted eviction
linra
Linra rendering: shape and render in a single pass
pipeline
Pipeline orchestration for shaping, rendering, and export.
shaping_cache
Backend-agnostic shaping cache
traits
The contracts that bind every backend together
types
The data structures that move through the pipeline.

Structs§

Color
GlyphSourcePreference
Preference ordering and deny list for glyph sources
RenderParams
ShapingParams

Enums§

GlyphSource
RenderMode

Constants§

DEFAULT_MAX_BITMAP_HEIGHT
Default maximum bitmap height: 16k pixels
DEFAULT_MAX_BITMAP_PIXELS
Default maximum total bitmap pixels: 1 Gpix
DEFAULT_MAX_BITMAP_WIDTH
Default maximum bitmap dimension (width): 16,777,216 pixels (16M)
MAX_FONT_SIZE
Maximum font size in pixels to prevent DoS attacks.
MAX_GLYPH_COUNT
Maximum number of glyphs to render in a single operation.

Functions§

get_max_bitmap_height
get_max_bitmap_pixels
get_max_bitmap_width
validate_glyph_count
Validate glyph count against security limits