Enum text_layout::Item
source · pub enum Item<Box = (), Glue = (), Penalty = (), N = f32> {
Box {
width: N,
data: Box,
},
Glue {
width: N,
stretch: N,
shrink: N,
data: Glue,
},
Penalty {
width: N,
cost: N,
flagged: bool,
data: Penalty,
},
}
Expand description
A single item in a paragraph.
Variants§
Box
An unbreakable box containing paragraph content. Typically represents a glyph or sequence of glyphs. Lines may not be broken at boxes.
Glue
Fields
width: N
The normal width of the whitespace.
stretch: N
The stretch parameter. If this item needs to be stretched in order to lay out a line, the stretch amount will be proportional to this value.
shrink: N
The shrink parameter. If this item needs to be shrunk in order to lay out a line, the shrink amount will be proportional to this value.
data: Glue
The glue’s data.
Whitespace that separates boxes. Lines may be broken at glue items.
Penalty
Fields
width: N
The width of the penalty item.
cost: N
The aesthetic cost of the penalty item. A high cost is a relatively undesirable breakpoint, while a low cost indicates a relatively desirable breakpoint.
flagged: bool
Whether or not this is a flagged penalty item. Some algorithms will attempt to avoid having multiple consecutive breaks at flagged penalty items.
data: Penalty
The penalty’s data.
A penalty item. Represents a possible breakpoint with a particular aesthetic cost that indicates the desirability or undesirability of such a breakpoint.