typstrx 0.1.0
typstrx: ^0.1.0 copied to clipboard
Typst document viewer for Flutter, backed by the native Rust Typst compiler, with high-resolution viewport rendering, text selection, and link navigation.
0.1.0 #
Initial release.
- Compile Typst source strings with the embedded Rust Typst compiler, including diagnostics with source locations
- Viewport-based high-resolution page rendering
TypstViewerwidget with pan/zoom, text selection, and links- Embedded default fonts + custom font registration
@previewpackage downloads with local cachingTypstDocument.exportPdf({tagged})for generation-checked vector PDF export.taggeddefaults totrue(matching typst-pdf's own default, writing a structure tree for accessibility/PDF-UA); passfalsefor an embedded fragment that will be stamped into another document, whose own structure tree wouldn't describe the final fileTypstPageView, a host-controlled, single-page, transparent Typst surface for canvases/notebooks that embed rendered content inline instead of showing a paginated document — sized to its compiled content, with no pan/zoom of its ownTypstSession.compileFragment/updateFragmentSource+TypstFragmentOptionsto compile Typst source as a content-sized, transparent embedded page; diagnostics and editor analysis offsets are mapped back to the caller's own source, so a host never accounts for the generated page preambleTypstTextSelection/TypstTextPosition/TypstTextSelectionRectandTypstViewerController.selection/TypstViewerParams.onSelectionChangedso a host can read or react to a rendered-text selection directly instead of only copying itTypstViewerParams.pageColor/showSelectionToolbar/enableNavigation/rasterBackgroundColor, letting a host disable typstrx's own page background, copy toolbar, and pan/zoom gestures when it's driving those itself (used byTypstPageView)TypstViewerController.currentRasterScale/currentRasterDpi/lastRender/cacheBytesfor reading back the actual on-screen rasterization resolution and render cost liveTypstViewerParams.maxRenderDpi/previewDpi(DPI-based; replace the earlier pixels-per-pointmaxRenderScale/previewScaleCap) to size rasterization quality directly in DPI.previewDpiis now a fixed baseline (rasterized regardless of current zoom, like pdfrx'sonePassRenderingScaleThreshold) rather than an adaptive cap; the zoom-adaptive tile tier (maxRenderDpi) takes over once the current zoom needs more resolution than that baseline providesTypstViewerParams.fixedRasterDpito pin every render (both tiers) to a constant DPI regardless of zoom, for comparing the fixed-quality vs. adaptive-quality rasterization models hands-onTypstViewerParams.tileScaleFactorto scale the zoom-adaptive tile resolution up or down relative to what the current zoom strictly needs- Clipped rasterization: a tile is now rendered straight into a tile-sized
buffer instead of rasterizing the whole page and cropping, via a vendored,
modified copy of
typst-render(third_party/typst-render-clip, Apache-2.0 — see itsNOTICE.md). Rendering the visible window now costs roughly what the viewport costs rather than growing with the page area times the square of the zoom: measured on a text-heavy A4 page, a viewport tile went from 7ms at 144 DPI / 22ms at 500 DPI / 103ms at 720 DPI to ~3ms flat across that range. TheRenderTooLargepixel budget now bounds the tile actually allocated rather than the page's virtual size, so an extreme zoom no longer fails TypstViewerParams.maxRenderDpinow defaults to576.0(was288.0), and is a quality ceiling rather than a limit keeping render cost boundedTypstViewerParams.renderDelaynow defaults to 16ms (was 80ms), since a discarded tile render no longer costs tens of milliseconds- The visible hi-res tile is now rendered before neighbouring pages' full-page previews, instead of queueing behind them
- Hi-res tiles now survive leaving the viewport and are evicted by the image cache budget (farthest page first) like previews, so panning back to a page reuses its tile instead of re-rendering it
- Adaptive tile DPI snaps up to discrete rungs, so a range of zoom levels reuses one cached tile instead of re-rendering on every gesture frame