kakemono 0.24.1

Convert PDF, Word, Excel, PowerPoint and EPUB documents and web pages to HTML, Markdown, EPUB, LaTeX and JSON in Rust
Documentation
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
//! Stacked glyphs inside a line of text: inline fractions (`β₁²/√β₂`),
//! exponents that are fractions (`t^-½`), a subscript under a superscript
//! (`D∞²`) or limits on an inline sum.
//!
//! Written as running text, such glyphs come out side by side and the text
//! no longer matches the fraction bars and radicals of the page picture. In
//! hard-95 mode they are drawn glyph by glyph at their place in the PDF,
//! inside the line; the rest of the line stays flowing text.
//!
//! Glyphs on the baseline whose size differs from the line's (small
//! capitals, a big operator in the text) keep their own size, and wide gaps
//! (tabs, as in a table of contents) keep their width.

use super::{Units, esc, gaps_of, is_tall, span_html, spans_h95};
use crate::common::geom::median;
use crate::model::{Line, SUB, SUP, Span};

/// A glyph is raised or lowered when its baseline is further than this (in
/// em of the line font size) from the baseline of its line.
const OFF_BASELINE_EM: f32 = 0.1;
/// Two raised or lowered glyphs are stacked when they overlap horizontally
/// by more than this (in points)...
const STACK_MIN_OVERLAP_PT: f32 = 0.5;
/// ...and their baselines are further apart than this (in em of the line
/// font size): a numerator over a denominator, a superscript over a
/// subscript. Less than that is one glyph slightly lower than the other.
const STACK_MIN_RISE_EM: f32 = 0.4;
/// A glyph on the baseline keeps its own font size when it differs from the
/// font size of the line by more than this fraction (small capitals are
/// about 80% of the capitals).
const RESIZED_MIN_RATIO: f32 = 0.08;
/// A gap between two glyphs of a line wider than this (in em of the line
/// font size) is a tab: the space before the page number of a table of
/// contents entry, between a chapter number and its title, between the page
/// number and the title of a running head. It keeps its width in the PDF
/// instead of being one word space that the line-fitting script would
/// stretch letter by letter. Word spaces are about a third of an em.
const TAB_MIN_GAP_EM: f32 = 0.8;
/// ... and at least this many times the median of the word spaces of the
/// line (its gaps narrower than [`TAB_MIN_GAP_EM`]): a justified line with
/// loose word spaces has no tab.
const TAB_MIN_SPACE_RATIO: f32 = 3.0;
/// A line whose gaps are all wider than [`TAB_MIN_GAP_EM`] has tabs only
/// when there are at most this many ("1 ⇥ Introduction", "Index ⇥ 297");
/// more is a loosely justified line.
const TAB_MAX_ALONE_COUNT: usize = 2;

/// Consecutive glyphs of a line drawn at their own place.
struct Cluster {
    /// Index of the first glyph.
    first: usize,
    /// Index after the last glyph.
    end: usize,
    /// Range of the characters of the line text (the concatenated spans)
    /// the glyphs stand for, spaces between them included.
    chars: std::ops::Range<usize>,
}

/// What is known of the text of a line, character by character and glyph
/// by glyph.
struct LineText<'a> {
    /// For each character of the line text, the glyph it stands for (see
    /// [`glyph_of_chars`]).
    glyph_of_char: &'a [Option<usize>],
    /// Widths of the gaps left for glyphs without Unicode value (see
    /// [`gaps_of`]).
    gaps: &'a [f32],
    /// For each glyph, the width of the tab before it (see [`tabs_of`]).
    tabs: &'a [Option<f32>],
}

/// Text of one span waiting to be written, all at one size.
#[derive(Default)]
struct Plain {
    /// The characters.
    text: String,
    /// Their own font size (points), or `None` for the size of the line.
    size: Option<f32>,
}

