pub(crate) fn build_content_stream(
page_height_pt: f32,
page: &Page,
encodings: &HashMap<Font, DocEncoding>,
embedded_by_id: &HashMap<EmbeddedFontId, &EmbeddedFontPlan>,
) -> Result<Vec<u8>>Expand description
Build the per-page content stream. The layout engine measures baselines from the top of the page; PDF’s coordinate system is bottom-origin, so we flip once here.
Base14 runs encode through the planner’s per-face DocEncoding
(WinAnsi byte + /Differences remap; characters outside both
tiers silently render as ?). Embedded-font runs encode the
shaped glyph stream as big-endian u16 CIDs.
Image placements (raster XObjects) emit outside the text object
: BT/ET brackets only permit text operators, so each image
placement is wrapped in its own q ... Q save/restore pair before
the text block starts. Putting images first means subsequent text
can overlay (e.g. a caption beneath the image is unaffected, but
in-line annotations atop a figure would land on top).