Changelog
What changed in the public surface of each release: a name added, removed or moved, and a type that widened. Every change to surface.toml has a line here. The reasons are in the decisions.
0.40.0
- Changed:
text_tagdraws one<text>per line of a multi-linecontent, stacked as slot text is, by the cap rule; a one-line text is unchanged (D145).
0.39.0
- Added:
reference_labels(columns, rows, *, column_kind="letters", row_kind="numbers", row_order="top_down") -> (column labels, row labels), the labels of a reference grid, letters A to Z or numbers, rows counted top down or bottom up (D143). - Added:
reference_origin(columns, rows, width, height, cell) -> GridPoint, the min corner of a reference-grid cell in divisions, the inverse ofreference_cell(D144). - Changed:
to_fragment_mm(..., cap_ratio=None):cap_ratiois optional and defaults to the library font'scap_height / units_per_em; neither it norlibraryraisesInvalidValueError(D142).
0.38.0
This release also carries the content of 0.37.0 (D139).
- Added:
text_boxes_prefix(slot, lines, height, font, grid=DEFAULT_GRID) -> tuple[Box, ...]and the one-measuretext_box(D139, see 0.37.0). - Added:
Measure.ink: GridBox, the union of the body ink, the leads, the given texts and any attached box, on the grid; an empty slot adds nothing andkeepoutis unchanged (D140). - Changed:
sheet_svgwrites its numbers as the shapes do: at most four decimals, a whole number of mm without.0(D141).
0.37.0
- Added:
text_boxes_prefix(slot, lines, height, font, grid=DEFAULT_GRID) -> tuple[Box, ...]: the box of each prefix of a line list, the k-th equal totext_boxof the first k lines; each distinct line is measured once (D139).
0.36.0
- Added:
on_gridonink_boxes(symbol, texts=None, height=None, font=None, grid=DEFAULT_GRID, *, on_grid=False): set, every box is aGridBoxrounded outward asmeasurerounds (min down, max up);InkBoxesis generic over its box type; floats stay the default (D138).
0.35.0
- Added:
ink_boxes(symbol, texts=None, height=None, font=None, grid=DEFAULT_GRID)andInkBoxes, the drawn ink with no margin as one box per group: the body (the elements that bind no port), each bound lead and each given slot text; a declaredbodyorkeepoutand a slot's reserved box enlarge none (D137).
0.34.0
- Changed:
text_footprintmeasures a text of one or more lines: the widest line by the block height under the font'stext_blockrule; one line is unchanged (D136).
0.33.0
- Added:
portonPolylineandArc(a trailing field) and in the file, as onLine; aCirclehas none (D135). - Changed:
leads,only_portsandkeepout_boxhandle every bound stroke;repeat,stretch,pattern_portsand composition carry it;lead-off-portchecks it (D135).
0.32.0
- Added:
text_footprint(font, text, cap_height_mm, grid, *, turn=False), the footprint of a one-line text in whole divisions as (width, height); withturnthe two are exchanged, the (thickness, reading length) aturn = trueslot declares asbox(D134). - Added:
corner_text(..., *, turn=False), the turned placement: the text reads bottom-up inside the box corner,turned=True(D134).
0.31.0
- Added:
Corner(NE,SE,SW,NW), a slot side that grows the box both ways from the slot point, its opposite corner;SlotSideisDirection | Centre | Corner, the data and the JSON schema accept the four names,orientturns a corner, and a corner slot grows with the body beyond a stretch cut (D131, D132). - Changed: the lint rule
stretch-cutaccepts a cut strictly inside a slot's box even when it lies outside the body; the cut then grows a declaredkeepout, not the body (D133).
0.30.0
- Added:
reference_cell(columns, rows, width, height, point), the (column label, row label) of the reference-grid cell holding a point of a page frame's content box, andReferenceCellError, raised for a point outside it with no clamp (D129). - Added:
floor_divisions(grid, mm), a length in millimetres rounded down to whole grid divisions, the mirror ofceil_divisions(D130). - Unchanged:
Library.font.heightsalready carries[font.heights]as a read-only mapping (0.16.0); no field was added.
0.29.1
- Changed (breaking):
port_formatis validated when a library has repeat or table symbols; the accessor isstr.library.tomlwithout the top-levelport_formatis refused with aschemafinding naming the key and the fix, andLibrary.port_formatandLibraryConfig.port_formatare keyword-onlystr, neverNone; a bundle withoutport_formatis invalid andbundle_to_dataalways writes it (D127). - Added:
text_divisions(grid, font, cap_height_mm), the em box of a text with that capital height in whole grid divisions,ceil_divisions(grid, em_height(font, cap_height_mm / grid.module_mm)); it measures the em box, not the capital's ink (D128). - Migrate: add
port_format = "{k}.{port}"to the top level of everylibrary.toml, before its first table, and passport_format=to everyLibrary(...)andLibraryConfig(...)call; regeneratebundle.jsonwithsymdef build.
0.29.0
- Added:
group_mm(body, at, *, classes=""), one<g class="..." transform="translate(x y)">around a fragment,atin mm (D125). - Added:
Orientation.half_turn, the orientation turned a further half turn, mirror kept (D126). - Changed: the closed-standard number in the bundle example of the design is gone; it says "My symbols".
- Changed (breaking): tutorial and fixture symbol ids renamed to descriptive keys; libraries that copied the tutorial ids rename them.
- Changed (breaking):
Library.fontandLibraryConfig.fontareFontMetrics, keyword-only and required, neverNone(D124). Alibrary.tomlwithout[font]is refused with aschemafinding that names the key and both forms, and a bundle without afontobject failsvalidate_bundle.bundle_to_dataalways writesfont.fitted_tableandfitted_symbolno longer check for a font. For the[font]files formLibraryConfig.fontis an unmeasured placeholder untilload_librarymeasures the files. - Migrate: add a
[font]table to everylibrary.toml(literal form, ornameandfiles); a library that wants the measure of no font declaresunits_per_em = 1000,cap_height = 720, empty[font.advances.normal]and[font.advances.thick], and[font.default_advance]normal = 600andthick = 600. Addfont=to everyLibrary(...)andLibraryConfig(...)call, and afontobject to a hand-written bundle.
0.28.0
- Changed (breaking):
FontMetrics.default_advanceis aMapping[Weight, float], one number per text weight, required for every weight likeadvances.library.tomltakes[font.default_advance]withnormalandthick(a single number is a schema finding); the bundle'sfont.default_advanceis an object.measure_fontderives each from its own face, andtext_width(..., weight=Weight.THICK)charges the bold default for an unlisted character (D119). - Added:
[grid] outline_margin,Grid.declared_outline_margin(int | None, defaultNone) andGrid.outline_margin(int): the divisions a unit outline stands off the boxes it encloses. Readingoutline_marginof a grid with none declared raisesInvalidValueErrornaming the key and the fix. The bundle writes it only when set (D120). - Changed (breaking):
repeat(symbol, n, *, port_format): the template of a pole's port id with the fields{k}and{port}is required, and symdef keeps no default; a missing one is aTypeError, a malformed one raisesInvalidValueError. A part'srepeatkey takes the format from the new top-levelport_formatkey oflibrary.toml(LibraryConfig.port_format), checked as a template with exactly{k}and{port}; a library that usesrepeatwithout it fails to load with aschemafinding atrepeatnaming the key (D123).Library.port_format(str | None, the last field, defaultNone) carries it, and the bundle writes it only when set;table,fitted_table,pattern_portsandpole_porttake it too, as a required value with no default, and rename a row's or a copy's ports, nodes, paths, bound leads and slots by it, so one key sets every prefix. Callers passlibrary.port_format. Gate 3 ofsymdef checkrepeats with it and is skipped for a library that declares none (D123). - Added:
sheet_svg(width_mm, height_mm, body, *, margin_mm) -> str, the<svg>root in millimetres around a body, andbold_layer(fragment) -> str, one<g font-weight="bold">around a fragment (D122). - Migrate: replace
FontMetrics(..., default_advance=600)withdefault_advance={Weight.NORMAL: 600, Weight.THICK: 600}anddefault_advance = 600in[font]with a[font.default_advance]table holdingnormal = 600andthick = 600(a library with[font] filesneeds nothing). - Migrate: replace
repeat(symbol, n)withrepeat(symbol, n, port_format=library.port_format), and addport_format=library.port_formatto everytable,fitted_tableandpattern_portscall and a third argument to everypole_portcall; withport_format = "{k}.{port}"inlibrary.tomlthe ports stay1.in,2.in. - Migrate: a library whose part files use
repeat = Naddsport_format = "{k}.{port}"at the top level oflibrary.toml, before its first table.
0.27.0
- Added:
rect_mm(box, *, library, weight, stroke, fill, dash=None, classes=""),outline_mm(box, *, library, weight, stroke, dash=None, classes="")andline_mm(a, b, *, library, weight, stroke, dash=None, classes=""): one SVG element in mm each, the width fromlibrary.lines, the dash fromlibrary.dash, the paint as given (D117, D118). - Added:
text_tag(..., classes="", at="baseline", font=None): aclasson the tag, andtoporcentreof the em box as the point, with the ascent fromfont; the defaults leave the output unchanged (D117).
0.26.0
- Added:
Weight.RULE(0.072 module, 0.18 mm at the default module) and the[lines] rulekey; a wire style may have weightrule, a symbol element may not (D115). - Added: the
[dash]table andLibrary.dash,LibraryConfig.dash: named dash patterns in mm.dashed(two lengths) anddash_dot(four) are required by a library that uses that style; the load fails naming the key. The bundle gains an optionaldashobject (D115). - Added:
Library.with_settings(dash=), which replaces the whole table (D115). - Added:
to_fragment_mm(..., library=None);weights_mmanddash_mmbecome optional and default tolibrary.linesandlibrary.dash(D116).
0.25.0
- Added:
tag_roots(symbol, orientation, library, *, gap, marking_height)andTextRoot(x, y, h, v): the text root of a symbol's tag slot and its three reflections through the body centre, in whole divisions of the library's grid (D113). - Added:
em_height(font, cap): the text height whose capital iscaptall, the exact inverse of the capital height a font gives (D114).
0.24.1
- Added:
measure(..., *, attach=None, stretch=None);stretch={axis: length}measures the symbol asstretch(symbol, axis, length, grid=library.grid)would make it, without building it (D111).
0.24.0
- Changed:
repeat(and a part'srepeatkey) accepts a symbol with no through path; every pole then has none (D106). - Added: keyword-only
pitchandpositionsonpattern_portsandstretch_to_ports: copies at a whole multiple of the wire pitch, or at given coordinates (D107). - Changed: lint rule
port-patternno longer refuses named ports on a pattern port's edge; it refuses two pattern ports on one edge.stretch_to_portson such an edge returns offsets for every port of the edge, andpattern_portsraises for a copy less than a wire pitch from a named port (D108). - Added:
table(row, n, axis, head=None, *, grid=None, gaps=None, positions=None, head_align=None):rowmay be a sequence of unlike rows;gaps,positionsandhead_alignare new (D109). - Added:
fitted_table(..., fit="cross");fit="step"fits the step along the stepping axis (D109). - Changed: lint rule
port-patternignores the single-port node that the bundle writes for a lone pattern port;symdef checkno longer fails on the reloaded bundle (D110).
0.23.0
- Added:
pattern_ports(symbol, edge, n, *, grid=DEFAULT_GRID), the symbol with the pattern port ofedgeexpanded intonports (1 toMAX_REPEAT) on the wire pitch, idsk.<id>, each with its bound lead andmarking.k.<id>slot; it raisesInvalidValueErrornaming the symbol, the edge andn(D104). - Added:
Port.pattern(TOMLpattern = true, bundle key only when true) and lint ruleport-pattern(ERROR, Ports): a pattern port shares its edge, has no cut on the edge's axis, or is in a node or path; 37 rules.port-isolatedskips a pattern port (D104). - Changed:
stretch_to_portson an edge with a pattern port takes anynup toMAX_REPEAT; every other edge is unchanged (D104).
0.22.0
- Changed:
keepout_boxis the body united with the bound leads (Lines with aport); a slot is a text slot and no longer enlarges it. A caller that read the keep-out as the room of the labels readsslot_box;Measure.keepoutstill holds the slots. The resolved JSONkeepout_boxmoves with it (D101). - Added:
only_ports(symbol, ports), the symbol with only the listed ports, their leads andmarking.<port>slots; an unknown id raisesUnknownNameErrornaming it and the symbol (D102). - Added:
stretch_to_ports(symbol, axis, edge, n, *, grid=DEFAULT_GRID), the(length, offsets)thatstretchtakes so thatedgecarriesnports on the wire pitch; it raisesInvalidValueErrorfor a symbol with no cut on the axis, an edge across the axis, ornabove the ports the edge declares (D102).
0.21.0
- Added:
text_tag(content, point, height_mm, *, anchor, font_family, turn=False, weight=Weight.NORMAL, tint=None, muted=None), one<text>in mm at a baseline point, andcorner_text(box, corner, height, font), the baseline point, anchor andturnedthat a box corner gives a text, as aTextPlacement(D100). - Added: keyword-only
lanes(default 1) andpitch(defaultlibrary.grid.wire_pitch, in M) onwire. Forlanesabove 1 the symbol holds one polyline per lane, lane 0 on the points and lane k moved k * pitch towards +y on a horizontal run and +x on a vertical run, mitred at corners.lanes=1is unchanged;lanesbelow 1,pitchof 0 or less, and a closed wire with several lanes raiseInvalidValueError(D99). - Added: the symbol keys
bodyandkeepout,[x0, y0, x1, y1]in M;Symbol.bodyandSymbol.keepout(default None).body_boxandkeepout_boxreturn a declared box exactly;orient,translate,stretch,repeatandtablecarry it (D98). - Added: lint rule
element-outside-body(ERROR, Geometry): a shape that leaves a declared body; 36 rules.text-outside-bodymeasures against a declared body (D98). - Added: the JSON schema's
bodyandkeepout; the resolved form writes them only when set.
0.20.0
- Added:
[grid] stretch_split = "weight" | "whole"(default "weight") andGrid.stretch_split; the bundle writes it only when "whole" (D97). - Added: a keyword-only
gridonstretchandtable; under "whole" a growth over several cuts splits in whole divisions, each cut but the last flooring its weighted share, and a growth that is not a whole number of divisions raises (D97).fitted_tableandfitted_symbolpasslibrary.grid.
0.19.0
- Changed: under
text_block = "grid"a centred text sits at the slot box's start edge plus floor(length / 2) whole divisions, not at the true centre; "cap" is unchanged (D96).
0.18.0
- Added:
slot_lines(slot, text, height, font), oneTextPlacementper\nline of a slot text,LINE_PITCHcap heights apart;text_box,to_fragmentandto_fragment_mmdraw and measure the whole block (D95). - Added:
fitted_symbol(symbol, texts, library, text_height), a symbol stretched on each axis so every slot intextsholds its text (D95). - Added:
wire(..., closed=False), keyword-only;closed=Truedraws a closed polyline (D95). - Added:
[font] text_block = "cap" | "grid"(default "cap"),FontMetrics.text_block, and agridkeyword onslot_text,slot_lines,text_boxandslot_box; "grid" sets rows a whole number of divisions apart with the baseline an ascent below the block top (D95). - Changed: a slot text containing
\nis drawn as several rows; a string without one is unchanged.
0.17.0
- Added:
fitted_table(row, axis, texts, library, text_height, *, head=None, head_texts=None), atablewhose columns are as wide as the widest text set in them, measured withlibrary.fontand rounded up to whole grid divisions (D94).
0.16.0
- Added:
[font]withfilestakesheights, the capital heights in mm by name;FontMetrics.heightscarries them (D93).familybesidefilesstays refused. - Added:
LibraryConfig.font_heights, theheightsof the files form, besidefont_filesandfont_name;fontstays None until the files are read (D93). - Changed: the load error for a literal key beside
filesnames the key and the fix.
0.15.0
- Added:
FontMetrics.family, the family name a renderer resolves the font by.measure_fontreads it from the regular face's typographic family (name ID 16), else its family (ID 1);FontMetrics.namestays ID 1. The literal[font]form takes an optionalfamily, defaultname;familybesidefilesis a load error, since the file gives it. The bundle'sfontobject carriesfamily(D92).
0.14.0
- Added:
measure(..., attach={slot_id: Symbol}). The attached symbol's keep-out box is placed at the turned slot's point and side, as a slot's reserved box is (never rotated), and united with that slot's box; it is inMeasure.slots[slot_id]andMeasure.keepout. A key that is not a slot id raisesUnknownNameError. Withoutattachthe result is unchanged (D91).
0.13.0
- Added:
measure_font(regular, bold)returningFontMetrics: it measures a regular and a bold TTF, given as bytes, into one advance table perWeight, the cap height, ascent and descent.fonttoolsis now a runtime dependency (D87). - Added:
[font]inlibrary.tomlmay givenameandfiles(regular,bold) instead of the metrics;symdef buildmeasures the files, relative tolibrary.toml, into the bundle. The literal form is unchanged (D87). - Added:
Library.with_settings(module_mm=None, font=None, heights=None, lines=None), a validated replace.fontis the two TTFs as bytes;GridandFontMetricsrun their own checks, then the checktext-outside-bodyruns over every symbol and a hit raisesInvalidValueError(D88, D90). - Added: the check
text-outside-body(D90), which measures a fixed text inside its symbol's body with the library font and is run byload_library(with the library's font, raisingLibraryError) and byLibrary.with_settingsin place oftext-too-large. - Added:
[lines]inlibrary.toml(normal,thick: millimetres) andLibrary.lines, a read-only map fromWeightto millimetres; the bundle carries it when not empty. A wire weight with no width is a load error (D89).
0.12.0
- Removed from
symdef, now onsymdef.authoring:build,check,init,lint,write_build,stale_build,RULES,finding_key,LibraryConfig(D84). - Added:
SymdefError, the base of every error symdef raises, withInvalidValueError,UnknownNameError,UnknownSymbolErrorandLibraryErrorunder it. None subclassesValueError,KeyErrororOSError, so anexcepton a builtin no longer catches them (D80). - Renamed:
GraphicalSymbolsErroris nowSymdefError; the old name is removed, with no alias (D80). - Added:
GridPoint,GridBox(withGridBox.union) andGridPort, whose coordinates are whole grid divisions (D81). - Added:
measure(symbol, orientation, library, texts=None, text_height=None)returningMeasure: body, keepout, slots and ports in whole divisions, already turned (D82). - Changed:
FontMetrics.advancesis one table perWeight([font.advances.normal]and[font.advances.thick]inlibrary.toml);thick_factoris removed, and the bundle'sfont.advanceshas anormaland athicktable (D82). - Added:
to_placed_fragment(symbol, orientation, at, library, ...), a fragment inside onetranslateread from aGridPoint(D83). - Added:
Grid.wire_pitch(8) andGrid.wire_pitch_fine(4), in divisions, and[grid]keys of the same names; the loader refuses a third pitch, a fine pitch that does not divide the standard one, and a port off the standard pitch (D86). - Added:
FontMetrics.heights, a read-only map of names to capital heights in millimetres, from[font.heights](D86). - Deprecated:
to_fragment_mmis listed for removal in 0.13, once its callers useto_placed_fragment.
0.11.0
- Added:
Library.fontandLibrary.grid, read from[font]and[grid]inlibrary.tomland carried by the bundle;FontMetrics,Grid,text_width. - Added:
slot_text,TextPlacement,to_divisions,from_divisions,ceil_divisions,Box.union,slots_box. - Widened:
body_box,keepout_boxandslot_boxtakefont=None(slot_boxalsotextandheight), andlinttakesgrid; with none, output is as before. - Made public:
orient_box,orient_point,orient_direction,pole_pitch,pole_port,nodes_of. - Changed:
load_libraryandload_bundlereturn aLibrarywhosesymbolsis read-only (D73 to D78).
0.10.0
- Widened:
Slot.sideisDirection | Centre; the centred sideCputs the box and the text onat(retroactive; the type widened in this release, D67 to D71). - Added: several
[[stretch]]cuts per axis, each with aweight; a line or polyline may saybetween = true.