This patch enhances the libgd-based terminals (e.g. png, and other gd variants) by adding full dashtype support and improving antialiasing quality.
For dashed lines, it introduces a PNG_dashtype() implementation that maps gnuplot’s built-in dashtypes (dash, dot, dash-dot, dash-dot-dot) and user-defined custom dash patterns into a gdImageSetStyle() array (color/transparent run lengths), scaled by both linewidth and the terminal’s dashlength factor. The code tracks dash phase across connected vectors so dashes remain continuous across polyline segments.
For TrueColor output with butt caps, dashed lines are rendered through a new custom antialiased dashed-line path because libgd’s gdStyled rendering does not antialias. A small AA rasterizer for thick segments is added, including buffering/flush logic to reduce visible “seam striping” when curves are approximated by many short segments. Axis/grid dotted rendering remains a special case as before.
I did not benchmark the performance impact directly, but solid "lw 1" lines should render as fast as before. I developed this patch because I needed to generate a large amount of PNG plots including dashed lines and the pngcairo terminal was orders of magnitude slower then the old png terminal, at least on my system.
Full disclosure: I used recent LLMs (Claude Opus 4.5 and OpenAI GPT 5.2) to help with the code generation.
As an example of what is possible with the new dashtype support, I have attached the output of the follwing example script:
Are patches still considered? Should I have posted this somewhere else?
I'm traveling and will have alook ar your patch when I return next week. In the meantime, just a question. IsYour code something that could be added to the libgd library itself? If so that would benefit not just gnuplot but all other users of the library. I have contributed fixes to libgd before so I know they are receptive.
Thanks for your contribution.
It would have been possible to add large parts of this patch directly to libgd, which indeed would have been the better solution, but gnuplot would still have to be patched to utilize the new capabilities. Additionally, the changes in how antialiasing with this patch works in general are significant and I found it quite unlikely that such a long-established library would adopt them.
Also, I do not have a lot of experience with these kind of libraries and although I have tested this patch quite a bit and think that I have solved most issues, the code is probably still not as clean as it should be for something like libgd.