impl Plain {
    /// Writes the pending text of `span` (if any) and clears it.
    fn flush(&mut self, out: &mut String, span: &Span, gaps: &mut std::slice::Iter<'_, f32>, units: &Units) {
        if self.text.is_empty() {
            return;
        }
        let html = span_html(span, &self.text, gaps);
        match self.size {
            Some(size) => out.push_str(&format!("<span style=\"font-size:{}\">{html}</span>", units.len(size))),
            None => out.push_str(&html),
        }
        self.text.clear();
    }
}

/// The styled text of a line as HTML, with its stacked glyphs (if any)
/// drawn at their place and its resized glyphs at their size. Returns the
/// markup and whether the text ended with a space (which the caller places
/// outside the line element).
///
/// Lines without stacked or resized glyphs or tabs, and lines whose text
/// cannot be matched to their glyphs, are written as plain styled text.
pub(super) fn line_html(line: &Line, spans: &[Span], units: &Units) -> (String, bool) {
    let gaps = gaps_of(line);
    let runs = stacked_runs(line);
    let tabs = tabs_of(line);
    if runs.is_empty()
        && tabs.iter().all(Option::is_none)
        && !line.glyphs.iter().any(is_tall)
        && !(0..line.glyphs.len()).any(|idx| own_size(line, idx).is_some())
    {
        return spans_h95(spans, &gaps);
    }
    let Some(glyph_of_char) = glyph_of_chars(line, spans) else {
        return spans_h95(spans, &gaps);
    };
    let clusters = clusters_of(&runs, &glyph_of_char);
    let text_info = LineText {
        glyph_of_char: &glyph_of_char,
        gaps: &gaps,
        tabs: &tabs,
    };
    write_line(line, spans, &clusters, &text_info, units)
}

/// For each glyph of `line`, the width (in points) of the gap before it when
/// that gap is a tab (see [`TAB_MIN_GAP_EM`] and [`TAB_MIN_SPACE_RATIO`]).
fn tabs_of(line: &Line) -> Vec<Option<f32>> {
    let spaces: Vec<f32> = (1..line.glyphs.len())
        .filter(|&idx| line.glyphs[idx].space_before)
        .map(|idx| line.glyphs[idx].x0 - line.glyphs[idx - 1].x1)
        .collect();
    let min_gap = TAB_MIN_GAP_EM * line.size;
    // The word spaces of the line, against which a wide gap is measured
    // (other wide gaps would hide a tab: "2 ⇥ Descriptive Statistics ⇥ 67").
    let words: Vec<f32> = spaces.iter().copied().filter(|&gap| gap <= min_gap).collect();
    let wide_count = spaces.len() - words.len();
    if words.is_empty() && wide_count > TAB_MAX_ALONE_COUNT {
        // Nothing but wide gaps: a loose justified line, not tabs.
        return vec![None; line.glyphs.len()];
    }
    let word_space = median(&words, 0.0);
    std::iter::once(None)
        .chain(line.glyphs.windows(2).map(|pair| {
            let gap = pair[1].x0 - pair[0].x1;
            (pair[1].space_before && gap > min_gap && gap >= TAB_MIN_SPACE_RATIO * word_space).then_some(gap)
        }))
        .take(line.glyphs.len())
        .collect()
}

/// Runs of consecutive glyphs that contain two stacked glyphs, as (first,
/// end) glyph indices: runs of raised or lowered glyphs (an inline fraction,
/// a fraction as an exponent), and runs of glyphs that overlap each other
/// horizontally (limits under `lim`, whose glyphs interleave with its
/// letters from left to right), merged where they meet. Runs with a glyph
/// that has no Unicode value are left out (such glyphs stay in the page
/// picture).
fn stacked_runs(line: &Line) -> Vec<(usize, usize)> {
    let mut runs = off_baseline_runs(line);
    runs.extend(overlapping_runs(line));
    runs.sort_unstable();
    let mut merged: Vec<(usize, usize)> = Vec::new();
    for (first, end) in runs {
        match merged.last_mut() {
            Some(last) if first < last.1 => last.1 = last.1.max(end),
            _ => merged.push((first, end)),
        }
    }
    merged.retain(|&(first, end)| {
        has_stacked_pair(line, first, end)
            && !line.glyphs[first..end]
                .iter()
                .any(|glyph| glyph.text.contains('\u{FFFD}'))
    });
    merged
}

