Skip to main content

Module labels

Module labels 

Source
Expand description

Atom-label orientation and backbone bond insets.

Caller supplies SVG-space atom coordinates. Labels split into an atom-center part (sits on the atom) and an optional traveling part (extends away from the molecule). OH on the left of a mol becomes HO with O still at the atom; abbreviations like GlcA have no traveling part — the first or last glyph is the center depending on the bond approach side.

Orientation follows RDKit MolDraw2D (E/W/N/S). All chem scripts (H-counts, charges, star-label markup, symbols, bold/italic) go through crate::markup::parse_label_markup → ScriptRole fake scripts, outlined as glyph paths, not <text>.

Structs§

AtomIn
Atom input for backbone + label placement.
BondIn
Bond as atom index pair into place_backbone atoms slice.
BondOut
Shortened bond endpoints in SVG space.
LabelParts
Atom-center glyph(s) vs optional traveling H / charge.
PlacedLabel
One placed atom label in SVG space (+Y down).

Enums§

LabelSide
Which side the traveling text extends toward (RDKit OrientType).

Functions§

compose_label
Plain display string after orientation (OH / HO / NH₂⁺).
label_ink_shape
Glyph ink for a placed label (halo / occupancy).
label_side
Orient a label from the sum of neighbor vectors (SVG +Y down).
label_side_for
Like label_side but degree-0 Hs-first elements use West (RDKit).
place_backbone
Place all atom labels and shorten bond endpoints into label clearances.
place_label
Place one label so the atom-center glyph sits on (atom_x, atom_y).
place_label_weighted
Like place_label, with mol weight increasing bond↔label clearance.
shorten_bond
Shorten a bond segment by end insets (same as Python bonds.shorten).
split_label
Split a raw label into center + traveling H + charge.