render#
Import |
|
Defined in |
|
Install |
|
Since |
0.1 |
Stability |
Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how. |
- scenet.emit.svg.render(core, *, metrics=None, fonts=None, live_text=False, id_prefix='', aria=True, embed=None, mono=False)[source]#
Render a compiled panel as a standalone SVG document.
- Parameters:
core (
PanelCore) – The compiled panel.metrics (
FontMetrics|None) – The regular face the lettering was measured in, in place of the shipped one, for a Core compiled with the samemetrics.fonts (
Mapping[str,FontMetrics] |None) – The declared fonts the lettering was measured in, by digest – whatCompileResult.fontsholds. Each facePanelCore.fontsnames must be here.live_text (
bool) – Emit lettering as<text>rather than glyph outlines.id_prefix (
str) – Put in front of everyidthe panel writes, and every reference to one. Nothing a single panel needs; it is what lets a strip hold several panels in one document, where ids must be unique. Empty by default, so a panel on its own is byte-identical to what it always was.aria (
bool) – Make the panel one image a screen reader can read, named with what it shows and then everything said in it, in reading order – seeaccessible_name().Falsewrites none of it, for anyone who post-processes the SVG: exactly what was written before it existed.embed (
Mapping[str,bytes] |None) – The supplied pictures’ bytes, by digest – whatCompileResult.imagesholds. Given, each picture is written into the SVG as adata:URI, and must be here; left out, it is linked by the path the document wrote, which a viewer reads from beside the SVG.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 whatpalette: monowould; seePanelCore.as_mono.
- Return type:
- Returns:
One SVG document, as text. The same Core and arguments give the same text.
- Raises:
RenderError – The Core was lettered in a font not handed back as
fonts, or a supplied picture is to be embedded and its bytes are not inembed.
Note
The renderer makes no layout decision: everything it draws is in the Core. Glyph outlines need no font where the SVG is shown;
live_textletters in<text>, which is smaller and selectable, and is only right where the font is installed.Example
>>> from scenet import compile_source, render >>> result = compile_source( ... "cast: {a: {reference: alice}}\nscript: [{say: {by: a, text: Hello.}}]" ... ) >>> svg = render(result.core, fonts=result.fonts) >>> svg.splitlines()[0] '<?xml version="1.0" encoding="UTF-8"?>' >>> svg == render(result.core, fonts=result.fonts) True
See also
render_debug, for why it looks like that.render_strip, for several panels in one SVG.render_pdf, for print.Added in version 0.10: The
id_prefixparameter.Added in version 0.11: The
fontsparameter.Added in version 0.12: The
ariaparameter.Added in version 0.12: The
embedparameter.Added in version 0.13: The
monoparameter.