Render API
Renderers consume already-paginated Page values. Registry discovery does not
import optional rendering backends until selected.
glyphive.render
Named render formats for already-paginated glyphive pages.
DEFAULT_DOCX_FONT = DEFAULT_MONO_FONT
module-attribute
DEFAULT_MONO_FONT = 'Consolas'
module-attribute
DEFAULT_PAGE_MARGIN_PT = 36.0
module-attribute
DEFAULT_PDF_FONT = 'dejavu-sans-mono'
module-attribute
FORMATS = frozenset(RenderFormat.names())
module-attribute
HORIZONTAL_ALIGNMENTS = frozenset({'left', 'center', 'justify'})
module-attribute
MINIMAL_PAGE_MARGIN_PT = 12.0
module-attribute
__all__ = ['FORMATS', 'DEFAULT_MONO_FONT', 'DEFAULT_PDF_FONT', 'DEFAULT_DOCX_FONT', 'DEFAULT_PAGE_MARGIN_PT', 'MINIMAL_PAGE_MARGIN_PT', 'HORIZONTAL_ALIGNMENTS', 'RenderFormat', 'available', 'get', 'lines_per_page_for', 'names', 'render']
module-attribute
RenderFormat
Bases: ABC
Base class for stateless, no-argument render formats.
name
class-attribute
__init_subclass__(**kwargs)
Source code in src/glyphive/render/_base.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
available()
classmethod
Source code in src/glyphive/render/_base.py
46 47 48 49 50 51 52 | |
geometric_payload_capacity(*, font=None, font_size=11.0, page_margin_pt=DEFAULT_PAGE_MARGIN_PT, character_spacing_pt=0.0, nsym_line=2)
Largest payload width that physically fits, ignoring the safety cap.
Unlike :meth:payload_capacity (clamped to the OCR-measured-safe row
width), this reports the uncapped geometric fit — used by
create --line-width max. Formats without physical font metrics
(text/docx/qr) return None, so max is rejected for them.
nsym_line is documented on :meth:payload_capacity.
Source code in src/glyphive/render/_base.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get(name)
classmethod
Source code in src/glyphive/render/_base.py
54 55 56 57 58 59 60 61 62 63 | |
is_available()
classmethod
Source code in src/glyphive/render/_base.py
65 66 67 | |
names()
classmethod
Source code in src/glyphive/render/_base.py
42 43 44 | |
payload_capacity(*, font=None, font_size=11.0, page_margin_pt=DEFAULT_PAGE_MARGIN_PT, character_spacing_pt=0.0, nsym_line=2)
Return the largest fitting codec payload width, if measurable.
Formats without reliable physical font metrics return None and
creation retains the conservative 60-character wire row. nsym_line
(default 2, matching create's default) is the per-line Reed-
Solomon parity budget being encoded with -- a format with physical
font metrics must reserve room for that optional field's extra
printed characters.
Source code in src/glyphive/render/_base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
render(pages, out, *, font=None, font_size=11.0, page_margin_pt=DEFAULT_PAGE_MARGIN_PT, horizontal_alignment='left', character_spacing_pt=0.0)
abstractmethod
Render already-paginated pages.
Source code in src/glyphive/render/_base.py
128 129 130 131 132 133 134 135 136 137 138 139 140 | |
available()
Source code in src/glyphive/render/__init__.py
52 53 | |
get(name)
Source code in src/glyphive/render/__init__.py
44 45 | |
lines_per_page_for(font_size, *, page_height_pt=792.0, page_margin_pt=DEFAULT_PAGE_MARGIN_PT)
Source code in src/glyphive/render/__init__.py
56 57 58 59 60 61 62 63 64 65 66 67 68 | |
names()
Source code in src/glyphive/render/__init__.py
48 49 | |
render(pages, out, fmt, *, font=None, font_size=11.0, page_margin_pt=DEFAULT_PAGE_MARGIN_PT, horizontal_alignment='left', character_spacing_pt=0.0)
Resolve fmt and delegate one time to its registered implementation.
Source code in src/glyphive/render/__init__.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |