retex-engine 1.0.0

The TeX typesetting engine for retex
Documentation
//! Glue specifications.

/// Order of infinity of a glue component: `normal`, LuaTeX's `fi`, `fil`,
/// `fill` or `filll`.
pub type GlueOrder = u8;

/// Finite glue.
pub const NORMAL: GlueOrder = 0;
/// `fi` (LuaTeX only).
pub const FI: GlueOrder = 1;
/// `fil`.
pub const FIL: GlueOrder = 2;
/// `fill`.
pub const FILL: GlueOrder = 3;
/// `filll`.
pub const FILLL: GlueOrder = 4;

/// A glue specification: natural width plus stretch and shrink.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Hash)]
pub struct Glue {
    /// Natural width (sp).
    pub width: i32,
    /// Stretch amount (sp, or units of the infinite order).
    pub stretch: i32,
    /// Shrink amount.
    pub shrink: i32,
    /// Order of the stretch.
    pub stretch_order: GlueOrder,
    /// Order of the shrink.
    pub shrink_order: GlueOrder,
}

impl Glue {
    /// Zero glue (TeX's `zero_glue`).
    pub const ZERO: Glue = Glue {
        width: 0,
        stretch: 0,
        shrink: 0,
        stretch_order: NORMAL,
        shrink_order: NORMAL,
    };

    /// Fixed glue of the given width.
    pub const fn fixed(width: i32) -> Glue {
        Glue {
            width,
            ..Glue::ZERO
        }
    }
}