okage is a pure Go port of tiny-skia and of resvg.
- tiny-skia is a small 2D renderer in Rust, and it is a subset of
Skia, the renderer of Chrome. It fills and strokes paths with a
solid color, a gradient or a pattern. It dashes strokes, clips with a mask
and blends images. It renders on the CPU only. okage ports it into the root
package and the package
path. - resvg renders SVG files with tiny-skia. okage ports it into the package
svg. - velato renders Lottie animations. okage ports it into the package
lottie, which draws with okage (D41). - tinyhtml5, tinycss2 and cssselect2
parse HTML, parse CSS and match CSS selectors in Python, for WeasyPrint.
okage ports them into the packages
html,tinycss2andcssselect2(D49, D50).
Today xo/resvg wraps resvg through cgo and a static archive for
each platform. A program that imports okage needs the Go toolchain and nothing
else.
okage uses SIMD where Go can, and its scalar code is the fallback. SIMD (single instruction, multiple data) means one instruction that works on several values at once. A build with TinyGo, most of all for WebAssembly, is a goal that the port keeps in mind.
The port of tiny-skia is done, in the root package and in path. It gives
the same bytes as tiny-skia in the scalar build, in the SIMD build and with
TinyGo, and the 157 integration tests of tiny-skia pass. It is about 1.2 to
3 times slower than the scalar code of tiny-skia, and work that makes it
faster stays open (D35). The package svg is the port of usvg and
resvg. It parses and renders each test file of resvg: without text and
without a raster image, with the same pixels as resvg, and with text or an
image, within the tolerance of D31. The package lottie is the port of
velato. It gives the same calls to its sink as velato for each of the 879
Noto animated emoji, and each sampled frame of them is within the tolerance of
D43 of ThorVG. docs/PLAN.md holds the plan, the phases and the
open questions.
The port starts from resvg v0.49.0 and from the versions of the crates that
it uses, such as tiny-skia v0.12.0. After each base port, okage follows each
upstream commit. On 2026-11-12 okage follows resvg up to its commit 5bdbae64
of 2026-11-11. docs/upstream/upstreams.tsv lists the upstream
repositories, and one ledger for each records what okage did with each commit.
Install okage with this command:
go get github.com/xo/okageThe renderer imports only the Go standard library. The package svg also
uses typesetting for text, and golang.org/x/image/webp for WebP files.
typesetting is a public copy of go-text/typesetting in
okage (D52). okage does not use cgo, so a program that imports it builds with
CGO_ENABLED=0 for every platform that Go supports.
Go 1.27 has SIMD only as an experiment, so okage has two builds:
- The scalar build is the default.
- The SIMD build uses the package
simd/archsimdof Go on amd64, arm64 and WebAssembly. A program gets it when it builds withGOEXPERIMENT=simd.
GOEXPERIMENT=simd go build ./...Both builds give the same bytes for every image. On an amd64 CPU without AVX2, the SIMD build uses the scalar code. TinyGo always uses the scalar code. When Go makes SIMD a standard feature, the SIMD build becomes the default. docs/SIMD.md holds the details.
| Document | What it holds |
|---|---|
| docs/PLAN.md | the plan, the testing plan, the phases and the open questions |
| docs/UPSTREAM.md | the rules for porting each upstream repository and each change that it makes |
| docs/SIMD.md | the rules for the vector code, the two builds and the SIMD packages of Go |
| docs/BACKLOG.md | the work that is known and not done |
| docs/FORMATS.md | a survey of the work to support other vector formats, such as PDF, EPS and DWG |
| docs/decisions/ | every decision, one file each, with an index |
| CONTRIBUTING.md | how to change okage |
| AGENTS.md | the rules for a coding agent, which also hold for a person |
okage differs from upstream only where a decision says so:
-
The SIMD build computes a reciprocal exactly. The SIMD backends of tiny-skia approximate it in the blend modes color dodge and color burn, and its scalar backend computes it exactly (D16).
-
svgdecodes PNG, JPEG and GIF files with the standard library, and WebP files withgolang.org/x/image/webp, in place of the decoders of resvg (D7). -
svgfinds fonts and shapes text withtypesetting, the copy ofgo-text/typesettingin okage, in place of the crates of resvg. Its text can differ from the text of resvg (D9, D52). -
Each package logs to a
*slog.Loggerthat the caller gives (D20). -
An elliptical arc makes at most 4,096 cubic curves. kurbo has no limit, so an arc with a radius of about 4.23e20 or more does not end in upstream (D30).
-
The gamma stages give one result for every NaN. Upstream reads the bits of a NaN there, and they differ between x86 and ARM (D34).
-
The fallback of text skips a character that no font draws, and goes on with the characters after it. Upstream stops at that character, so the characters after it get no fallback (D39). The fallback also replaces whole clusters, where upstream copies glyphs one by one, so an emoji sequence such as a flag falls back with the text around it (D39).
-
The fallback of text also goes on for an emoji that the font does not draw as an emoji: a character with U+FE0F without a color glyph, such as "©️" in a text font, and an emoji sequence that the font draws as several glyphs. Upstream falls back only for a missing glyph (D40).
-
lottiedraws as ThorVG where velato differs: the opacity, the opacity stops, the radius and the highlight of gradients, solid layers, time remap, easing, spatial positions, the closing of animated shapes, the opacity and the blend mode of layers, masks and stroke dashes (D43).Renderer.MergePathsdraws merge paths by compositing, which velato and ThorVG do not, and it is off by default (D42). -
htmlbuilds a tree with a node for each run of text, where tinyhtml5 builds an ElementTree of Python. It goes on where upstream raises an error, and options bound the depth, the nodes and the issues of a parse (D49). -
tinycss2nests at most 256 blocks andcssselect2at most 32 selectors, where upstream has no limit. Where upstream raises an exception for a selector or a color, the port returns aSelectorErroror no color (D50).
When upstream changes the code of a difference, okage removes its own code and ports the change of upstream. D40 gives the steps for items 7 and 8, and D42 and D43 give them for item 9.
okage also adds APIs that upstream does not have:
- A
Pixmapgives an*image.RGBAthat shares its bytes, and it implementsimage.Imageanddraw.Image(D19). svg.Newmakes aRenderer, which renders SVG data into an*image.RGBAin one call, asxo/resvgdoes. It loads the fonts of the system on its first call, and sets each generic family to the first of a list of common fonts that is installed. The package registers the formatsvgwithimage.RegisterFormat, soimage.Decodereads SVG data (D36).FontDatabase.LoadOSFontsloads the same fonts into a database of the program (D46).svg.ShapeTextlays out a run of text with the fonts, the fallback and the shaping ofsvg, and gives its advance width and the outlines of its glyphs as a path, so that a program can draw text without SVG data (D37).TextRun.RenderColorGlyphsdraws its color glyphs, such as color emoji (D39).html.Parseparses an HTML-like label of Graphviz,label=<...>in DOT, andLabel.Layoutlays it out asdotdoes: the boxes of the tables and the cells, the rules, the runs of text and the ports (D38).lottie.Parsereads a Lottie file, andlottie.RenderFramedraws a frame of it onto an okage pixmap throughPixmapSink, the sink oflottiethat draws with okage (D41).lottie.Detectfinds a Lottie document from the start of a file, andlottie.OpenDotLottiereads a dotLottie archive.lottie.Loadparses either one.Composition.Imagedraws a frame into an*image.RGBAof a given size, andFrameCountandDurationcount and time the frames (D44).FontDatabase.LoadFontDataloads a font in WOFF, WOFF2 or EOT, as well as TrueType and OpenType data.svg.ConvertFontDataconverts such a font to TrueType or OpenType data.FontDatabase.FaceNamereturns a string of the name table of a face, such as the version or the sample text (D45). The packagewebfontgives the same conversion to a program that does not usesvg(D51).
The output of svg is compared with resvg and with libvips within a
tolerance, not byte for byte (D23). The renderer gives the same bytes as
tiny-skia.
The root package and path are under the BSD-3-Clause license of tiny-skia.
See LICENSE, which keeps the copyright lines of upstream. The
package svg and the packages that it uses take the MIT license of resvg and
of its crates, in a LICENSE file in each folder (D13). The package html
takes the MIT license of tinyhtml5, in html/LICENSE. That
license also covers the parser of the labels of Graphviz (D49). The packages
tinycss2 and cssselect2 keep the BSD-3-Clause licenses of their upstreams,
in tinycss2/LICENSE and
cssselect2/LICENSE (D50).
The brotli decoder in internal/brotli is a copy of the one of
github.com/dsnet/compress, and keeps its BSD-3-Clause license, in
internal/brotli/LICENSE (D45). The packages
under typesetting are a copy of go-text, and keep its license, the
Unlicense or the BSD-3-Clause license, in
typesetting/LICENSE. The package harfbuzz keeps the
MIT license of HarfBuzz in
typesetting/harfbuzz/LICENSE (D52). The
package lottie takes the MIT license of velato, in
lottie/LICENSE. Its test files are Noto animated emoji
under CC BY 4.0, as lottie/testdata/NOTICE says.