TeX's badness(t, s) (tex.web §108): how bad it is to stretch (or shrink) by
t when s is available. 0 is perfect, INF_BAD is unsettable.
TeX computes an integer approximation of 100·(t/s)³ using 32-bit scaled
arithmetic. We evaluate the same function in floating point and round, which
is what \tolerance, \hbadness and the fitness thresholds below are all
calibrated against.
Two artefacts of TeX's integer arithmetic are deliberately not reproduced, because they are properties of 32-bit Pascal rather than of typography:
inf_bad outright once r = 297·t/s exceeds 1290 — an
overflow guard on r³. It makes TeX's badness jump from 8189 straight to
10000 at a ratio of about 4.34.inf_bad when the shortfall exceeds 7230584sp (110.33pt) and
the available stretch is under 1663497sp (25.38pt), for the same reason.Both only fire at ratios above ~4.3, where a line is visibly broken anyway.
They matter only under \sloppy (\tolerance=9999), where TeX would refuse
a ratio-4.5 line that we accept at badness 9112.
Line breaking and glue setting.
model.ts's vocabulary is already exported above.