Skip to main content
← Back to kicad-monkey Rust Docs kicad-monkey Rust Crate API Reference

Module symbol_authoring

Module symbol_authoring 

Source
Expand description

Typed fresh-source authoring for KiCad symbol libraries (.kicad_sym).

Build an AuthoredSymbolLibrary and call canonical_text or write_into. The output is what KiCad 10’s own writer produces (SCH_WRITER_V10::SaveSymbolLibrary): the same tokens in the same order, the same number spelling and the same file layout (KICAD_FORMAT::Prettify). Lengths are integer nanometres and points are in the file’s frame, +Y up, so callers never format numbers. Lines end in LF on every platform (KiCad itself saves CRLF on Windows). The whole library is checked before anything is written; an invalid library writes nothing.

Items keep the order they are given in. KiCad keeps that order within each item kind when it loads a library and sorts them on its next save. Derived symbols (extends) and embedded files are not written.

Structs§

AuthoredPinAlternate
AuthoredSymbol
One root symbol.
AuthoredSymbolColor
(color r g b a); alpha runs from 0 to 1 as KiCad stores it.
AuthoredSymbolLibrary
A whole .kicad_sym file.
AuthoredSymbolPin
(pin ...). at is the connection point. Alternates are written in name order, as KiCad keeps them.
AuthoredSymbolPoint
A point in the library file’s frame: nanometres, +Y up.
AuthoredSymbolProperty
One (property ...) field.
AuthoredSymbolShape
AuthoredSymbolStroke
(stroke ...). Width 0 is KiCad’s default width and a negative width draws no outline.
AuthoredSymbolText
(text ...). KiCad stores the angle in tenths of a degree.
AuthoredSymbolTextBox
(text_box ...): word-wrapped text in a fixed box from start to end.
AuthoredSymbolTextEffects
(effects (font ...) (justify ...) (href ...)) of a field, text or text box.
AuthoredSymbolUnit
The drawing of one unit in one body style. Unit 0 and body style 0 mean all units and all body styles.
SymbolAuthoringLimits
Independent ceilings for one library write.

Enums§

AuthoredPinElectricalType
AuthoredPinGraphicStyle
AuthoredPinOrientation
Direction from a pin’s connection point to its body end, as KiCad names it.
AuthoredSymbolBodyStyles
Body styles a symbol offers (body_styles).
AuthoredSymbolFill
(fill ...).
AuthoredSymbolItem
AuthoredSymbolLineStyle
AuthoredSymbolPowerKind
AuthoredSymbolShapeGeometry
AuthoredSymbolTextHorizontal
AuthoredSymbolTextVertical

Constants§

KICAD_DEFAULT_PIN_NAME_OFFSET_NM
KiCad’s default pin name offset (DEFAULT_PIN_NAME_OFFSET, 20 mil).
KICAD_DEFAULT_TEXT_SIZE_NM
KiCad’s default text size (DEFAULT_TEXT_SIZE, 50 mil).
KICAD_SYMBOL_LIBRARY_VERSION_2025_10_24
The symbol-library format revision KiCad 10.0 writes.

Functions§

escape_lib_item_name
A library item name as KiCad stores it (EscapeString(..., CTX_LIBID)): \, <, >, : and " become {backslash}, {lt}, {gt}, {colon} and {dblquote}; line breaks are dropped.
unescape_lib_item_name
The shown form of a stored library item name: the inverse of escape_lib_item_name, plus the {slash} older KiCad wrote for /.
unescape_string
The text KiCad shows for a stored text (UnescapeString, common/string_utils.cpp, which EDA_TEXT::cacheShownText applies to every shown text): each escape token ({slash}, {dblquote}, …) becomes its character. A brace group after $, ~, ^ or _ (a text variable or markup) and an unknown token keep their braces, their content read the same way; an unclosed { stays.