1signature OUT_DVI = 2sig 3 val setChar : BasicTypes.charCode -> unit 4 val putChar : BasicTypes.charCode -> unit 5 val setRule : BasicTypes.dist * BasicTypes.dist -> unit 6 val putRule : BasicTypes.dist * BasicTypes.dist -> unit 7 val right : BasicTypes.dist -> unit 8 val down : BasicTypes.dist -> unit 9 val push : unit -> unit 10 val pop : unit -> unit 11 val font : FontTypes.fontNr -> unit 12 val fontDef : FontTypes.fontNr -> unit 13 val fontDefs : FontTypes.fontNr list -> unit 14 val bop : int * int -> unit 15 val eop : unit -> unit 16 val pre : int -> unit 17 val post : int -> int * int * int -> unit 18 val postpost : int -> unit 19 val tail : int -> unit 20end 21(*----------*) 22 23structure OutDvi: OUT_DVI = 24struct 25 open BasicTypes; open FontTypes 26 open OutHigh 27 open Distance; open FontVector 28 29 val instr = outNat1 30 31 fun instrArg code arg = (instr code; outNat1 arg) 32 33 fun setChar ch = if ch < 128 then instr ch else instrArg 128 ch 34 val putChar = instrArg 133 35 36 fun rule code (a, b) = (instr code; outInt4 a; outInt4 b) 37 val setRule = rule 132 38 val putRule = rule 137 39 40 val right = outInstrV 142 41 val down = outInstrV 156 42 43 val push = fn () => instr 141 44 val pop = fn () => instr 142 45 46 fun font f = instr (171 + f) 47 48 fun fontDef nr = 49 let val (fam, s) = Vector.sub (famSizeVector, nr) 50 val size = distInt s 51 fun cmName RM = "cmr" | cmName MI = "cmmi" 52 | cmName SY = "cmsy" | cmName EX = "cmex" 53 val fileName = cmName fam ^ Int.toString s 54 in instrArg 243 nr; outZero 4; outInt4 size; outInt4 size; 55 outZero 1; outString fileName 56 end 57 58 fun fontDefs [] = () 59 | fontDefs (h :: t) = (fontDef h; fontDefs t) 60 61 fun bop (pageNr, prevPos) = 62 ( instr 139; outInt4 pageNr; outZero 36; outInt4 prevPos) 63 64 val eop = fn () => instr 140 65 66 val version = fn () => outNat1 2 67 val numDen = fn () => (outInt4 25400000; outInt4 473628672) 68 val banner = fn () => outString "Reinhold Heckmann's Formula Formatter" 69 70 fun pre mag = 71 ( instr 247; version (); numDen (); outInt4 mag; banner () ) 72 73 fun trailer 0 = () 74 | trailer n = (instr 223; trailer (n - 1)) 75 76 fun post mag (pageNr, prevPos, maxLevel) = 77 ( instr 248; outInt4 prevPos; 78 numDen (); outInt4 mag; 79 outInt4 (distInt (10 * 72)); (* maxVSize *) 80 outInt4 (distInt ( 7 * 72)); (* maxWidth *) 81 outNat2 maxLevel; outNat2 pageNr ) 82 83 fun postpost postPos = 84 ( instr 249; outInt4 postPos; version (); trailer 3 ) 85 86 fun tail ownPos = trailer (4 - ownPos mod 4) 87 88end 89