-
Notifications
You must be signed in to change notification settings - Fork 7
/
SetNode.sml
53 lines (43 loc) · 1.51 KB
/
SetNode.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
signature SET_NODE =
sig
open BasicTypes; open BoxTypes
val outChar: boxkind -> (fontNr * charCode) -> unit
val outRule: boxkind -> dim -> unit
val outKern: boxkind -> dist -> unit
val outGlue: boxkind -> glueParam -> glueSpec -> unit
end
(*----------*)
structure SetNode: SET_NODE =
struct
open BasicTypes; open BoxTypes
open Distance; open CharInfo
open OutHigh; open DviCmd
(* Invariant for horizontal stuff:
reference point -> end point = reference point + (0, width)
Invariant for vertical stuff:
upper left corner -> lower left corner
*)
(* Characters *)
fun outChar HBox info = SetChar info
| outChar VBox info =
( Down (charHeight info); PutChar info; Down (charDepth info) )
(* Rules *)
fun outRule HBox {height, depth, width} =
( Down depth; SetRule (height + depth, width); Up depth )
| outRule VBox {height, depth, width} =
let val vsize = height + depth
in Down vsize; PutRule (vsize, width) end
(* Kerns *)
fun outKern HBox = Right
| outKern VBox = Down
(* Glue *)
fun glueMult (r, ord) (d, ord') =
if ord = ord' then realMult (r, d) else zero
fun glueSize natural ({size, ...}: glueSpec) = size
| glueSize (stretching factor) {size, stretch, ...} =
size + glueMult factor stretch
| glueSize (shrinking factor) {size, shrink, ...} =
size - glueMult factor shrink
fun outGlue kind glueParam glueSpec =
outKern kind (glueSize glueParam glueSpec)
end