Skip to content

Commit

Permalink
Made Weasyprint use the Ubuntu font
Browse files Browse the repository at this point in the history
  • Loading branch information
frzb committed Jan 15, 2025
1 parent 39a198c commit e130392
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 6 deletions.
28 changes: 28 additions & 0 deletions input/css/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,31 @@
ul { @apply text-slate-700 text-base; }
span { @apply text-slate-700 text-base; }
}

@font-face {
font-family: 'Ubuntu';
src: local('./static/fonts/Ubuntu/Ubuntu-Light.ttf') format('ttf');
font-weight: 300;
font-style: normal;
}

@font-face {
font-family: 'Ubuntu';
src: local('./static/fonts/Ubuntu/Ubuntu-Regular.ttf') format('ttf');
font-weight: 400;
font-style: normal;
}

@font-face {
font-family: 'Ubuntu';
src: local('./static/fonts/Ubuntu/Ubuntu-Medium.ttf') format('ttf');
font-weight: 500;
font-style: normal;
}

@font-face {
font-family: 'Ubuntu';
src: local('./static/fonts/Ubuntu/Ubuntu-Bold.ttf') format('ttf');
font-weight: 700;
font-style: normal;
}
7 changes: 4 additions & 3 deletions input/templates/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}
body, .max-w-4xl {
font-family: Ubuntu;
background: none !important;
box-shadow: none !important;
padding: 9pt !important;
Expand Down Expand Up @@ -53,7 +54,7 @@
</head>
<body class="bg-slate-100 font-ubuntu font-normal">
<!-- Language Links -->
<div class="max-w-4xl mx-auto top-3 right-3 space-x-2 flex sm:p-0 p-3 items-center justify-end">
<div class="max-w-4xl mx-auto top-3 right-3 space-x-2 flex sm:p-0 p-3 items-center justify-end print:!hidden">
<a href="./index.html" class="no-underline">English</a>
<img src="./static/icons/language-icon.svg" class="h-10 w-10" alt="Select Language">
<a href="./index_de.html" class="no-underline">Deutsch</a>
Expand Down Expand Up @@ -139,7 +140,7 @@
<!-- Skills Section -->
<div class="mt-8">
<h2>Skills and Experience</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-2">
<div class="grid grid-cols-1 sm:grid-cols-2 print:!grid-cols-2 gap-x-2">
{% for skill in skills %}
<div class="p-[3px] border-b border-gray-300">
<div class="flex items-center justify-between">
Expand Down Expand Up @@ -168,7 +169,7 @@
</div>
</div>
<!-- Repo Links -->
<div class="max-w-4xl mx-auto top-3 right-3 space-x-2 flex sm:p-0 p-3 items-center justify-end">
<div class="max-w-4xl mx-auto top-3 right-3 space-x-2 flex sm:p-0 p-3 items-center justify-end print:!hidden">
<a href="https://github.com/frzb/resume" class="no-underline">Source code for generating this resume |</a>
<a href="https://github.com/frzb/resume/commit/{{ short_git_sha }}" class="no-underline">Rev: {{ short_git_sha }}</a>
</div>
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from watchdog.events import FileSystemEventHandler
from jinja2 import Environment, FileSystemLoader, select_autoescape
from weasyprint import HTML
from weasyprint.text.fonts import FontConfiguration


class ResumeHandler(FileSystemEventHandler):
Expand Down Expand Up @@ -38,7 +39,8 @@ def create_output(self):
data = self.load_data(f"./input/{file}", self.include_private_data)
output_html_path = self.render_template(data, file)
self.tailwindcss_build()
HTML(output_html_path).write_pdf(f"./output/{name}.pdf")
font_config = FontConfiguration()
HTML(output_html_path).write_pdf(f"./output/{name}.pdf", stylesheets=["https://fonts.googleapis.com/css2?family=Ubuntu:wght@100;300;400;500;700&display=swap"], font_config=font_config)

def on_closed(self, event):
print(event)
Expand Down
2 changes: 1 addition & 1 deletion static/css/tailwind.css

Large diffs are not rendered by default.

Binary file added static/fonts/Ubuntu/Ubuntu-Bold.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-BoldItalic.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-Italic.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-Light.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-LightItalic.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-Medium.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-MediumItalic.ttf
Binary file not shown.
Binary file added static/fonts/Ubuntu/Ubuntu-Regular.ttf
Binary file not shown.
4 changes: 3 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
module.exports = {
content: ['./index.html'],
theme: {
extend: {},
extend: {
ubuntu: ['Ubuntu', 'sans-serif'],
},
},
plugins: [],
}
Expand Down

0 comments on commit e130392

Please sign in to comment.