quii / learn-go-with-tests

Learn Go with test-driven development
MIT License
21.56k stars 2.75k forks source link

Use monospace for all code examples in PDF #552

Open alaindet opened 2 years ago

alaindet commented 2 years ago

Hello, The PDF version of Learn Go with Tests should really use a monospace font for all code examples to ease the reading. Thank you.

enkeyz commented 2 years ago

Would be great! I can recommend Jetbrains Mono, which is an open-source font.

quii commented 2 years ago

Agreed, have no idea how 😂

enkeyz commented 2 years ago

Agreed, have no idea how joy

You can pass arguments to pandoc when you build the pdf: https://tex.stackexchange.com/questions/234786/how-to-set-a-font-family-with-pandoc

-V 'monofont:DejaVuSansMono.ttf' for example.

Be sure to read the font's license :)

quii commented 2 years ago

https://github.com/quii/learn-go-with-tests/tree/monospace-pdf

I don't have access to a non-m1 computer right now, although I will later this week

If anyone in this thread does have a non-ARM computer that can run ./build.books.sh and check the PDF from this branch, I'll merge.

alaindet commented 2 years ago

I tried to run the script by changing "Courier New" to "DejaVu Sans Mono" since I'm on Ubuntu and these warnings came out. When I tried to open the output PDF, no monospace was used for code sections anyway

[WARNING] Missing character: There is no 🤷 (U+1F937) (U+1F937) in font DejaVu Sans/OT:script=latn;l [WARNING] Missing character: There is no ️ (U+FE0F) (U+FE0F) in font Noto Sans CJK TC/OT:script=ha [WARNING] Missing character: There is no ✅ (U+2705) (U+2705) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ❓ (U+2753) (U+2753) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ❓ (U+2753) (U+2753) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ❓ (U+2753) (U+2753) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ❓ (U+2753) (U+2753) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ✅ (U+2705) (U+2705) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ✅ (U+2705) (U+2705) in font DejaVu Sans/OT:script=latn;la [WARNING] Missing character: There is no ✅ (U+2705) (U+2705) in font DejaVu Sans/OT:script=latn;la

alaindet commented 2 years ago

Ok I managed to make it work: move to main branch, just change meta.tex like this, no need for "monofont" variable

\setmonofont{DejaVu Sans Mono}