Rewrite of vangdfang/libcutter, with stronger support of SVG fields.
Find a file
2025-11-11 15:28:29 -07:00
src Finish implementing rect, continue path 2025-11-11 15:28:29 -07:00
test-svgs Add sample test SVGs 2025-11-11 14:01:05 -07:00
.gitignore Start thinking on design 2025-10-21 15:18:21 -06:00
Cargo.toml Continue dev 2025-11-06 15:46:51 -07:00
LICENSE Initial commit 2025-10-21 08:22:17 -06:00
README.md Start designing serial interface 2025-10-23 16:00:43 -06:00

libcutter-rust

Rewrite of vangdfang/libcutter, with stronger support of SVG fields.

Reasoning

The original libcutter design is naive, and only supports a very rudamentary understanding of the modern SVG standard. Most notably, it does not parse the attributes of SVG element (noted as <svg>), nor does it parse the Group element (noted as <g>). These objects contain several attributes that can modify the effective output of a file. This includes the transform attribute, as well as the viewbox attribute. These fundamentally modify what should be output by the printer, and lack of support makes it significantly harder to understand, from the GUI of an SVG editor, what the printer will actually output.

Less importantly, libcutter performs many memcpy calls, which is potentially dangerous. The library is also very difficult to understand, and imports out-of-date and unsupported libraries. The build process is officially poorly documented, and unofficial documentation is incomplete in documenting it's dependencies.

This project hopes to resolve these issues.

Dependencies

Rust library dependencies

This project is built using the native Rust tooling, installed with rustup and ran with cargo. Rust supports most modern operating systems and architectures; for more information, see the getting started page. Rust toolchains are trivial to install, and the build process will inherently download almost all necessary dependencies.

The dependencies used by this project are largely the community standard; clap, nalgebra, and tracing are recommended directly by the community on their guidance page. XML libraries are not listed on said website, however, roxmltree contains no futher dependencies, and is actively maintained as of Oct. 2025.

The serialport library is well maintained, and has enough functionality as to be worth the alternative of directly writing to a serial file. This comes with the downside of adding system-level dependencies, as the library uses the udev functionality in Linux for enumerating objects. These external system-level libraries are necessary at build-time, but are not required for deployment. This is seen as a reasonable tradeoff between functionality and development environment setup overhead.

System level dependencies

The serialport library this project is based upon requires the installation of the pkg-config package and libudev headers for build-time only. This is currently feature-gated by enable_printing, but that should be enabled as default in the future. On apt-based systems (Debian, Ubuntu, and their derivatives), these can be installed with:

sudo apt install pkg-config libudev-dev

On rpm-based systems (Fedora, RHEL-based distributions, OpenSUSE, etc), these can be installed with:

sudo dnf install pkgconf-pkg-config systemd-devel

If you are new to Linux and are unsure which distribution you are running, consult files in /etc with the suffix release to find your operating system. Once you are aware of the distribution, Wikipedia and DistroWatch should list the package manager of your distribution. If your package manager is not listed, please consider opening an issue for support.

Building

Once the Rust toolchain is installed, to build this project, simply run the following in the root of the repository:

cargo build

Alternatively, you can build with optimisations:

cargo build --release

The binary is found in target/debug/libcutter-rust, or target/release/libcutter-rust if built with optimisations. This can be run directly by calling the binary like so:

./target/release/libcutter-rust --svg-file /path/to/file.svg

You can also run the binary through cargo like so:

cargo run -- --svg-file /path/to/file.svg

Note that running through cargo requires the -- in the CLI arguments; this tells Cargo to pass all arguments that follow directly to the binary being run.