fix: Use new fonts for PDFization (#5688)
This commit is contained in:
parent
66f1ba3088
commit
5f4dfb87b6
|
@ -14,6 +14,7 @@ from pathlib import Path
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
from weasyprint import HTML as wpHTML
|
from weasyprint import HTML as wpHTML
|
||||||
|
from weasyprint.text.fonts import FontConfiguration
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core import checks
|
from django.core import checks
|
||||||
|
@ -626,6 +627,7 @@ class DocumentInfo(models.Model):
|
||||||
stylesheets.append(finders.find("ietf/css/document_html_txt.css"))
|
stylesheets.append(finders.find("ietf/css/document_html_txt.css"))
|
||||||
else:
|
else:
|
||||||
text = self.htmlized()
|
text = self.htmlized()
|
||||||
|
stylesheets.append("https://static.ietf.org/fonts/noto-sans-mono/import.css")
|
||||||
|
|
||||||
cache = caches["pdfized"]
|
cache = caches["pdfized"]
|
||||||
cache_key = name.split(".")[0]
|
cache_key = name.split(".")[0]
|
||||||
|
@ -635,10 +637,12 @@ class DocumentInfo(models.Model):
|
||||||
pdf = None
|
pdf = None
|
||||||
if not pdf:
|
if not pdf:
|
||||||
try:
|
try:
|
||||||
|
font_config = FontConfiguration()
|
||||||
pdf = wpHTML(
|
pdf = wpHTML(
|
||||||
string=text, base_url=settings.IDTRACKER_BASE_URL
|
string=text, base_url=settings.IDTRACKER_BASE_URL
|
||||||
).write_pdf(
|
).write_pdf(
|
||||||
stylesheets=stylesheets,
|
stylesheets=stylesheets,
|
||||||
|
font_config=font_config,
|
||||||
presentational_hints=True,
|
presentational_hints=True,
|
||||||
optimize_size=("fonts", "images"),
|
optimize_size=("fonts", "images"),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue