Hasty Briefsbeta

Bilingual

Replacing WebView2 print-to-PDF with an embedded Typst engine (Rust)

a day ago
  • #PDF Export
  • #Typst
  • #Rust
  • Inkwell, a desktop Markdown editor, initially had PDF export only on Windows due to reliance on WebView2's COM interface.
  • Typst, a Rust typesetting engine, enabled cross-platform PDF export by replacing browser-based printing with a library-based approach.
  • Integration with Typst involved implementing the World trait to provide necessary resources like fonts and assets, without filesystem dependencies.
  • Markdown-to-Typst conversion facilitated source-level translation, enhancing features like clickable cross-references in PDFs.
  • LaTeX math translation required handling syntax differences, such as implicit multiplication, to ensure accurate rendering.
  • Mermaid diagrams were handled via in-memory SVG storage, avoiding temp files and ensuring consistent hashing across languages.
  • Fonts were embedded directly into the binary, guaranteeing consistent typography and offline functionality.
  • The new export system eliminated platform-specific code, improved output quality, and made PDF generation testable.
  • Typst proved effective for embedding document generation, though translation from source formats like Markdown requires additional effort.