~sbinet/star-tex

5f7eb3fff0e13e3f7ca2a8c8d3b73986ab9eb680 — Sebastien Binet 4 months ago 01f5074
dvi: add Init(*CmdPre,*CmdPost) to Renderer interface

Renderers need the information stored in the prelude/postamble of DVI
documents to infer scaling, maximum width/height in pixels, etc...

Signed-off-by: Sebastien Binet <s@sbinet.org>
2 files changed, 6 insertions(+), 2 deletions(-)

M dvi/dvi.go
M dvi/machine.go
M dvi/dvi.go => dvi/dvi.go +4 -2
@@ 20,6 20,7 @@ import (

// Renderer defines the protocol to draw a DVI document.
type Renderer interface {
	Init(pre *CmdPre, post *CmdPost)
	BOP(bop *CmdBOP)
	EOP()



@@ 29,8 30,9 @@ type Renderer interface {

type nopRenderer struct{}

func (nopRenderer) BOP(cmd *CmdBOP) {}
func (nopRenderer) EOP()            {}
func (nopRenderer) Init(pre *CmdPre, post *CmdPost) {}
func (nopRenderer) BOP(cmd *CmdBOP)                 {}
func (nopRenderer) EOP()                            {}

func (nopRenderer) DrawGlyph(x, y int32, font Font, glyph rune, c color.Color) {}
func (nopRenderer) DrawRule(x, y, w, h int32, c color.Color)                   {}

M dvi/machine.go => dvi/machine.go +2 -0
@@ 106,6 106,8 @@ func (m *Machine) run(p Program, ip int) error {
		eop = false
	)

	m.rdr.Init(&p.pre, &p.post)

	p.r.SetPos(beg)
	op := opCode(p.r.PeekU8())
	if op != opBOP {