Repository navigation
Releases
v0.11.1
This release makes a fill through a mask faster. The renderer draws the same bytes as v0.11.0.
go get github.com/xo/okage@v0.11.1- A fill through a mask skips the rows and the chunks of 16 pixels at its sides where the mask is 0. The chunks that stay keep their places, so the bytes match tiny-skia for each blend mode (D60).
Mask.IntersectPathtakes its temporary mask from a pool, and clears and multiplies only the rows that the path can cover (D60).
In ivy, an image drawn through a clip of one row went from 1.3 s to 0.1 s for each page, and a form of PDF from 7.3 s to 3.1 s.
v0.11.0
This release adds the drawing and the text that ivy needs. The renderer draws the same output as v0.10.0 by default. Each new behavior is new API, or changes only a fill that panicked or drew nothing before.
go get github.com/xo/okage@v0.11.0Drawing
- A fill no longer panics on a path with huge coordinates. tiny-skia 0.12 has the same fault (D53).
DrawPixmapof an image that is aligned to the pixels skips the stages of the pipeline, with the same bytes. A full page with a mask and an opacity draws in 12 ms in place of 30 ms (D53).Paint.Coveragefills a path with 8 by 8 samples in each pixel.Paint.StrokeAdjustmoves a thin stroke onto the pixel grid, as stroke adjustment does in PDF. A hairline on a pixmap of 1 or 2 rows or columns now draws (D54).NewMeshGradientmakes a shader that fills a mesh of triangles with a color at each corner, for the shadings of the types 4 to 7 of PDF and PostScript.SpreadModeDecalmakes a gradient transparent outside its stops (D55).MaskFromLuminanceandMask.ApplyTransfermake the soft masks of PDF with a backdrop color and a transfer function.Pixmap.RemoveBackdropandPixmap.Knockoutcomposite the groups that are not isolated and the knockout groups (D56).
Text and SVG
FontDatabasegives the parsed fonts, new faces with variations, a lookup in the cached cmap and the metrics of a face.AutoFontVariationsmaps a CSS weight, stretch and style to the axes of a variable font.TextStyletakes the features, the language and the spacing of a run, andTextRun.Clustersgives each cluster.FontDatabase.ColorGlyphgives a glyph of COLR or of the table SVG as a tree (D57).svg.ReadDimensionsreads the size and the viewBox of an SVG image before the parse.svg.FromXMLTreeandsvg.FromXMLNodemake a tree from roxmltree, androxmltree.Buildermakes a document without XML text.svg.WithZeroSizeaccepts an image of size zero.:has()incssselect2matches in about linear time (D58).typesetting/font/cffexports the predefined charsets of CFF, and drawsseacand the FontMatrix of each font dictionary. The go-text commite8da365efixes the kerning of fonts such as Calibri and Roboto (D59).
v0.10.0
This release makes public the packages that ivy reads and lays out documents with. The renderer draws the same output as v0.9.0.
go get github.com/xo/okage@v0.10.0The new public packages
roxmltreeparses XML into a tree that a program reads. It is a port of the Rust crate roxmltree 0.21.1 (D47).kurbogives the 2D curves and shapes of a subset of the Rust crate kurbo 0.13.1 (D48).htmlnow also parses HTML documents, as a port of tinyhtml5 (D49). It still lays out the HTML-like labels of Graphviz.tinycss2parses CSS, andcssselect2matches CSS selectors against a tree. Both are ports of the Python packages of the same names (D50).webfontconverts a font in WOFF, WOFF2 or EOT into an sfnt file (D51).typesettingis a copy of github.com/go-text/typesetting v0.3.5, so that the maintainers can fix it in okage (D52).svguses the copy, andgo.modno longer requires go-text. No exported type of okage was a type of go-text, so a program that uses go-text for its own fonts keeps working.
v0.9.0
This release exports the loading of the system fonts of the renderer (D46).
go get github.com/xo/okage@v0.9.0The fonts of the system
svg.FontDatabase.LoadOSFonts() loads the fonts of the system and of the home directory into a database. It calls LoadSystemFonts with the root of the file system and LoadUserFonts with the home directory that os.UserHomeDir gives. On Windows, the root is the volume of %WINDIR%.
The Renderer now calls LoadOSFonts to load its fonts. A program that shapes text with its own database, beside a Renderer, loads the same fonts as the renderer. LoadOSFonts does not set the generic families. The Renderer still sets them.
v0.8.0
This release loads fonts in WOFF, WOFF2 and EOT, and reads the strings of the name table of a font (D45).
go get github.com/xo/okage@v0.8.0Fonts in a web format
svg.FontDatabase.LoadFontData loads a font in one of these formats:
| Format | What okage does |
|---|---|
| TrueType, OpenType, or a collection of them | Loads the bytes as they are, as before |
| WOFF 1.0 | Inflates each table and writes a TrueType or OpenType file |
| WOFF2 | Decompresses the tables with brotli and reverses the transforms of the tables glyf, loca and hmtx. A WOFF2 collection gives each of its faces |
| EOT | Removes the header, and reverses the XOR of the font data when the header sets it |
FaceData gives the converted bytes. An EOT file that uses MicroType Express compression does not load. LoadFontsFS, LoadSystemFonts and LoadUserFonts still load only .ttf, .ttc, .otf and .otc files, as fontdb does.
svg.ConvertFontData gives the TrueType or OpenType bytes of such a font, for a program that needs the bytes and not a database. Its errors wrap the new sentinel errors okage.ErrFontData, for malformed data, and okage.ErrFontUnsupported, for data in another format.
The brotli decoder is a copy of the one of github.com/dsnet/compress, in internal/brotli, under its BSD-3-Clause license. okage still has no new dependency. The decoder adds about 460 KB to a program that uses svg.
The name table
svg.FontDatabase.FaceName(id, nameID) returns the string of a name ID of the name table of a face, such as 4 for the full name, 5 for the version and 19 for the sample text. It takes the record in English (United States) first.
v0.7.1
This release fixes the results of okage on arm64 and s390x, and the tests on 32-bit platforms.
go get github.com/xo/okage@v0.7.1The same results on arm64 and s390x
On arm64 and s390x, the Go compiler fuses a multiply and an add into one instruction, even across statements. The fused result can differ in the last bit from the result on amd64, where the compiler does not fuse. okage requires the same results on each platform (D16), so each product that feeds an add is now rounded first, with an explicit float64 or float32 conversion. The fault was in these places:
internal/crmath: the double-double arithmetic of sin, cos, tan, atan2 and pow. An unrounded product broke the arithmetic, so some results differed in the last bit, such aspow(2, 10), which gave 1023.9999999999998. The transforms ofsvguse these functions.internal/kurbo:SolveCubic,SolveQuadratic, the products ofAffineand the ITP solver.- The cubic and quadratic solvers of
path64in the root package. svg: the offsets of the gradients of COLR glyphs, the lighting filters, the angles of markers, text on a path and the alignment of a view box.html: the layout of tables.lottie: the shapes, the easing, the repeaters, the trim paths, the gradient stops, and the effects of thePixmapSink.
The results on amd64 do not change. The calls of math.FMA that port mul_add of Rust stay fused, as Rust does.
32-bit tests
The test of Composition.Image compiles where an int has 32 bits, and internal/lottiecompat has a test, so that TinyGo builds a test program for each package for wasip1.
v0.7.0
This release adds the helpers that a program needs to load and show Lottie files (D44).
go get github.com/xo/okage@v0.7.0New API in lottie
| API | What it does |
|---|---|
Detect(head []byte) bool |
Reports whether the start of a file is a Lottie document. Each of the top-level keys fr, ip, op, w and h must hold a number. The start can be cut short at any byte |
IsDotLottie(head []byte) bool |
Reports whether the data is a zip archive, and so a dotLottie archive |
OpenDotLottie(r io.ReaderAt, size int64) |
Reads a dotLottie archive. Animations holds the sorted paths of its documents, and FS, Data and Parse give its files |
Load(data []byte) |
Parses a Lottie document, or the first document of a dotLottie archive |
Composition.FrameCount, FrameDuration, Duration |
Count the frames and give their times |
Composition.Image(n, w, h int) |
Draws frame n into a new *image.RGBA of w by h pixels. The composition is scaled to fill the image |
The root package adds the sentinel errors ErrLottieEmpty and ErrLottieDotLottie.
The code comes from the Lottie decoder of the image viewer iv, which keeps only the parts that are particular to a viewer. The rendering of a frame is the same as in v0.6.1.
v0.6.1
This release makes lottie draw a frame much faster.
go get github.com/xo/okage@v0.6.1Speed
PixmapSink made a pixmap and a mask of the size of the target for each layer, and composited each layer through the high-precision pattern pipeline of tiny-skia. Now:
- A layer keeps the rectangle that its draws touch, and
PopLayercomposites only that rectangle. A mode that clears the target where the layer is transparent, such as source-in, clears the rest of its clip without blending. - The normal mode and the Porter-Duff modes composite with a direct loop on premultiplied 8-bit pixels. It gives the same result as
DrawPixmapof tiny-skia within 2 in each channel. The other blend modes still useDrawPixmap. - A clip that is a rectangle on the pixel grid needs no mask.
- The pixmaps of the layers come from a pool, and are reused across layers and frames.
For one frame at 1024x1024:
| File | v0.6.0 | v0.6.1 |
|---|---|---|
| Noto rocket | 195 ms, 46.6 MB | 9 ms, 5.5 MB |
| star | 26 ms | 4.5 ms |
| Noto fire | 100 ms | 39 ms |
The frames are the same as in v0.6.0, and the test against ThorVG still passes for each sampled frame of the 879 Noto animated emoji. A file with many gradients is still slower than ThorVG, because tiny-skia fills a gradient with more than two stops in its high-precision pipeline (D35).
v0.6.0
This release adds the package lottie, which renders Lottie animations with okage (D41). It is a port of velato, and it draws as ThorVG does where velato differs (D43).
go get github.com/xo/okage@v0.6.0lottie
c, err := lottie.Parse(data)
if err != nil {
return err
}
pm, _ := okage.NewPixmap(uint32(c.Width), uint32(c.Height))
m := pm.AsMut()
err = lottie.RenderFrame(c, c.Frames[0], lottie.IdentityAffine, &m)Parsereads a Lottie file into aComposition.RenderFramedraws a frame onto an okage pixmap.- A
Rendererdraws onto anySink, the interface of velato for a renderer.PixmapSinkis the sink that draws with okage. It draws the effects Fill and Tint. - The test module compares
lottiewith velato through the Rust oracle, and with ThorVG throughxo/lottie, on the 879 Noto animated emoji. With the differences of D42 and D43 off,lottiegives the same calls to its sink as velato on every file. Each of the 4,395 sampled frames is within the tolerance of D43 of ThorVG.
Differences from velato
lottie draws as ThorVG where velato differs (D43): 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, stroke dashes, and a matte source with the blend mode multiply.
Renderer.MergePaths draws merge paths of modes 2 to 5 by compositing (D42). It is off by default, because ThorVG and velato draw a merge path as a compound path.
Not done
Expressions, the Gaussian blur and the drop shadow in PixmapSink, image assets and text layers. docs/BACKLOG.md lists them.
Other changes
internal/kurbo adds Affine, PathEl, PathSeg, Rect, Ellipse, RoundedRect, SolveCubic and the extrema of a quadratic Bezier.
v0.5.2
This release makes the fallback of text choose an emoji font for an emoji that the first font does not draw as an emoji (D40).
go get github.com/xo/okage@v0.5.2Fallback
- A character with U+FE0F, the selector that asks for the emoji form, now falls back to an emoji font when its font has no color glyph for it. For example, with Noto Sans first, "©️" and "™️" now draw with the color emoji font, as a browser draws them. A plain "©" stays in the text font.
- An emoji sequence that a font draws as several glyphs, because the font has no ligature for it, now falls back to a font that draws it as one emoji.
- A run that has only such a cluster to fix stays in its font. Only that cluster moves to the emoji font.
The fallback ranks each cluster as missing, not emoji or drawn, and takes the glyphs of a fallback font only when they rank better. An emoji sequence is found by ranges of characters (U+FE0F, U+20E3, the tags and U+1F000 to U+1FAFF), because go-text keeps its emoji data in an internal package. This is a deliberate difference from upstream. It applies to ShapeText and to <text> elements. When resvg changes its fallback, okage removes the code of D39 and D40 and ports the change of upstream, as D40 says.
Upstream
okage now follows resvg up to 5bdbae64, the release of resvg v0.50.0. That commit changes only versions and the changelog.