/// Runs of consecutive raised or lowered glyphs, as (first, end) indices.
fn off_baseline_runs(line: &Line) -> Vec<(usize, usize)> {
    let off_baseline = |idx: usize| (line.glyphs[idx].y - line.baseline).abs() > OFF_BASELINE_EM * line.size;
    let mut runs = Vec::new();
    let mut idx = 0;
    while idx < line.glyphs.len() {
        if !off_baseline(idx) {
            idx += 1;
            continue;
        }
        let first = idx;
        while idx < line.glyphs.len() && off_baseline(idx) {
            idx += 1;
        }
        runs.push((first, idx));
    }
    runs
}

/// Runs of at least two consecutive glyphs each of which starts left of the
/// right end of the ones before it in the run (by more than
/// [`STACK_MIN_OVERLAP_PT`]), as (first, end) indices.
fn overlapping_runs(line: &Line) -> Vec<(usize, usize)> {
    let glyphs = &line.glyphs;
    let mut runs = Vec::new();
    let mut idx = 0;
    while idx < glyphs.len() {
        let first = idx;
        let mut right = glyphs[idx].x1;
        idx += 1;
        while idx < glyphs.len() && glyphs[idx].x0 < right - STACK_MIN_OVERLAP_PT {
            right = right.max(glyphs[idx].x1);
            idx += 1;
        }
        if idx - first >= 2 {
            runs.push((first, idx));
        }
    }
    runs
}

/// The font size of glyph `idx` of `line` when the glyph sits on the
/// baseline but is clearly smaller or larger than the line (see
/// [`RESIZED_MIN_RATIO`]), or is clearly larger wherever it sits; `None`
/// otherwise.
fn own_size(line: &Line, idx: usize) -> Option<f32> {
    let glyph = &line.glyphs[idx];
    let on_baseline = (glyph.y - line.baseline).abs() <= OFF_BASELINE_EM * line.size;
    let resized = (glyph.size - line.size).abs() > RESIZED_MIN_RATIO * line.size;
    // Larger than the line is never a superscript, wherever its baseline
    // ("初級1" at 18 pt in a running foot of 9 pt type).
    let larger = glyph.size > line.size * (1.0 + RESIZED_MIN_RATIO);
    ((on_baseline && resized) || larger).then_some(glyph.size)
}

/// Whether two glyphs of `line.glyphs[first..end]` sit one over the other.
fn has_stacked_pair(line: &Line, first: usize, end: usize) -> bool {
    let glyphs = &line.glyphs[first..end];
    glyphs.iter().enumerate().any(|(i, upper)| {
        glyphs[i + 1..].iter().any(|other| {
            let overlap = upper.x1.min(other.x1) - upper.x0.max(other.x0);
            overlap > STACK_MIN_OVERLAP_PT && (upper.y - other.y).abs() > STACK_MIN_RISE_EM * line.size
        })
    })
}

