Skip to content

Use golang.org/x/image/vector directly#28

Merged
andydotxyz merged 1 commit intogo-text:mainfrom
redawl:golang_x_vector
Apr 17, 2026
Merged

Use golang.org/x/image/vector directly#28
andydotxyz merged 1 commit intogo-text:mainfrom
redawl:golang_x_vector

Conversation

@redawl
Copy link
Copy Markdown
Contributor

@redawl redawl commented Apr 17, 2026

When rasterx is used with Filler, it uses golang.org/x/image/vector rasterizer. We can improve performance by using the rasterizer directly. This saves on the conversions from Int26_6 to float etc.

Unfortunately, it doesn't draw pixel perfect to the old snapshot tests. IMO it is probably more accurate, since a lot of float operations are now gone (I can't tell the difference visually).

Benchmark:

redawl@workstation ~/projects/render $ benchstat /tmp/{old,new}.txt
goos: linux
goarch: amd64
pkg: github.com/go-text/render
cpu: AMD Ryzen 7 7800X3D 8-Core Processor
                           │ /tmp/old.txt │            /tmp/new.txt             │
                           │    sec/op    │   sec/op     vs base                │
DrawString/Lorem_Ipsum-16     2.275m ± 0%   1.388m ± 0%  -38.98% (p=0.000 n=10)
DrawString/Arabic_Ipsum-16    4.262m ± 1%   2.501m ± 0%  -41.32% (p=0.000 n=10)
DrawString/Hello_World-16     272.1µ ± 1%   206.3µ ± 1%  -24.18% (p=0.000 n=10)
geomean                       1.382m        894.8µ       -35.25%

@benoitkugler
Copy link
Copy Markdown
Contributor

Looks very good to me, and the new tests snapshots are OK.

Copy link
Copy Markdown
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can barely tell the difference but could be persuaded that the latter is a tad sharper.
Either way the performance improvement is good news.

It will break all our golden masters in Fyne too - but these things do happen some times, we can group a few together for the next big release.

@andydotxyz andydotxyz merged commit 35796c2 into go-text:main Apr 17, 2026
3 checks passed
@redawl redawl deleted the golang_x_vector branch April 17, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants