Skip to content

Commit

Permalink
chore: move fonts CSS for PDF into a separate file
Browse files Browse the repository at this point in the history
This way it is easier to maintain and lint.
  • Loading branch information
nijel committed Nov 14, 2024
1 parent feb29ea commit d97197b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 4 additions & 12 deletions weblate_web/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,11 @@ def render_pdf(*, html: str, output: Path) -> None:
string=html,
url_fetcher=url_fetcher,
)
fonts_css = finders.find("pdf/fonts.css")
if fonts_css is None:
raise ValueError("Could not load fonts CSS")

Check warning on line 64 in weblate_web/pdf.py

View check run for this annotation

Codecov / codecov/patch

weblate_web/pdf.py#L64

Added line #L64 was not covered by tests
font_style = CSS(
string="""
@font-face {
font-family: Source Sans Pro;
font-weight: 400;
src: url("static:vendor/font-source/TTF/SourceSans3-Regular.ttf");
}
@font-face {
font-family: Source Sans Pro;
font-weight: 700;
src: url("static:vendor/font-source/TTF/SourceSans3-Bold.ttf");
}
""",
filename=fonts_css,
font_config=font_config,
url_fetcher=url_fetcher,
)
Expand Down
10 changes: 10 additions & 0 deletions weblate_web/static/pdf/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@font-face {
font-family: Source Sans Pro;
font-weight: 400;
src: url("static:vendor/font-source/TTF/SourceSans3-Regular.ttf");
}
@font-face {
font-family: Source Sans Pro;
font-weight: 700;
src: url("static:vendor/font-source/TTF/SourceSans3-Bold.ttf");
}

0 comments on commit d97197b

Please sign in to comment.