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§
- Authored
PinAlternate - Authored
Symbol - One root symbol.
- Authored
Symbol Color (color r g b a); alpha runs from 0 to 1 as KiCad stores it.- Authored
Symbol Library - A whole
.kicad_symfile. - Authored
Symbol Pin (pin ...).atis the connection point. Alternates are written in name order, as KiCad keeps them.- Authored
Symbol Point - A point in the library file’s frame: nanometres, +Y up.
- Authored
Symbol Property - One
(property ...)field. - Authored
Symbol Shape - Authored
Symbol Stroke (stroke ...). Width 0 is KiCad’s default width and a negative width draws no outline.- Authored
Symbol Text (text ...). KiCad stores the angle in tenths of a degree.- Authored
Symbol Text Box (text_box ...): word-wrapped text in a fixed box fromstarttoend.- Authored
Symbol Text Effects (effects (font ...) (justify ...) (href ...))of a field, text or text box.- Authored
Symbol Unit - The drawing of one unit in one body style. Unit 0 and body style 0 mean all units and all body styles.
- Symbol
Authoring Limits - Independent ceilings for one library write.
Enums§
- Authored
PinElectrical Type - Authored
PinGraphic Style - Authored
PinOrientation - Direction from a pin’s connection point to its body end, as KiCad names it.
- Authored
Symbol Body Styles - Body styles a symbol offers (
body_styles). - Authored
Symbol Fill (fill ...).- Authored
Symbol Item - Authored
Symbol Line Style - Authored
Symbol Power Kind - Authored
Symbol Shape Geometry - Authored
Symbol Text Horizontal - Authored
Symbol Text Vertical
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, whichEDA_TEXT::cacheShownTextapplies 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.