Skip to main content

read_svg_viewport_px

Function read_svg_viewport_px 

Source
pub fn read_svg_viewport_px(path: &Path) -> Option<(u32, u32)>
Expand description

SVG viewport size in CSS px, the way a browser takes it: the root width/height (a unitless value is CSS px), falling back to the viewBox only when the lengths are absent or relative (%). None when neither is usable, so the caller omits the dimensions and lets the browser size it.

Basis for imagewidth/imageheight in LaTeXML::Post::Graphics. The viewBox is only a coordinate system, not the rendered size; preferring it under-sized SVGs whose lengths disagreed with it (issue #696, reported by the LaTeXML maintainer). Not parity-relevant: Perl parses no SVG — it renders via Image::Magick, whose raster follows width/height, not the viewBox (Util/Image.pm:86-97); pdftocairo/mutool are our own beyond-Perl PDF→SVG pipeline, absent from Perl.