Drawing in Inkscape
Set up a 256 by 256 px document, draw with a 16 px centred stroke, save a plain SVG and import it as an icon source file.
Last updated
Inkscape is free and works directly on SVG, which makes it a good fit. Menu names vary by version.
1. Set up the document
- File > Document Properties: display units px, custom size 256 × 256 px, scale 1.0 (user units per px). The viewBox must be
0 0 256 256. - Grids: add a rectangular grid with spacing 16 px (and a minor line every 4 if you like). Turn on snapping to grid and to nodes.
- Add guides at 32 and 224 for the live area (drag from the rulers, then edit their position).
2. Draw
- Use the Pen, Ellipse and Rectangle tools. Rectangles: set Rx and Ry to 16, or 8 for small parts, in the tool controls.
- In Fill and Stroke (Ctrl+Shift+F): fill none for outlines, a flat color for solid shapes; stroke flat color, width 16 px, Join: Round, Cap: Round. Make sure the stroke is centred on the path (Inkscape strokes always are).
- Do not use Path > Stroke to Path.
- Avoid rotating or scaling shapes after you draw them. If you must, check Preferences > Behavior > Transforms > Store transformation: Optimized, so Inkscape bakes the transform into the coordinates, and confirm in the XML editor (Ctrl+Shift+X) that no element has a
transformattribute. - No text. If the icon needs letters, convert with Path > Object to Path.
- Do not use filters, gradients, clones, patterns or masks.
3. Save
File > Save As > Optimized SVG (or Plain SVG if the Optimized option is not there). With Optimized SVG:
| Option | Setting |
|---|---|
| Number of significant digits | 5 |
| Shorten color values | off |
| Convert CSS attributes to XML attributes | on |
| Collapse groups | off |
| Create groups for similar attributes | off |
| Keep editor data | off |
| Remove metadata | on |
| Enable viewboxing | off (width and height stay) |
The result must have viewBox="0 0 256 256" and no <style> block.
4. Import and check
cd tooling/generator
uv run scripts/icon.py import ~/Documents/pen-nib.svg pencil-line -c Editor -t edit,write,draw
uv run scripts/icon.py check pencil-line
uv run scripts/icon.py weights pencil-line
The import sends stroked shapes to line and filled shapes to area. Review area yourself: the weights page says when a filled shape is really a dot, hole or detail.