use common::{Glue, GlueOrder, Scaled}; /// TeX glue with stretch and shrink orders stored as engine values. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct TeXGlue { pub width: Scaled, pub stretch: Scaled, pub stretch_order: TeXGlueOrder, pub shrink: Scaled, pub shrink_order: TeXGlueOrder, } #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub enum TeXGlueOrder { #[default] Normal, Fil, Fill, Filll, } impl TeXGlueOrder { pub const fn index(self) -> usize { match self { Self::Normal => 0, Self::Fil => 1, Self::Fill => 2, Self::Filll => 3, } } } impl From for TeXGlue { fn from(glue: Glue) -> Self { Self { width: glue.width, stretch: glue.stretch, stretch_order: glue.stretch_order.into(), shrink: glue.shrink, shrink_order: glue.shrink_order.into(), } } } impl From for Glue { fn from(glue: TeXGlue) -> Self { Self { width: glue.width, stretch: glue.stretch, stretch_order: glue.stretch_order.into(), shrink: glue.shrink, shrink_order: glue.shrink_order.into(), } } } impl From for TeXGlueOrder { fn from(order: GlueOrder) -> Self { match order { GlueOrder::Normal => Self::Normal, GlueOrder::Fil => Self::Fil, GlueOrder::Fill => Self::Fill, GlueOrder::Filll => Self::Filll, } } } impl From for GlueOrder { fn from(order: TeXGlueOrder) -> Self { match order { TeXGlueOrder::Normal => Self::Normal, TeXGlueOrder::Fil => Self::Fil, TeXGlueOrder::Fill => Self::Fill, TeXGlueOrder::Filll => Self::Filll, } } }