Release 0.3

Release v0.3.0 is out of the oven.

It is mainly a maintenance release, dropping support for Go < 1.16, and preparing for DVI support via the new dvi package.

dvi

dvi is a new package that implements encoding and decoding DVI documents.

More informations about the DVI standard can be found here:

The main entry point of the dvi package is:

// Dump reads r until EOF and calls f for each decoded DVI command.
func Dump(r io.Reader, f func(cmd Cmd) error) error

Other useful types are Font and Program. Program is a compiled representation of a stream of DVI commands, suitable for execution on a dvi.Machine.

A typical use would be:

vm := dvi.NewMachine(dvi.WithContext(ctx), dvi.WithLogOutput(w))
raw, err := os.ReadFile("some.dvi")
if err != nil {
	return fmt.Errorf("could not read DVI program file: %w", err)
}

prog, err := dvi.Compile(raw)
if err != nil {
	return fmt.Errorf("could not compile DVI program: %w", err)
}

err = vm.Run(prog)
if err != nil {
	return fmt.Errorf("could not interpret DVI program: %w", err)
}

cmd/dvi-dump

dvi-dump is a new command that displays the content of a DVI file in a human readable format or JSON.

The human readable format should be exactly the same than the official dvitype command from TeX Live.

$> dvi-dump -h
Usage of dvi-dump:
  -json
    	enable JSON output
  -texmf string
    	path to TexMF root

$> dvi-dump ./testdata/hello_golden.dvi
numerator/denominator=25400000/473628672
magnification=1000;       0.00006334 pixels per DVI unit
' TeX output 1776.07.04:1200'
Postamble starts at byte 1290.
maxv=43725786, maxh=30785863, maxstackdepth=2, totalpages=1
Font 36: cmti10---loaded at size 655360 DVI units 
Font 23: cmbx10---loaded at size 655360 DVI units 
Font 12: cmsy10---loaded at size 655360 DVI units 
Font 6: cmmi10---loaded at size 655360 DVI units 
Font 0: cmr10---loaded at size 655360 DVI units 
 
42: beginning of page 1 
87: push 
level 0:(h=0,v=0,w=0,x=0,y=0,z=0,hh=0,vv=0) 
88: down3 -917504 v:=0-917504=-917504, vv:=-58 
92: pop 
[...]