diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500.woff b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500.woff
deleted file mode 100644
index 28e30b1..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500.woff2 b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500.woff2
deleted file mode 100644
index 8b30ffe..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500italic.woff b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500italic.woff
deleted file mode 100644
index 6c10f1b..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500italic.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500italic.woff2 b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500italic.woff2
deleted file mode 100644
index 6a81956..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-500italic.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700.woff b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700.woff
deleted file mode 100644
index af766f0..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700.woff2 b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700.woff2
deleted file mode 100644
index 757390b..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700italic.woff b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700italic.woff
deleted file mode 100644
index 17a6253..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700italic.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700italic.woff2 b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700italic.woff2
deleted file mode 100644
index 652b746..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-700italic.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-italic.woff b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-italic.woff
deleted file mode 100644
index 0271b04..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-italic.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-italic.woff2 b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-italic.woff2
deleted file mode 100644
index 9f0f6ba..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-italic.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-regular.woff b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-regular.woff
deleted file mode 100644
index fd9e361..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-regular.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-regular.woff2 b/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-regular.woff2
deleted file mode 100644
index d55b5cc..0000000
Binary files a/src/privatim/reporting/fonts/dm-sans-v6-latin-ext_latin-regular.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-italic.woff b/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-italic.woff
deleted file mode 100644
index 1b7c907..0000000
Binary files a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-italic.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-italic.woff2 b/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-italic.woff2
deleted file mode 100644
index c12a54b..0000000
Binary files a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-italic.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-regular.woff b/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-regular.woff
deleted file mode 100644
index 3349c0a..0000000
Binary files a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-regular.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-regular.woff2 b/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-regular.woff2
deleted file mode 100644
index 52aaa0f..0000000
Binary files a/src/privatim/reporting/fonts/dm-serif-display-v5-latin-ext_latin-regular.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-brands-400.eot b/src/privatim/reporting/fonts/fa-brands-400.eot
deleted file mode 100644
index 1ee7a56..0000000
Binary files a/src/privatim/reporting/fonts/fa-brands-400.eot and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-brands-400.svg b/src/privatim/reporting/fonts/fa-brands-400.svg
deleted file mode 100644
index 067be5c..0000000
--- a/src/privatim/reporting/fonts/fa-brands-400.svg
+++ /dev/null
@@ -1,3717 +0,0 @@
-
-
-
diff --git a/src/privatim/reporting/fonts/fa-brands-400.ttf b/src/privatim/reporting/fonts/fa-brands-400.ttf
deleted file mode 100644
index 032f907..0000000
Binary files a/src/privatim/reporting/fonts/fa-brands-400.ttf and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-brands-400.woff b/src/privatim/reporting/fonts/fa-brands-400.woff
deleted file mode 100644
index e6a44f8..0000000
Binary files a/src/privatim/reporting/fonts/fa-brands-400.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-brands-400.woff2 b/src/privatim/reporting/fonts/fa-brands-400.woff2
deleted file mode 100644
index c851402..0000000
Binary files a/src/privatim/reporting/fonts/fa-brands-400.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-duotone-900.eot b/src/privatim/reporting/fonts/fa-duotone-900.eot
deleted file mode 100644
index b4a9aa8..0000000
Binary files a/src/privatim/reporting/fonts/fa-duotone-900.eot and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-duotone-900.svg b/src/privatim/reporting/fonts/fa-duotone-900.svg
deleted file mode 100644
index 0c07fcc..0000000
--- a/src/privatim/reporting/fonts/fa-duotone-900.svg
+++ /dev/null
@@ -1,15328 +0,0 @@
-
-
-
diff --git a/src/privatim/reporting/fonts/fa-duotone-900.ttf b/src/privatim/reporting/fonts/fa-duotone-900.ttf
deleted file mode 100644
index bc8c92b..0000000
Binary files a/src/privatim/reporting/fonts/fa-duotone-900.ttf and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-duotone-900.woff b/src/privatim/reporting/fonts/fa-duotone-900.woff
deleted file mode 100644
index 09cc0ba..0000000
Binary files a/src/privatim/reporting/fonts/fa-duotone-900.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-duotone-900.woff2 b/src/privatim/reporting/fonts/fa-duotone-900.woff2
deleted file mode 100644
index ac0d45b..0000000
Binary files a/src/privatim/reporting/fonts/fa-duotone-900.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-light-300.eot b/src/privatim/reporting/fonts/fa-light-300.eot
deleted file mode 100644
index fd2cfc7..0000000
Binary files a/src/privatim/reporting/fonts/fa-light-300.eot and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-light-300.svg b/src/privatim/reporting/fonts/fa-light-300.svg
deleted file mode 100644
index 6244f7f..0000000
--- a/src/privatim/reporting/fonts/fa-light-300.svg
+++ /dev/null
@@ -1,12423 +0,0 @@
-
-
-
diff --git a/src/privatim/reporting/fonts/fa-light-300.ttf b/src/privatim/reporting/fonts/fa-light-300.ttf
deleted file mode 100644
index ea1f36c..0000000
Binary files a/src/privatim/reporting/fonts/fa-light-300.ttf and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-light-300.woff b/src/privatim/reporting/fonts/fa-light-300.woff
deleted file mode 100644
index da6981a..0000000
Binary files a/src/privatim/reporting/fonts/fa-light-300.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-light-300.woff2 b/src/privatim/reporting/fonts/fa-light-300.woff2
deleted file mode 100644
index fbdeaaa..0000000
Binary files a/src/privatim/reporting/fonts/fa-light-300.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-regular-400.eot b/src/privatim/reporting/fonts/fa-regular-400.eot
deleted file mode 100644
index c0bf92e..0000000
Binary files a/src/privatim/reporting/fonts/fa-regular-400.eot and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-regular-400.svg b/src/privatim/reporting/fonts/fa-regular-400.svg
deleted file mode 100644
index 407156a..0000000
--- a/src/privatim/reporting/fonts/fa-regular-400.svg
+++ /dev/null
@@ -1,11323 +0,0 @@
-
-
-
diff --git a/src/privatim/reporting/fonts/fa-regular-400.ttf b/src/privatim/reporting/fonts/fa-regular-400.ttf
deleted file mode 100644
index 2d03c19..0000000
Binary files a/src/privatim/reporting/fonts/fa-regular-400.ttf and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-regular-400.woff b/src/privatim/reporting/fonts/fa-regular-400.woff
deleted file mode 100644
index 012f42c..0000000
Binary files a/src/privatim/reporting/fonts/fa-regular-400.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-regular-400.woff2 b/src/privatim/reporting/fonts/fa-regular-400.woff2
deleted file mode 100644
index 70fc754..0000000
Binary files a/src/privatim/reporting/fonts/fa-regular-400.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-solid-900.eot b/src/privatim/reporting/fonts/fa-solid-900.eot
deleted file mode 100644
index ddbd2a5..0000000
Binary files a/src/privatim/reporting/fonts/fa-solid-900.eot and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-solid-900.svg b/src/privatim/reporting/fonts/fa-solid-900.svg
deleted file mode 100644
index 16984ad..0000000
--- a/src/privatim/reporting/fonts/fa-solid-900.svg
+++ /dev/null
@@ -1,9653 +0,0 @@
-
-
-
diff --git a/src/privatim/reporting/fonts/fa-solid-900.ttf b/src/privatim/reporting/fonts/fa-solid-900.ttf
deleted file mode 100644
index e6330e6..0000000
Binary files a/src/privatim/reporting/fonts/fa-solid-900.ttf and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-solid-900.woff b/src/privatim/reporting/fonts/fa-solid-900.woff
deleted file mode 100644
index 45f5cd5..0000000
Binary files a/src/privatim/reporting/fonts/fa-solid-900.woff and /dev/null differ
diff --git a/src/privatim/reporting/fonts/fa-solid-900.woff2 b/src/privatim/reporting/fonts/fa-solid-900.woff2
deleted file mode 100644
index dff46ed..0000000
Binary files a/src/privatim/reporting/fonts/fa-solid-900.woff2 and /dev/null differ
diff --git a/src/privatim/reporting/report.py b/src/privatim/reporting/report.py
index bc0cf52..a7b061f 100644
--- a/src/privatim/reporting/report.py
+++ b/src/privatim/reporting/report.py
@@ -2,14 +2,13 @@
from datetime import datetime
from io import BytesIO
from pathlib import Path
-
from babel.dates import format_datetime
-
from privatim.i18n import translate, _
from privatim.layouts.layout import DEFAULT_TIMEZONE
from privatim.utils import datetime_format
from pyramid.renderers import render
-from weasyprint import HTML # type: ignore
+from weasyprint import HTML, CSS # type: ignore
+from weasyprint.text.fonts import FontConfiguration # type: ignore
from typing import TYPE_CHECKING, Protocol
@@ -100,44 +99,37 @@ def build(self) -> PDFDocument:
class HTMLReportRenderer:
"""
Render meeting report with WeasyPrint, using HTML and CSS.
-
You can turn on logging for weasyprint to debug issues:
-
>>> import logging, sys
>>> logger = logging.getLogger('weasyprint')
>>> logger.setLevel(logging.DEBUG)
>>> logger.addHandler(logging.StreamHandler(sys.stdout))
-
"""
-
template = 'privatim:reporting/template/report.pt'
def render(
- self,
- meeting: 'Meeting',
- timestamp: str,
- request: 'IRequest'
+ self,
+ meeting: 'Meeting',
+ timestamp: str,
+ request: 'IRequest'
) -> bytes:
html = self.render_template(meeting, timestamp, request)
- return self.render_pdf(html)
+ return self.render_pdf(html, request)
def render_template(
- self,
- meeting: 'Meeting',
- timestamp: str,
- request: 'IRequest'
+ self,
+ meeting: 'Meeting',
+ timestamp: str,
+ request: 'IRequest'
) -> str:
"""Render chameleon report template."""
-
document_context = {'title': meeting.name, 'created_at': timestamp}
-
title = translate(
_(
"Protocol of meeting ${title}",
mapping={'title': document_context['title']},
)
)
-
ctx = {
'title': title,
'meeting': meeting,
@@ -147,12 +139,76 @@ def render_template(
}
return render(self.template, ctx)
- def render_pdf(self, html: str) -> bytes:
+ def render_pdf(self, html: str, request: 'IRequest') -> bytes:
"""
Render processed chameleon template as PDF.
"""
-
resource_base_url = Path.cwd() / 'privatim' / 'reporting'
buffer = BytesIO()
- HTML(string=html, base_url=str(resource_base_url)).write_pdf(buffer)
+
+ italic_font_name = 'dm-sans-v6-latin-ext_latin-500italic.woff'
+ italic_font_name_woff2 = 'dm-sans-v6-latin-ext_latin-500italic.woff2'
+ regular_font_name = 'dm-sans-v6-latin-ext_latin-500.woff'
+ regular_font_name_woff2 = 'dm-sans-v6-latin-ext_latin-500.woff2'
+ normal_font_name = 'dm-sans-v6-latin-ext_latin-regular.woff'
+ normal_font_name_woff2 = 'dm-sans-v6-latin-ext_latin-regular.woff2'
+ normal_italic_font_name = 'dm-sans-v6-latin-ext_latin-italic.woff'
+ normal_italic_font_name_wo2 = 'dm-sans-v6-latin-ext_latin-italic.woff2'
+ base_font_url = 'privatim:static/fonts/'
+
+ # Create URLs first
+ font_paths = {
+ 'regular': f'{base_font_url}{regular_font_name}',
+ 'regular_woff2': f'{base_font_url}{regular_font_name_woff2}',
+ 'italic': f'{base_font_url}{italic_font_name}',
+ 'italic_woff2': f'{base_font_url}{italic_font_name_woff2}',
+ 'normal': f'{base_font_url}{normal_font_name}',
+ 'normal_woff2': f'{base_font_url}{normal_font_name_woff2}',
+ 'normal_italic': f'{base_font_url}{normal_italic_font_name}',
+ 'normal_italic_woff2': f'{base_font_url}'
+ f'{normal_italic_font_name_wo2}',
+ }
+
+ font_urls = {
+ key: request.static_url(path) for key, path in font_paths.items()
+ }
+
+ font_config = FontConfiguration()
+ css_font_face = f'''
+ @font-face {{
+ font-family: 'DM Sans';
+ font-style: normal;
+ font-weight: 400;
+ src: url({font_urls['normal_woff2']}) format('woff2'),
+ url({font_urls['normal']}) format('woff');
+ }}
+ @font-face {{
+ font-family: 'DM Sans';
+ font-style: italic;
+ font-weight: 400;
+ src: url({font_urls['normal_italic_woff2']}) format('woff2'),
+ url({font_urls['normal_italic']}) format('woff');
+ }}
+ @font-face {{
+ font-family: 'DM Sans';
+ font-style: normal;
+ font-weight: 500;
+ src: url({font_urls['regular_woff2']}) format('woff2'),
+ url({font_urls['regular']}) format('woff');
+ }}
+ @font-face {{
+ font-family: 'DM Sans';
+ font-style: italic;
+ font-weight: 500;
+ src: url({font_urls['italic_woff2']}) format('woff2'),
+ url({font_urls['italic']}) format('woff');
+ }}
+ '''
+
+ css = CSS(string=css_font_face, font_config=font_config)
+ HTML(string=html, base_url=str(resource_base_url)).write_pdf(
+ buffer,
+ stylesheets=[css],
+ font_config=font_config
+ )
return buffer.getvalue()
diff --git a/src/privatim/reporting/template/report.pt b/src/privatim/reporting/template/report.pt
index 3c9b230..196b4ef 100644
--- a/src/privatim/reporting/template/report.pt
+++ b/src/privatim/reporting/template/report.pt
@@ -25,34 +25,7 @@
*/
/* dm-sans-regular - latin-ext_latin */
- @font-face {
- font-family: 'DM Sans';
- font-style: normal;
- font-weight: 400;
- src: local(''),
- url(../fonts/dm-sans-v6-latin-ext_latin-regular.woff2) format('woff2'),
- url(../fonts/dm-sans-v6-latin-ext_latin-regular.woff) format('woff');
- }
-
- /* dm-sans-italic - latin-ext_latin */
- @font-face {
- font-family: 'DM Sans';
- font-style: italic;
- font-weight: 400;
- src: local(''),
- url(../fonts/dm-sans-v6-latin-ext_latin-italic.woff2) format('woff2'),
- url(../fonts/dm-sans-v6-latin-ext_latin-italic.woff) format('woff');
- }
- /* dm-sans-500 - latin-ext_latin */
- @font-face {
- font-family: 'DM Sans';
- font-style: normal;
- font-weight: 500;
- src: local(''),
- url(../fonts/dm-sans-v6-latin-ext_latin-500.woff2) format('woff2'),
- url(../fonts/dm-sans-v6-latin-ext_latin-500.woff) format('woff');
- }
/* Global page settings. */
@page {
@@ -97,11 +70,14 @@
padding-left: 0;
}
+ .agenda-items-list p {
+ margin-left: 0.5cm;
+ }
+
img {
min-width: 5cm;
max-width: 5cm;
max-height: 3.5cm;
-
}
body {
@@ -133,12 +109,10 @@
+