hi there,
I’ve just tagged daktilo@v0.3.1
:
It’s a Go package that uses a Cgo package wrapping a simple-minded FFI around a couple of Typst crates, mostly statically compiled.
package daktilo_test
import (
"bytes"
"fmt"
"log"
"strings"
"codeberg.org/sbinet/daktilo"
)
func ExampleCompilePDF() {
dst := new(bytes.Buffer)
err := daktilo.CompilePDF(dst, strings.NewReader(`#set document(
date: datetime(year:2009,month:11,day:10), // for reproducibility
author: "daktilo",
)
#set page(width: 200pt, height: 300pt)
#set text(font: "New Computer Modern", weight: 450)
#show raw: set text(font: "New Computer Modern Mono", weight: 450)
= H1
== H2
=== H3
Hell·o from *Typ·st* and _Go_.
$ sum_(k=1)^n k = (n(n+1)) / 2 $
List:
- item a
- item b
Enumeration:
+ item a
+ item b
*Bye.*
`))
if err != nil {
log.Fatal(err)
}
fmt.Printf("PDF: %d bytes.\n", len(dst.Bytes()))
// Output:
// PDF: 16694 bytes.
}
I plan to expand a bit the exported Rust-FFI to allow producing PNGs and SVGs, taking fonts from the system and better error reporting (right now, the error is exposed to Go as a dumb string).
I am a very new Rust programmer so the plans above may not come to fruition just about now
(also, if you have constructive criticism about my Rust style, I’ll gladly consider it)