Configurable font size in PDF

This commit is contained in:
Peter Gillich 2024-03-15 19:00:16 +01:00
parent 8087055b50
commit 036593fbc8
2 changed files with 36 additions and 0 deletions

View File

@ -62,6 +62,7 @@ The build for the above Docker image can be audited at <https://hub.docker.com/r
Requirements:
- Make
- Ruby
- `gem install bundler`
- `bundle install`
@ -79,6 +80,33 @@ BOOK_SLUG='sre_book' ./generate.sh
BOOK_SLUG='srw_book' ./generate.sh
```
### PDF options
Any option can be passed to `pandoc` by `PDF_OPT_` prefix, for example:
```sh
PDF_OPT_GEOMETRY=margin=1.5cm \
PDF_OPT_DOCUMENTCLASS=extbook \
PDF_OPT_FONTSIZE=14pt \
PDF_OPT_MAINFONT=LiberationSerif-Regular.ttf \
PDF_OPT_MAINFONTOPTIONS=BoldFont=LiberationSerif-Bold.ttf,ItalicFont=LiberationSerif-Italic.ttf,BoldItalicFont=LiberationSerif-BoldItalic.ttf \
PDF_OPT_MONOFONT=LiberationMono-Regular.ttf \
PDF_OPT_MONOFONTOPTIONS=BoldFont=LiberationMono-Bold.ttf,ItalicFont=LiberationMono-Italic.ttf,BoldItalicFont=LiberationMono-BoldItalic.ttf \
PDF_OPT_SANSFONT=LiberationSans-Regular.ttf \
PDF_OPT_SANSFONTOPTIONS=BoldFont=LiberationSans-Bold.ttf,ItalicFont=LiberationSans-Italic.ttf,BoldItalicFont=LiberationSans-BoldItalic.ttf \
BOOK_SLUG=sre_book ./generate.sh
```
Default options passed to `pandoc` in `generate.sh` are overloaded by `PDF_OPT_` prefix, see `PDF_OPT_GEOMETRY` in above example.
Fonts in above axample are packed to `fonts-liberation2` on **Ubuntu**.
See more details:
* <https://pandoc.org/MANUAL.html#fonts>
* <https://ctan.org/pkg/extsizes>
* <https://ctan.org/pkg/fontspec>
# Known Issues
- metadata is not complete. There are just too many authors

View File

@ -12,6 +12,13 @@ export ${BOOKS[${BOOK_SLUG^^}]}
# Common vars.
IMGS_DOMAIN="lh3.googleusercontent.com"
PDF_OPTIONS=()
for i in ${!PDF_OPT_*}; do
declare -n val=$i
key=${i#PDF_OPT_}
PDF_OPTIONS+=("-V" "${key,,}=${val}");
done
# Make sure that links are relative \
# # Remove the /sre/ directories
# Save stuff in html/ directory
@ -96,6 +103,7 @@ pandoc --from=html \
-V subparagraph \
-V geometry=margin=2cm \
-V fig_caption=false \
${PDF_OPTIONS[@]} \
--columns=60 \
complete.html