diff --git a/.gitignore b/.gitignore index e47f97b..51556c3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ Desktop.ini # Build output and Go artifacts /build +# `go build` in the root writes the binary here. +/dot # Scratch / work-in-progress files # *.local diff --git a/CHANGELOG.md b/CHANGELOG.md index 77ce62f..ad854ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,14 +7,25 @@ command line interface described in `README.md`. ## [Unreleased] -## [1.2.0] - 2026-10-07 +## [1.2.0] - 2026-10-08 + +### Added + +- `-Txdot`: the layout with its drawing operations, as Graphviz's xdot. + `-Tdot` stays the layout with positions only. ### Changed -- The engine is forkcloser/go-graphviz v0.4.0. Text is measured with the +- The engine is forkcloser/go-graphviz v0.5.0. Text is measured with the fonts it is drawn in, the installed ones, as Graphviz's own `dot` does: labels fit their nodes, and the same graph can lay out slightly differently, in every output format, on machines with different fonts. +- PNG and JPEG are drawn the way Graphviz's Cairo renderer draws: lines + meet in mitred corners and end flat, where they were round; dashed lines + are six points on, six off, and dotted lines two on, six off, Graphviz's + lengths. A PNG render of a graph of about 40 nodes allocates 7 MB + instead of 320 MB and takes half the time. The binary no longer carries + `fogleman/gg` or `golang/freetype`. - Font names resolve as Graphviz resolves them (PostScript names, family and style words, metric-compatible substitutes), falling back to embedded Go fonts in regular, bold, italic and monospace. @@ -31,9 +42,14 @@ command line interface described in `README.md`. a blank page. - Characters the label's font lacks (Japanese, Chinese, Korean in a Latin font) are drawn from an installed font that has them, not as boxes. +- A node image named by an absolute path is drawn; it was silently left + out. A lossless or extended WebP node image, any WebP with alpha, is + sized as it is instead of failing the render as a page too large. +- An attribute the engine could not store (out of WebAssembly memory) + fails the render instead of being dropped. Details in go-graphviz's -[CHANGELOG](https://github.com/forkcloser/go-graphviz/blob/v0.4.0/CHANGELOG.md). +[CHANGELOG](https://github.com/forkcloser/go-graphviz/blob/v0.5.0/CHANGELOG.md). ## [1.1.1] - 2026-10-05 diff --git a/cmd/dot/main.go b/cmd/dot/main.go index f3a3aa8..6c62d8a 100644 --- a/cmd/dot/main.go +++ b/cmd/dot/main.go @@ -1,4 +1,4 @@ -// Command dot renders a Graphviz graph to dot, svg, png or jpg without a +// Command dot renders a Graphviz graph to dot, xdot, svg, png or jpg without a // native graphviz installation: the engine is go-graphviz's WASM build. // // Usage: @@ -28,7 +28,7 @@ const usage = `usage: dot [-K engine] [-T format] [-o path] [input] -K engine layout engine: dot (default), neato, fdp, sfdp, circo, twopi, osage, patchwork - -T format output format: dot (default), svg, png, jpg + -T format output format: dot (default), xdot, svg, png, jpg -o path output file (default: standard output) -V print the version -h print this help @@ -77,11 +77,14 @@ func layoutNamed(name string) (graphviz.Layout, bool) { } } -// formatNamed is the output format by the name -T takes. "dot" is graphviz's -// xdot: the layout written back as DOT, with the computed positions on it. +// formatNamed is the output format by the name -T takes, as Graphviz names +// them: "dot" is the layout written back as DOT with the computed positions +// on it, "xdot" that plus the drawing operations. func formatNamed(name string) (graphviz.Format, bool) { switch name { case "dot": + return graphviz.GV, true + case "xdot": return graphviz.XDOT, true case "svg": return graphviz.SVG, true @@ -97,7 +100,7 @@ func formatNamed(name string) (graphviz.Format, bool) { // parseArgs accepts graphviz's glued flags (-Tpng) as well as spaced ones, // which the standard flag package cannot do. func parseArgs(args []string) (options, error) { - opt := options{layout: graphviz.DOT, format: graphviz.XDOT} + opt := options{layout: graphviz.DOT, format: graphviz.GV} // A spaced value flag consumes the argument after it, so the loop moves // the index itself rather than ranging over the slice. diff --git a/cmd/dot/main_test.go b/cmd/dot/main_test.go index 045e2d3..5d64d1a 100644 --- a/cmd/dot/main_test.go +++ b/cmd/dot/main_test.go @@ -20,7 +20,7 @@ func TestParseArgs(t *testing.T) { want options err bool }{ - {nil, options{layout: graphviz.DOT, format: graphviz.XDOT}, false}, + {nil, options{layout: graphviz.DOT, format: graphviz.GV}, false}, { []string{"-Tpng", "-oout.png", "in.dot"}, options{layout: graphviz.DOT, format: graphviz.PNG, output: "out.png", input: "in.dot"}, @@ -31,8 +31,8 @@ func TestParseArgs(t *testing.T) { options{layout: graphviz.NEATO, format: graphviz.SVG, output: "out.svg", input: "-"}, false, }, - {[]string{"-h"}, options{layout: graphviz.DOT, format: graphviz.XDOT, help: true}, false}, - {[]string{"-V"}, options{layout: graphviz.DOT, format: graphviz.XDOT, version: true}, false}, + {[]string{"-h"}, options{layout: graphviz.DOT, format: graphviz.GV, help: true}, false}, + {[]string{"-V"}, options{layout: graphviz.DOT, format: graphviz.GV, version: true}, false}, {[]string{"-Tgif"}, options{}, true}, {[]string{"-Kbogus"}, options{}, true}, {[]string{"-o"}, options{}, true}, @@ -56,10 +56,11 @@ func TestRenderFormats(t *testing.T) { t.Parallel() magic := map[string]string{ - "dot": "digraph", - "svg": "