/// For each character of the line text (the concatenated `spans`), the
/// index of the glyph it stands for (`None` for the spaces between words).
///
/// The text of a line is its glyphs in order, with a space where a glyph
/// has `space_before`; at the end of the line a soft hyphen may have been
/// removed or a space added. Returns `None` when the text is anything else.
fn glyph_of_chars(line: &Line, spans: &[Span]) -> Option<Vec<Option<usize>>> {
    let mut expected: Vec<(char, Option<usize>)> = Vec::new();
    for (glyph_idx, glyph) in line.glyphs.iter().enumerate() {
        if glyph.space_before && glyph_idx > 0 {
            expected.push((' ', None));
        }
        expected.extend(glyph.text.chars().map(|ch| (ch, Some(glyph_idx))));
    }
    let text: Vec<char> = spans.iter().flat_map(|span| span.text.chars()).collect();
    let matches = |len: usize| {
        len <= expected.len() && text.len() >= len && expected[..len].iter().zip(&text).all(|(exp, ch)| exp.0 == *ch)
    };
    let mut map: Vec<Option<usize>> = expected.iter().map(|exp| exp.1).collect();
    if text.len() == expected.len() && matches(expected.len()) {
        Some(map)
    } else if text.len() + 1 == expected.len() && expected.last()?.0 == '-' && matches(text.len()) {
        map.pop();
        Some(map)
    } else if text.len() == expected.len() + 1 && text.last() == Some(&' ') && matches(expected.len()) {
        map.push(None);
        Some(map)
    } else {
        reordered_glyph_of_chars(&expected, &text)
    }
}

/// [`glyph_of_chars`] for a text whose characters are the glyphs' in another
/// order: the text of an inline fraction gives the numerator first, while
/// the glyphs go from left to right (`√ d c − 1` for `c` over `√d−1`).
/// Each character takes the first glyph not yet taken that stands for it;
/// spaces stand for no glyph. Returns `None` unless every glyph is taken,
/// except a hyphen at the end of the line that the text dropped.
fn reordered_glyph_of_chars(expected: &[(char, Option<usize>)], text: &[char]) -> Option<Vec<Option<usize>>> {
    let mut taken = vec![false; expected.len()];
    let mut map = Vec::with_capacity(text.len());
    for &ch in text {
        if ch == ' ' {
            map.push(None);
            continue;
        }
        let pos = (0..expected.len()).find(|&pos| !taken[pos] && expected[pos].0 == ch)?;
        taken[pos] = true;
        map.push(expected[pos].1);
    }
    let left: Vec<usize> = (0..expected.len())
        .filter(|&pos| !taken[pos] && expected[pos].0 != ' ')
        .collect();
    match left.as_slice() {
        [] => Some(map),
        [pos] if *pos + 1 == expected.len() && expected[*pos].0 == '-' => Some(map),
        _ => None,
    }
}

/// The clusters of the stacked runs, with the characters they cover.
fn clusters_of(runs: &[(usize, usize)], glyph_of_char: &[Option<usize>]) -> Vec<Cluster> {
    let in_run = |glyph: Option<usize>, first: usize, end: usize| glyph.is_some_and(|idx| first <= idx && idx < end);
    runs.iter()
        .filter_map(|&(first, end)| {
            let start = glyph_of_char.iter().position(|&glyph| in_run(glyph, first, end))?;
            let last = glyph_of_char.iter().rposition(|&glyph| in_run(glyph, first, end))?;
            Some(Cluster {
                first,
                end,
                chars: start..last + 1,
            })
        })
        .collect()
}

/// The HTML of character `ch` at position `pos` of the line when it is not
/// plain text: a tall glyph, which stays in the picture (an unseen gap of
/// its width), or a tab (a space whose next character is set far apart).
fn placed_char_html(line: &Line, ch: char, pos: usize, text_info: &LineText<'_>, units: &Units) -> Option<String> {
    let glyph_of_char = text_info.glyph_of_char;
    if let Some(glyph_idx) = glyph_of_char[pos]
        && is_tall(&line.glyphs[glyph_idx])
    {
        let glyph = &line.glyphs[glyph_idx];
        return Some(format!(
            "<span class=\"ph\" style=\"width:{}\">{}</span>",
            units.len(glyph.x1 - glyph.x0),
            esc(&glyph.text)
        ));
    }
    let tab = match (glyph_of_char[pos], glyph_of_char.get(pos + 1)) {
        (None, Some(&Some(next))) if ch == ' ' => text_info.tabs[next],
        _ => None,
    };
    tab.map(|width| format!("<span class=\"tab\" style=\"width:{}\">&#160;</span>", units.len(width)))
}

