Skip to main content

Module render

Module render 

Source
Expand description

Render a formula to a gpui image — the display primitive (the ratex-gtk4 analog).

model → LaTeX → RaTeX layout → display list → ratex-render raster (PNG) → decode → BGRA → gpui RenderImage. RaTeX only exposes a PNG encoder (not the raw pixmap), so we round-trip through PNG for now; a pixmap accessor (or a small fork) would skip the re-decode. RaTeX rasters black-on-opaque-white; we recolor to the host’s text color on a transparent background (a pixel’s darkness becomes the glyph alpha), so a formula blends into any theme.

Structs§

Rendered
A rasterized formula plus its logical (pre-DPR) size in px.

Constants§

PAD
Logical padding (px) RaTeX leaves around the formula. The view offsets caret/slot geometry by this much, since the same value feeds RenderOptions::padding.

Functions§

render_latex
Render raw LaTeX to a gpui image — the display path for a $$…$$ block, which has no edit model. Glyphs are painted in color (the host’s text color) on a transparent background. None if the LaTeX fails to parse / lay out / rasterize.
render_latex_to_png
Render raw LaTeX to PNG file bytes (black on white) at the given font size and DPR. Suitable for writing directly to a .png file.
render_latex_to_svg
Render raw LaTeX to an SVG string at the given font size.
render_row
Render a row to a gpui image at font_size px/em and dpr device-pixel-ratio. None if the row’s LaTeX fails to parse / lay out / rasterize.