Documentation
¶
Index ¶
Constants ¶
const InfPenalty = 10000.0
InfPenalty is TeX's "infinite" penalty (∞ = forbidden break, −∞ = forced).
const MaxBadRatio = 1e4
MaxBadRatio is the worst finite badness ratio the optimiser will consider: a line that is underfull with no stretch at all. Callers pass it as the tolerance for a last-resort pass that must return SOMETHING rather than fail. MaxBadRatio caps the adjustment ratio of a short line that has no stretch (the analogue of TeX's inf_bad): the line is very bad but still finite, so an emergency pass with a large tolerance can accept it instead of collapsing the whole paragraph onto one line.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
Kind ItemKind
Width float64
Height, Depth float64 // box only (glyph metrics)
R rune // box only (the glyph, 0 if none)
Stretch, Shrink float64 // glue only
Penalty float64 // penalty only
Flagged bool // penalty only (e.g. a hyphen) — consecutive flags are penalised
}
Item is one element of a horizontal list.
type Line ¶
type Line struct {
Start, End int // item index range [Start, End) actually set on the line
Ratio float64 // glue adjustment ratio r (−1 fully shrunk … +tolerance stretched)
}
Line describes one output line of a broken paragraph.
func KnuthPlass ¶
KnuthPlass breaks items into lines of the given width, minimising total demerits (linePenalty is TeX's \linepenalty). It returns the chosen lines in order and ok=false if no sequence of feasible breaks exists within tolerance.