/// Writes the spans of a line, replacing the characters of each cluster by
/// the cluster drawn glyph by glyph, and setting resized glyphs (see
/// [`own_size`]) at their size and tabs (see [`tabs_of`]) at their width.
fn write_line(
    line: &Line,
    spans: &[Span],
    clusters: &[Cluster],
    text_info: &LineText<'_>,
    units: &Units,
) -> (String, bool) {
    let glyph_of_char = text_info.glyph_of_char;
    let mut gaps = text_info.gaps.iter();
    let mut out = String::new();
    let mut trailing = false;
    let mut pos = 0usize;
    let mut next_cluster = 0usize;
    for (span_idx, span) in spans.iter().enumerate() {
        let mut text = span.text.as_str();
        if span_idx + 1 == spans.len() && text.ends_with(' ') {
            text = text.trim_end_matches(' ');
            trailing = true;
        }
        let mut plain = Plain::default();
        for ch in text.chars() {
            match clusters.get(next_cluster) {
                Some(cluster) if cluster.chars.contains(&pos) => {
                    plain.flush(&mut out, span, &mut gaps, units);
                    if pos + 1 == cluster.chars.end {
                        out.push_str(&cluster_html(line, spans, cluster, glyph_of_char, units));
                        next_cluster += 1;
                    }
                }
                _ => {
                    if let Some(html) = placed_char_html(line, ch, pos, text_info, units) {
                        plain.flush(&mut out, span, &mut gaps, units);
                        out.push_str(&html);
                    } else {
                        // Spaces (no glyph) keep the size of the text before them.
                        if let Some(glyph_idx) = glyph_of_char[pos] {
                            let size = own_size(line, glyph_idx);
                            if size != plain.size {
                                plain.flush(&mut out, span, &mut gaps, units);
                                plain.size = size;
                            }
                        }
                        plain.text.push(ch);
                    }
                }
            }
            pos += 1;
        }
        plain.flush(&mut out, span, &mut gaps, units);
    }
    (out, trailing)
}

/// The glyphs of a cluster, each in a box of its advance width placed at its
/// position in the PDF relative to the start of the cluster and to the
/// baseline of the line. Each glyph keeps the style of its span, without the
/// raising or lowering of superscripts and subscripts (its position does
/// that). Kept out of translation.
fn cluster_html(
    line: &Line,
    spans: &[Span],
    cluster: &Cluster,
    glyph_of_char: &[Option<usize>],
    units: &Units,
) -> String {
    let span_of_char = span_of_chars(spans);
    let glyphs = &line.glyphs[cluster.first..cluster.end];
    let mut cursor = glyphs[0].x0;
    let right = glyphs.iter().map(|glyph| glyph.x1).fold(cursor, f32::max);
    let mut out = String::from("<span class=\"st\" translate=\"no\">");
    for (offset, glyph) in glyphs.iter().enumerate() {
        let glyph_idx = cluster.first + offset;
        let char_idx = glyph_of_char.iter().position(|&glyph| glyph == Some(glyph_idx));
        let source = char_idx.and_then(|idx| span_of_char.get(idx)).map(|&idx| &spans[idx]);
        let style = Span {
            text: String::new(),
            style: source.map_or(0, |span| span.style) & !(SUP | SUB),
            href: source.and_then(|span| span.href.clone()),
            color: glyph.color,
            math: None,
            note: None,
        };
        let mut css = format!(
            "width:{};top:{};font-size:{}",
            units.len(glyph.x1 - glyph.x0),
            units.len(glyph.y - line.baseline),
            units.len(glyph.size),
        );
        if glyph.x0 != cursor {
            css.push_str(&format!(";margin-left:{}", units.len(glyph.x0 - cursor)));
        }
        if offset + 1 == glyphs.len() && right > glyph.x1 {
            css.push_str(&format!(";margin-right:{}", units.len(right - glyph.x1)));
        }
        cursor = glyph.x1;
        let class = if is_tall(glyph) { "sg ph" } else { "sg" };
        out.push_str(&format!(
            "<span class=\"{class}\" style=\"{css}\">{}</span>",
            span_html(&style, &glyph.text, &mut [].iter())
        ));
    }
    out.push_str("</span>");
    out
}

