Skip to content

Commit

Permalink
fix: Use new fonts for PDFization
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed May 25, 2023
1 parent 65bd689 commit 99cb583
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ietf/doc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from lxml import etree
from typing import Optional, TYPE_CHECKING
from weasyprint import HTML as wpHTML
from weasyprint.text.fonts import FontConfiguration

from django.db import models
from django.core import checks
Expand Down Expand Up @@ -626,6 +627,7 @@ def pdfized(self):
stylesheets.append(finders.find("ietf/css/document_html_txt.css"))
else:
text = self.htmlized()
stylesheets.append("https://static.ietf.org/fonts/noto-sans-mono/import.css")

cache = caches["pdfized"]
cache_key = name.split(".")[0]
Expand All @@ -635,10 +637,12 @@ def pdfized(self):
pdf = None
if not pdf:
try:
font_config = FontConfiguration()
pdf = wpHTML(
string=text, base_url=settings.IDTRACKER_BASE_URL
).write_pdf(
stylesheets=stylesheets,
font_config=font_config,
presentational_hints=True,
optimize_size=("fonts", "images"),
)
Expand Down

0 comments on commit 99cb583

Please sign in to comment.