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
//! In-tree TeX math typesetting.
//!
//! `$…$` / `$$…$$` content is parsed ([`parse`]) into an atom tree,
//! laid out per the TeXbook Appendix G algorithm ([`layout`]) using
//! the OpenType MATH metrics of STIX Two Math ([`font`]), then drawn
//! by the renderer as filled glyph *outlines* + rule rectangles — no
//! font is embedded and nothing is selectable, so an equation behaves
//! like a figure in every PDF viewer.
//!
//! Characters STIX Two Math lacks (CJK, Arabic, Devanagari, … inside
//! `\text{…}` or as bare symbols) are outlined the same way from the
//! document's body / fallback faces (`text_fonts`) — still vector-only,
//! nothing embedded. A character no face covers renders as a hollow
//! placeholder box with a `log::warn!` rather than vanishing. RTL
//! runs inside `\text{…}` are reordered to visual order (see
//! [`layout::visual_order`]); no joining/shaping is performed —
//! parity with the body-text emit path.
//!
use ;
use ;
use RefCell;
use HashSet;
/// Parse + lay out `content`. Returns `None` only for whitespace-only
/// input; malformed TeX still produces a (best-effort) fragment.
/// `text_fonts` is the body-then-fallback chain consulted for
/// characters outside the math font's coverage (may be empty).
/// `warned` collects characters no font covers; share one set across
/// a render so each distinct char warns once per document.