render_page#

Import

from scenet import render_page

Defined in

scenet.emit.page (source)

Install

pip install scenet

Since

0.10

Stability

Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how.

scenet.emit.page.render_page(page, panels, *, live_text=False, debug=False, fonts=None, aria=True, embed=None, mono=False)[source]#

Render one page as a standalone SVG document.

Parameters:
  • page (PageCore) – The page: its size and where each panel’s frame is.

  • panels (Mapping[str, PanelCore]) – Every panel’s compiled Core, by name. Each one named by a frame must be here, compiled at that frame’s size.

  • live_text (bool) – Emit lettering as <text> rather than glyph outlines.

  • debug (bool) – Place each panel’s diagnostic overlay instead of the panel.

  • fonts (Mapping[str, FontMetrics] | None) – The declared fonts the panels were lettered in, by digest – what Book.fonts holds.

  • aria (bool) – Make the page a named group of panels a screen reader reads in order. False writes none of it. An overlay never has it.

  • embed (Mapping[str, bytes] | None) – The supplied pictures’ bytes, by digest – what Book.images holds – to write into the SVG. Left out, each picture is linked by the path its document wrote.

  • mono (bool) – Draw every value as its grey and ignore its colour, as for a black-and-white edition. Every decision was made on the grey, so this draws exactly what palette: mono would; see PanelCore.as_mono.

Return type:

str

Returns:

The page, as SVG.

Raises:

RenderError – A page places a panel panels does not hold, a Core names a font not given as fonts, or a picture is to be embedded and its bytes are not in embed.

Note

A page is drawn at its own size, in page units; each panel at its frame. Nothing is laid out here: the frames are the Page Core’s.

Example

>>> from scenet import compile_book, render_page
>>> book = compile_book(
...     "cast: {a: {reference: alice}}\n"
...     "pages: [{tiers: [{panels: [one]}]}]\npanels: {one: {}}"
... )
>>> cores = {name: result.core for name, result in book.panels.items()}
>>> 'viewBox="0 0 2000 3000"' in render_page(book.pages[0], cores)
True

See also

render_pages, for every page side by side. render_pdf, for print.

Added in version 0.11: The fonts parameter.

Added in version 0.12: The aria parameter.

Added in version 0.12: The embed parameter.

Added in version 0.13: The mono parameter.