Skip to main content

pieces_join

Function pieces_join 

Source
pub fn pieces_join(gap: f64, baseline_drift: f64, em: f64) -> bool
Expand description

Whether two adjacent pieces with no whitespace between them read as one word.

gap is the horizontal distance in points from the end of the left piece to the start of the right piece – negative where they overlap. baseline_drift is the absolute difference of their baselines in points. em is the larger of the two pieces’ type sizes in points.

The pieces join when the gap is under 0.15 em and the drift under 0.3 em: a real inter-word space parts them, and so does a superscript riding off the baseline, while a kern split or a style change inside the word does not.

A page breaks one word across adjacent spans more often than it looks: a style change inside the word, a kerning split written as two Tj, a ligature fallback. Inter-word spaces in body type are around 0.25 em and more, while kerning gaps are well under 0.1 em, so 0.15 em sits between a real space and an intra-word split. A superscript rides a third of an em off the baseline and more, while one line’s drift stays under it, so 0.3 em keeps x2 two words without splitting a line that merely slopes.