Give every template its own assets: fonts, logos and icons, vector first, so that they print #8

Open
opened 2026-10-01 07:02:06 +00:00 by tiagoagueda · 0 comments
Owner

The list says: "Every template must hold its assets, so fonts, logos, icons, or other graphical elements can be printed. Vectorial graphics is always preferred."

What the core allows today

  • No files beside a template. A plugin has no static files: "A logo inside a plugin wheel is invisible to the static machinery, always" (src/postulo/plugins/logos.py in the core).
  • Nothing is fetched while drawing. WeasyPrint is given a fetcher that allows data: addresses only, and Chromium aborts every request (src/postulo/documents/pdf.py). The wiki's CVs states the rule: "its CSS inline, and anything else as a data: address".
  • Fonts are the server's. The image installs DejaVu and Noto, and a theme only names fonts: "the theme names fonts, the fonts are whatever the server happens to have".
  • The preview is stricter than the PDF. Its content-security policy allows data: images, but no data: font (font-src 'self'), no style attribute, and no <style> without the page's nonce, inside an inline SVG included.
  • No built-in theme has an image or a drawing.

So a template can inline a drawing or a data: image by hand today, but cannot bring a font that the preview shows, and has nowhere to keep a file. The rest waits for postulo/postulo#343.

What the plugin should do

  • Each template keeps its assets in the package beside it: fonts, logos, icons, rules and ornaments.
  • Vector first. Logos and icons are SVG, taking their colour from the text (currentColor) so they print in black and white. A raster image only where a vector cannot exist, at a resolution made for print.
  • Fonts under a licence that allows embedding and redistribution, the licence kept beside the font, and only the styles a template uses. Each font names the scripts it draws; for a script it lacks, the template falls back to the server's fonts and does not print boxes (postulo/postulo#74).
  • Nothing depends on colour or on a printed background, which many printers drop.
  • A list of every asset, its source and its licence, in the repository.
  • No words inside a graphic (#7).

Decisions

  • Before the core change. Recommended: templates ship with inline drawings and the server's fonts, and gain their own fonts when postulo/postulo#343 lands. Alternative: wait for it.
  • Subsetting fonts. Recommended: subset to the scripts the plugin's languages need, to keep each drawn document small, since assets are inlined into every one.

Needs from the core

postulo/postulo#343: a way for a theme to name a file in its own package and have it inlined, and a preview that shows what the PDF shows.

Done when

  • Each template's fonts, logos and icons are in the package, with their licences, and reach the PDF and the preview alike.
  • A template printed in black and white loses nothing a reader needs.
  • No request leaves the server while any template is drawn.

From the list of template improvements of 2026-09-30.

The list says: "Every template must hold its assets, so fonts, logos, icons, or other graphical elements can be printed. Vectorial graphics is always preferred." ## What the core allows today - **No files beside a template.** A plugin has no static files: "A logo inside a plugin wheel is invisible to the static machinery, always" (`src/postulo/plugins/logos.py` in the core). - **Nothing is fetched while drawing.** WeasyPrint is given a fetcher that allows `data:` addresses only, and Chromium aborts every request (`src/postulo/documents/pdf.py`). The wiki's *CVs* states the rule: "its CSS inline, and anything else as a `data:` address". - **Fonts are the server's.** The image installs DejaVu and Noto, and a theme only names fonts: "the theme names fonts, the fonts are whatever the server happens to have". - **The preview is stricter than the PDF.** Its content-security policy allows `data:` images, but no `data:` font (`font-src 'self'`), no `style` attribute, and no `<style>` without the page's nonce, inside an inline SVG included. - No built-in theme has an image or a drawing. So a template can inline a drawing or a `data:` image by hand today, but cannot bring a font that the preview shows, and has nowhere to keep a file. The rest waits for postulo/postulo#343. ## What the plugin should do - Each template keeps its assets in the package beside it: fonts, logos, icons, rules and ornaments. - **Vector first.** Logos and icons are SVG, taking their colour from the text (`currentColor`) so they print in black and white. A raster image only where a vector cannot exist, at a resolution made for print. - **Fonts under a licence that allows embedding and redistribution**, the licence kept beside the font, and only the styles a template uses. Each font names the scripts it draws; for a script it lacks, the template falls back to the server's fonts and does not print boxes (postulo/postulo#74). - **Nothing depends on colour or on a printed background**, which many printers drop. - A list of every asset, its source and its licence, in the repository. - No words inside a graphic (#7). ## Decisions - **Before the core change.** Recommended: templates ship with inline drawings and the server's fonts, and gain their own fonts when postulo/postulo#343 lands. Alternative: wait for it. - **Subsetting fonts.** Recommended: subset to the scripts the plugin's languages need, to keep each drawn document small, since assets are inlined into every one. ## Needs from the core postulo/postulo#343: a way for a theme to name a file in its own package and have it inlined, and a preview that shows what the PDF shows. ## Done when - Each template's fonts, logos and icons are in the package, with their licences, and reach the PDF and the preview alike. - A template printed in black and white loses nothing a reader needs. - No request leaves the server while any template is drawn. From the list of template improvements of 2026-09-30.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo-templates#8
No description provided.