fixed font embedding

This commit is contained in:
tmont 2024-11-14 13:57:39 -08:00
parent f0686e0a06
commit 0301a255fa
6 changed files with 13 additions and 11 deletions

View File

@ -15,16 +15,23 @@ To generate PDFs:
2. `mkdir -p rendered`
3. `node index.mjs`
Note that the fonts "Schibsted Grotesk" and "Sometype Mono" must be installed
on the system.
Also note that this uses Firefox instead of Chrome to generate the PDFs.
Chrome seems to embed the fonts as Type 3 fonts, which are bad for printing.
Firefox seems to embed them as TrueType or Type 1C, which are better.
```
tmont@thelio:~/code/sources-of-light (main +) node index.mjs
$ node index.mjs
processing 001-title.html...
generated PDF at /home/tmont/code/sources-of-light/rendered/001-title.pdf
processing 002-title2.html...
generated PDF at /home/tmont/code/sources-of-light/rendered/002-title2.pdf
processing 003-toc.html...
generated PDF at /home/tmont/code/sources-of-light/rendered/003-toc.pdf
processing 197-timeline.html...
generated PDF at /home/tmont/code/sources-of-light/rendered/197-timeline.pdf
processing 196-timeline.html...
generated PDF at /home/tmont/code/sources-of-light/rendered/196-timeline.pdf
```
Rendered pages will be in `rendered/`.

View File

@ -14,7 +14,8 @@ const files = fs.readdirSync(path.join(dirname, 'pages'))
.map(file => path.join(dirname, 'pages', file));
const browser = await puppeteer.launch({
executablePath: '/usr/bin/google-chrome',
browser: 'firefox',
executablePath: '/usr/bin/firefox',
});
const page = await browser.newPage();
@ -23,9 +24,7 @@ for (const file of files) {
console.log(`processing ${path.basename(file)}...`);
await page.goto(`file://${file}`, {
waitUntil: 'networkidle0',
});
await page.goto(`file://${file}`);
await page.pdf({
width: '9.25in',

View File

@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="../fonts/SchibstedGrotesk/style.css"/>
<style>
body {
margin: 0;

View File

@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8">
<title>Title 2</title>
<link rel="stylesheet" href="../fonts/SchibstedGrotesk/style.css"/>
<style>
body {
margin: 0;

View File

@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8">
<title>ToC</title>
<link rel="stylesheet" href="../fonts/SometypeMono/style.css"/>
<style>
body {
margin: 0;

View File

@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8">
<title>Timeline</title>
<link rel="stylesheet" href="../fonts/SchibstedGrotesk/style.css" />
<style>
body {
margin: 0;