-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rasterization performance #47
Comments
font-rs is using the algorithm described here The method is fast for rasterizing but generates only a mask or gray map. Other operations like combining images are O(N²) since each pixel is processed. The method is thus good for rasterizing text which is dense and a small image size, not for general 2D graphics on big images. The package font-go is a proof of concept of a font rasterizer using the font-rs algorithm. The rasterizer algorithm is implemented in the vector package. The x/image/font package is using the x/image/vector package. The algorithm to flatten bézier curves in the vector package may be interesting to look at. I think it comes from FreeType. It looks simple and efficient. It may not be optimal in the number of line segments generated, but it is surely optimal to compute the number of steps of t when compared to the method described here. |
This library currently uses the Also see flattening: create the fewest amount of linear segments for quad/cube Béziers and arcs. |
Flattening has been implemented which is slightly better than Nigel Tao's version. Otherwise, improving rasterization performance is a high-priority but re-implementing a rasterizer is not. |
This may have improved dramatically with the fix for #334. In the future we may need to implement our own rasterizer for RGBA and NRGBA (for PNGs) images, with gamma correction and subpixel rasterization for text. |
Improve rasterization performance. How does FreeType perform? Why is the
vector
one slow?vector
: https://github.com/golang/image/tree/master/vectorexp
: https://github.com/golang/exp/blob/master/shiny/iconvg/rasterizer.gorasterx
: https://github.com/srwiley/rasterx for a combination ofvector
and FreeTypeMake sure the new rasterizer supports both fill types:
EvenOdd
andNonZero
(vector
does not supportEvenOdd
).EDIT: see the following links for some ideas.
font-rs
: https://medium.com/@raphlinus/inside-the-fastest-font-renderer-in-the-world-75ae5270c445, also see https://www.cryptologie.net/article/406/simd-instructions-in-go for implementing in GoEDIT: actually, Nigel Tao has an implementation of
font-rs
in Go here: https://github.com/google/font-go. It says in https://github.com/golang/image/blob/master/vector/vector.go thatfont-go
is proof of concept, but doesn't actually importvector
...?The text was updated successfully, but these errors were encountered: