Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created December 3, 2022 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/104e301e0aecf6e2065c9918ac6eae3c to your computer and use it in GitHub Desktop.
Save zr-tex8r/104e301e0aecf6e2065c9918ac6eae3c to your computer and use it in GitHub Desktop.
SATySFi: A simple 100000-page document
let text-box-board w h ib =
let (tw, th, _) = get-natural-metrics ib in
let gtxt = draw-text ((w -' tw) *' 0.5, (h -' th) *' 0.5) ib in
inline-graphics w h 0pt (fun p -> [shift-graphics p gtxt])
let text-board ctx w h fname fsize str =
let ctx = ctx |> (set-font-size fsize)
|> (set-font Latin (fname, 1., 0.)) in
let ib = read-inline ctx (embed-string str) in
text-box-board w h ib
let number-board ctx n =
let ib = text-board ctx 100pt 100pt `Junicode` 24pt (arabic n) in
line-break true true ctx (ib ++ inline-fil)
let-inline ctx \dummy-math _ = inline-nil
let make-document body =
let ctx = get-initial-context 100pt (command \dummy-math) in
page-break (UserDefinedPaper (100pt, 100pt))
(fun _ -> (|
text-origin = (0pt, 0pt); text-height = 100pt;
|))
(fun _ -> (|
header-origin = (0pt, 0pt); header-content = block-nil;
footer-origin = (0pt, 0pt); footer-content = block-nil;
|))
(body ctx)
let make-body ctx n =
let-rec part s e =
if s >= e then number-board ctx s
else
let m = s + (e - s) / 2 in
(part s m) +++ (part (m + 1) e)
in
part 1 n
in
make-document (fun ctx -> (make-body ctx 100000))
@zr-tex8r
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment