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
//! Folding presentation-form ligatures to the letters they stand for.
//!
//! Strictly U+FB00–U+FB06, the Alphabetic Presentation Forms that are purely
//! typographic. Æ, œ and ß are letters of their languages and are never
//! touched. Folding happens after quad matching, so a ligature is still atomic
//! for coverage, and after `/ActualText`, so a declaration is never undone.
use TextChar;
/// The letters a ligature presentation form stands for, or `None` if the
/// character is not one.
///
/// The fold set is the whole of the difficulty, and it is exactly U+FB00 to
/// U+FB06. That block, Alphabetic Presentation Forms, exists for legacy
/// round-tripping and holds no letter of any language. A note reading `tariff`
/// cannot be searched for or pasted anywhere useful, which is why folding is
/// the default rather than the option.
///
/// What must **not** be folded, and why each is tempting:
///
/// * **U+00C6/E6 (Æ/æ)** is a letter of Danish, Norwegian and Icelandic.
/// `cli-pdf-extract` folds it to `fl` and corrupts every Danish word that
/// contains it.
/// * **U+0152/0153 (Œ/œ)** is a letter of French, and Unicode *names* it
/// `LATIN SMALL LIGATURE OE`. The name records its history, not its status.
/// * **U+00DF (ß)** is a letter of German.
///
/// Nor is NFKC a shortcut: it also rewrites superscript two as an ASCII `2`,
/// which would mangle exponents throughout the papers this tool exists for.
///
/// U+FB05 is the one judgement call. Its constituent letters are U+017F LONG S
/// and `t`, so that is what it folds to — U+017F is a letter, like Æ, and not
/// this function's business. Folding it to `st` would be more useful to
/// someone searching an early-modern text and is a second transformation, not
/// a de-ligaturing.
pub
/// Split one glyph into the letters its presentation form stands for.
///
/// The advance is divided between them, which is what pdf_oxide already does
/// for a `/ToUnicode` entry mapping one code to several characters. It matters
/// for more than tidiness: `order_reading` decides where to insert a space
/// from `origin_x + rendered_advance`, so pieces that each carried the whole
/// advance would fabricate a gap after every ligature — `staff on` becoming
/// `staff on` — and pieces that carried none would swallow a real space.
pub