1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! 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
}
}
}