pykello / racket-graphviz

Library to enable using graphviz in Racket programs
BSD 3-Clause "New" or "Revised" License
25 stars 3 forks source link

`dot->pict` produces different label layout compare to `dot -T` #9

Open wilbowma opened 4 years ago

wilbowma commented 4 years ago

I was trying to convert to using racket-graphviz over graphviz directly, but the graph produced differs in how labels are laid out.

#lang scribble/base

@(require graphviz)

@dot->pict[#<<#eos
digraph {

node [ shape="box" ]

/* The Languages */

L0 [label="Paren-x64"];
L1 [label="x64"];

/* The Passes */

edge [fontname="Courier"]

L0 -> L1 [label="generate-x64"];

L0 -> "integer" [label="interp-paren-x64"];
}
#eos
]

pict

On the other hand, when the same dot script is run with dot -Tpng meow.dot > meow.png meow

pykello commented 4 years ago

thanks for the report. looking into it.

wilbowma commented 4 years ago

FWIW, I experimented with different ways of building the pict:

(define (run-dot str format)
  (define cmd (string-append "dot -y -T" format))
  (match (process cmd)
    [(list stdout stdin pid stderr ctl)
     (write-string str stdin)
     (newline stdin)
     (close-output-port stdin)
     (cond [(eq? (ctl 'status) 'done-error) (error (port->string stderr))]
           [else stdout])]))

(require (only-in pict bitmap) racket/draw)
(define (dot->pict . rest)
  (bitmap (make-object bitmap% (run-dot (apply string-append rest) "png"))))

This worked okay, although I ended up using SVG output to include it in a Scribble document instead.