C bindings to the Rust's ttf-parser
library.
Provides access only to most common methods.
cargo build --release
This will produce a dynamic library that can be located at target/release
.
Be sure to strip it.
cargo build
gcc test.c -g -o test -L./target/debug/ -lttfparser
env LD_LIBRARY_PATH=./target/debug/ ./test
This crate can be built and installed using cargo-c.
To build and used it uninstalled
cargo cbuild -v --library-type staticlib
export PKG_CONFIG_PATH=<the path cbuild shows at the end>
gcc test.c -g -o test `pkg-config --libs --cflags tffparser`
./test
To install it system-wide
cargo cinstall --destdir /tmp/ttf-parser
sudo cp -a /tmp/ttf-parser/* /
- The library doesn't use
unsafe
(except the bindings itself). - All data access is bound checked.
- No heap allocations, so crash due to OOM is not possible.
- Technically, should use less than 64KiB of stack in worst case scenario.
- All methods are thread-safe.
- All recursive methods have a depth limit.
- Most of arithmetic operations are checked.
- Most of numeric casts are checked.
- Rust panics will be caught at the FFI boundary.
The ttfparser.h
is generated via cbindgen
and then manually edited a bit.