skia-safe 0.16.0

Safe Skia Bindings for Rust
Documentation

Safe Rust bindings to the Skia Graphics Library.

This packages contains safe Rust wrappers for Skia and uses skia-bindings to build and interface with the Skia C++ library.

For information about the supported build targets and how to run the examples, please visit the github page of the rust-skia project.

Documentation

Functional level documentation is not yet available. To get started, take a look at the Rust examples or the Skia documentation.

Bindings & Wrappers

Skia-safe wraps most parts of the public Skia C++ APIs:

  • Vector Geometry: Matrix, Rect, Point, Size, etc.
  • Most drawing related classes and functions: Surface, Canvas, Paint, Path.
  • Almost all Effects and Shaders.
  • Utility classes we think are useful.
  • PDF & SVG rendering
  • Skia Modules
  • GPU Backends
    • Vulkan
    • OpenGL
    • Metal

Wrappers for functions that take callbacks and virtual classes are not supported right now. While we think they should be wrapped, the use cases related seem to be rather special, so we postponed that for now.

Features

Skia-safe supports the following features that can be configured via cargo:

Feature vulkan

Vulkan support can be enabled by setting the Cargo feature default = ["vulkan"] in skia-safe/Cargo.toml, which will cause a rebuild of Skia. To render the examples with Vulkan use cargo run --example skia-org -- [OUTPUT_DIR] --driver vulkan.

Note that Vulkan drivers need to be available. On Windows, they are most likely available already, on Linux this article on linuxconfig.org might get you started, and on macOS with Metal support, install the Vulkan SDK for Mac and configure MoltenVK by setting the DYLD_LIBRARY_PATH, VK_LAYER_PATH, and VK_ICD_FILENAMES environment variables as described in Documentation/getting_started_macos.html.

Feature svg

This feature enables the SVG rendering backend. To create a new Skia canvas that renders to SVG, use the function skia-safe::svg::Canvas::new().

Feature shaper

The Cargo feature shaper enables text shaping with Harfbuzz and ICU.

On Windows, the file icudtl.dat must be available in your executable's directory. To provide the data file, either copy it from the build's output directory (shown when skia-bindings is compiled with cargo build -vv | grep "ninja: Entering directory"), or - if your executable directory is writable - invoke the function skia_safe::icu::init() before creating the skia_safe::Shaper object.

A simple example can be found in the skia-org command line application.