// Rulers. / A horizontal ruler is drawn from the point 0,0 into positive x and y, / half a unit (0.5 inch or cm) + 18 points high. / len is the length of the ruler in units (inches or cm). / ppu is the points per unit (72 per inch or 72%2.54 per cm). / ticks is an inverted list of tick mark lengths (2 = .5 units high) ruler.generic:{[doc;len;ppu;ticks] / pdfw.ruler.generic rise:18+_.5*ppu inc:ppu%#ticks path.moveto[doc;0,rise] path.lineto[doc;(len*ppu;rise)] {l:ppu%ticks path.moveto[doc;(inc*x;rise)] path.lineto[doc;(inc*x;rise-l[x!#ticks])]}'!_1+len*#ticks path.paint[doc;`stroke] text.begin[doc] font.add_type1[doc;`Helvetica;`WinAnsiEncoding] text.font[doc;`Helvetica;14] text.move[doc;0 2] {sw:#s:\$x cw:14*556%1000 adj:cw*sw%2 text.move[doc;(-adj;0)] text.show[doc;s] text.move[doc;(ppu+adj;0)]}'!1+_ len text.end[doc] } ruler.inch:{[doc;len] / pdfw.ruler.inch ruler.generic[doc;len;72;2 32 16 32 8 32 16 32 4 32 16 32 8 32 16 32]} ruler.cm:{[doc;len] / pdfw.ruler.inch ruler.generic[doc;len;72%2.54;2 8 8 8 8 4 8 8 8 8]}