Skip to main content

Module cache

Module cache 

Source
Expand description

Core types and layout pipeline for the text/inline formatting context.

This module defines the central data structures (UnifiedConstraints, LayoutCache, FontManager, UnifiedLayout, etc.) and implements the 5-stage inline layout pipeline:

  1. Logical AnalysisInlineContentLogicalItem
  2. BiDi ReorderingLogicalItemVisualItem
  3. ShapingVisualItemShapedItem
  4. Text Orientation — vertical writing-mode transforms
  5. Flow / Positioning — line breaking + final PositionedItem placement

The module also contains cursor movement helpers, caching infrastructure (per-item and monolithic), and font management (FontContext, FontManager, LoadedFonts). Integration with the box layout solver lives in solver3/fc.rs.

Re-exports§

pub use crate::font_traits::ParsedFontTrait;
pub use crate::font_traits::ShallowClone;

Structs§

BidiLevel
BreakCursor
CachedLineBreaks
Cached line break boundaries from a previous layout pass.
ContentIndex
A stable, logical pointer to an item within the original InlineContent array.
FontChainKey
Key for caching font chains - based only on CSS properties, not text content
FontContext
Bundles all font-related state that can be shared across layout passes.
FontHash
A reference to a font for rendering, identified by its hash. This hash corresponds to ParsedFont::hash and is used to look up the actual font data in the renderer’s font cache.
FontManager
FontSelector
A selector for loading fonts from the font cache. Used by FontManager to query fontconfig and load font files.
Glyph
Enhanced glyph with all features
GraphemeClusterId
A stable, logical identifier for a grapheme cluster.
HyphenationBreak
Represents a single valid hyphenation point within a word.
InitialLetter
InlineBorderInfo
Border information for inline elements (display: inline, inline-block)
InlineBreak
InlineImage
InlineShape
InlineSpace
IntrinsicTextSizes
Inline-axis intrinsic contributions derived from shaped text, without running the line-breaking stage of the pipeline.
LayoutFontMetrics
Layout-specific font metrics extracted from FontMetrics Contains only the metrics needed for text layout and rendering
LayoutFragment
Defines a single area for layout, with its own shape and properties.
LineConstraints
Line constraints with multi-segment support
LineSegment
LoadedFonts
A map of pre-loaded fonts, keyed by FontId (from rust-fontconfig)
MemoryFace
One in-memory face registered under a family name, with the style attributes needed to choose the right face for a CSS (weight, italic/oblique) query.
OverflowInfo
Stores information about content that exceeded the available layout space.
PartialStyleProperties
Point
PositionedItem
Rect
ShapedCluster
A group of glyphs that corresponds to one or more source characters (a cluster).
ShapedGlyph
A single, shaped glyph with its essential metrics.
Size
Stroke
StyleOverride
StyleProperties
Style properties with vertical text support
StyledRun
TextCacheMemoryReport
Approximate heap bytes retained by a TextShapingCache.
TextDecoration
TextShapingCache
UnifiedConstraints
Unified constraints combining all layout features
UnifiedLayout
UnifiedLine
Intermediate structure carrying information from the line breaker to the positioner.
VerticalMetrics
VisualItem
VisualRun

Enums§

AvailableSpace
Available space for layout, similar to Taffy’s AvailableSpace.
BidiDirection
BreakType
CharacterClass
ClearType
FontChainKeyOrRef
Either a FontChainKey (resolved via fontconfig) or a direct FontRef hash.
FontOrRef
Enum that wraps either a fontconfig-resolved font (T) or a direct FontRef.
FontStack
Font stack that can be either a list of font selectors (resolved via fontconfig) or a direct FontRef (bypasses fontconfig entirely).
FontStyle
FontVariantCaps
FontVariantEastAsian
FontVariantLigatures
FontVariantNumeric
GlyphKind
The kind of a glyph, used to distinguish characters from layout-inserted items.
GlyphOrientation
GlyphSource
Hyphens
Controls whether hyphenation is allowed to create soft wrap opportunities.
ImageSource
IncrementalRelayoutResult
Result of an incremental relayout attempt.
InitialLetterAlign
Alignment mode for initial letters, controlling which alignment points are used to size and position the letter relative to the root inline box.
InlineContent
JustifyContent
LayoutError
LineBreakStrictness
LineHeight
CSS line-height value.
LogicalItem
MemoryFontTier
How a registered in-memory face ranks against fonts on disk.
ObjectFit
OverflowBehavior
OverflowWrap
CSS overflow-wrap (aka word-wrap) property.
PathSegment
SegmentAlignment
Defines how text should be aligned when a line contains multiple disjoint segments.
ShapeBoundary
ShapeDefinition
ShapedItem
Spacing
TextAlign
TextBoundary
Text boundary types for cursor movement
TextCombineUpright
TextOrientation
TextTransform
TextWrap
UnicodeBidi
CSS unicode-bidi property values relevant to layout.
VerticalAlign
WhiteSpaceMode
WordBreak
WritingMode

Functions§

break_one_line
Breaks a single line of items to fit within the given geometric constraints, handling multi-segment lines and hyphenation. Break a single line from the current cursor position.
create_logical_items
Panics
extract_line_breaks
Extract line break boundaries from a positioned items list.
find_all_hyphenation_breaks
A “word” is defined as a sequence of one or more adjacent ShapedClusters.
get_base_direction_from_logical
get_item_measure
Helper to get the primary measure (width or height) of a shaped item.
get_item_measure_with_spacing
Like get_item_measure but ALSO includes the per-cluster letter-spacing and per-separator word-spacing that position_one_line adds after each cluster.
get_item_vertical_metrics
Gets the ascent (distance from baseline to top) and descent (distance from baseline to bottom) for a single item, incorporating half-leading from line-height.
get_item_vertical_metrics_approx
Approximate version of get_item_vertical_metrics for use without constraints (e.g. bounds()). Uses 80/20 ascent/descent ratio as fallback for empty-glyph strut case.
is_collapsible_whitespace
Returns true if the item is collapsible whitespace per CSS Text 3 §4.1.2 Phase II.
is_cursive_script_cluster
Returns true if the cluster’s first character belongs to a cursive script (Arabic, Syriac, Mongolian, N’Ko, Mandaic, Phags Pa, Hanifi Rohingya) per CSS Text 3 Appendix D.
is_no_break_space
True for separators that add word-spacing but must NOT offer a soft-wrap opportunity.
is_word_separator
is_zero_width_space
Helper to identify if an item is a zero-width space (U+200B), which provides a soft wrap opportunity with no visible width.
justify_kashida_and_rebuild
Rebuilds a line of items, inserting Kashida glyphs for justification.
perform_fragment_layout
Performs layout for a single fragment, consuming items from a BreakCursor.
position_one_line
Positions a single line of items, handling alignment and justification within segments.
reorder_logical_items
Errors
shape_visual_items
Errors
shape_visual_items_with_per_item_cache
Shape visual items into ShapedItems using pre-loaded fonts.
try_incremental_relayout
Attempt incremental relayout given old metrics and new per-item advance widths.

Type Aliases§

CacheId
FourCc
ShapedGlyphVec
Glyph storage for a single shaped cluster.