I use Adobe Illustrator extensively and automate it with AppleScript. I recently made a children's toy where I need to expand letter font objects (so I can cut them with the laser cutter) and offset the expanded objects by 0.6mm (so I can cut a mortise with the CNC router for the letters to fit into). The design for the letter P looks like this with the orange part to become the laser-cutter letter and the black stroke to become the mortise. I also add pictures of the result with the letter outside and inside the mortise.
I automated this with GUI scripting in Illustrator (see appendix below) and want to code this with an open source library so it is more accessible to anyone who wants to make such a toy with custom letters.
I have tried SVGwrite as suggested here, but I was unable to expand type. I found no answers whether Cairo would allow type expansion and path offset. One solution is to use Inkscape, but I would rather keep the code self-contained by importing a library rather than requiring the installation of an external program.
Do you know of a Python library that allows type expansion and path offset?
Appendix: Here is the only solution I found to automate this. I use AppleScript and Illustrator was with GUI interaction:
-- Code to interact with Illustrator via GUI property ai_process : "Adobe Illustrator" on clickMenuBarItemAndItem(menuBarItem, menuItem) tell application "System Events" tell application process ai_process tell menu bar 1 tell menu bar item menuBarItem tell menu 1 tell menu item menuItem click end tell end tell end tell end tell end tell end tell end clickMenuBarItemAndItem -- Code to expand object on expand() -- no expand command in API, so expand with GUI (this becomes a group) my clickMenuBarItemAndItem("Object", "Expand...") tell application "System Events" tell application process ai_process delay 1 key code 36 -- enter end tell end tell end expand -- Code to offset path my clickMenuBarItemAndTwoItems("Object", "Path", "Offset path...") tell application "System Events" tell application "Adobe Illustrator" to activate keystroke "0.6mm" delay 0.1 key code 36 -- enter delay 0.1 end tell