`Interned::insert` looked the key up and then inserted it, two probes for a
new key. It now goes through `HashMap::entry`, one probe either way, and
counts that probe itself, so the tests count what the index does.
`author()` built a `String` key on every call. It now looks the author up
borrowed first, and allocates only for a new one.
Review on #1467.
Both writers found each run's font and colour by scanning the table so far
(write.rs `Tables`, doc/export.rs `Tables` and `author` for `\revtbl`), so
a document with n distinct fonts or colours took O(n²) comparisons. 3,000
runs with their own font and colour took 18,006,000 steps in the small
writer and 13,498,500 in the word-model writer.
Each table stays a Vec, in first-use order, so the output is unchanged.
`Interned` adds a map from key to place beside it: the colour, the font
name lowercased (as `eq_ignore_ascii_case` matched), or the trimmed author.
Tests count lookups through a test-only counter, as PdfCraft's own RTF
writer does: at most four per run for 3,000 runs in each writer, and font
names still match without regard to ASCII case.
* Add craft-rtf: RTF tokenizer, text decoding, and a reader and writer for a small model
The tokenizing rules, code pages, multibyte decoding, dates and escaping come
from WordCraft's RTF reader and writer. The model (paragraphs with outline
level and indent, character formatting, tables) covers what DesignCraft's text
import, DeckCraft's outline import and export and PdfCraft's export use.
An unpaired UTF-16 surrogate in \u reads as U+FFFD and a high surrogate pairs
only with the very next \u, as storytold/wordcraft#6105 describes for Word.
* craft-rtf: a symbol font's bytes are its own codes
A font with \fcharset2 (Symbol, Wingdings) has no letters: a byte from 0x80
reads as U+F000 + the byte instead of a letter of the document's code page.
The symbol page applies to body text only, a symbol default font's page does
not apply to text in a font chosen with \f, \plain makes the default font's
page current again, and a code page an entry names with \cpg is kept.
Ported from storytold/wordcraft#6014.
* craft-rtf: alignment, indents, spacing, superscript and subscript; NUL is not text
The model and both directions gain what DesignCraft's RTF export writes:
\ql \qc \qr \qj, \ri, \fi, \sb, \sa, \super, \sub, \nosupersub.
A \u0 or \'00 no longer puts a NUL into the text.
---------
Co-authored-by: Simon Koch-Sultan <126534658+scks1@users.noreply.github.com>