/// For each character of the concatenated `spans`, the index of its span.
fn span_of_chars(spans: &[Span]) -> Vec<usize> {
    spans
        .iter()
        .enumerate()
        .flat_map(|(idx, span)| std::iter::repeat_n(idx, span.text.chars().count()))
        .collect()
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::common::geom::Rect;
    use crate::model::LineGlyph;

    /// A line of 10 pt type with one glyph per word, each word 20 pt wide
    /// and starting at the given position.
    fn line(starts: &[f32]) -> Line {
        let glyphs: Vec<LineGlyph> = starts
            .iter()
            .enumerate()
            .map(|(i, &x)| LineGlyph {
                text: "w".to_string(),
                x0: x,
                x1: x + 20.0,
                y: 100.0,
                size: 10.0,
                font: 0,
                script: 0,
                space_before: i > 0,
                drawn_space: false,
                link: None,
                ink: Rect::new(x, 93.0, x + 20.0, 100.0),
                ox: x,
                oy: 100.0,
                extra: Vec::new(),
                color: [0; 3],
            })
            .collect();
        Line {
            page: 0,
            bbox: Rect::new(starts[0], 90.0, starts[starts.len() - 1] + 20.0, 102.0),
            ink: Rect::new(starts[0], 93.0, starts[starts.len() - 1] + 20.0, 100.0),
            baseline: 100.0,
            size: 10.0,
            font: 0,
            glyphs,
            fixed_pitch: false,
        }
    }

    #[test]
    fn inline_fraction_text_is_matched_to_its_glyphs() {
        // "≤ c/√(d−1)": the text gives the numerator first, the glyphs go from
        // left to right (the radical starts left of the "c" above it).
        let mut fraction = line(&[0.0, 12.0, 15.0, 16.0, 19.0, 23.0]);
        for (glyph, text) in fraction.glyphs.iter_mut().zip(["≤", "√", "d", "c", "−", "1"]) {
            glyph.text = text.to_string();
            glyph.space_before = false;
        }
        let spans = [Span::plain("≤c √d−1")];
        let map = glyph_of_chars(&fraction, &spans).expect("the text is the glyphs reordered");
        assert_eq!(map, vec![Some(0), Some(3), None, Some(1), Some(2), Some(4), Some(5)]);
    }

    #[test]
    fn page_number_of_a_contents_entry_is_after_a_tab() {
        // "1.1 Finding Words  ........  12": word spaces of 3 pt, then 120 pt.
        let tabs = tabs_of(&line(&[0.0, 23.0, 46.0, 186.0]));
        assert_eq!(tabs, vec![None, None, None, Some(120.0)]);
    }

    #[test]
    fn chapter_number_and_page_number_are_both_tabs() {
        // "2 ⇥ Descriptive Statistics ⇥ 67": two gaps of about 1 em around
        // one word space of 3 pt.
        let tabs = tabs_of(&line(&[0.0, 30.0, 53.0, 83.0]));
        assert_eq!(tabs, vec![None, Some(10.0), None, Some(10.0)]);
    }

    #[test]
    fn loose_justified_line_has_no_tab() {
        // Word spaces of 18 to 22 pt: all wide, none much wider than the others.
        let tabs = tabs_of(&line(&[0.0, 38.0, 80.0, 120.0]));
        assert!(tabs.iter().all(Option::is_none));
    }
}