bitpressio / docker-for-php-developers-errata

Reported errata for https://bitpress.io/docker-for-php-developers/
13 stars 0 forks source link

The fonts are not displayed correctly in Ubuntu #1

Closed axelitus closed 4 years ago

axelitus commented 6 years ago

Using the fancy PDF version in Ubuntu displays the fonts incorrectly and thus hinders the book's readability, especially the code listings: screenshot-20180522083351-643x588

axelitus commented 6 years ago

I'm running Ubuntu 18.04 bionic and the issue is that the missing fonts are being replaced by DejaVu Sans (by default): screenshot from 2018-05-22 09-51-19

To fix this issue we need to tell Ubuntu to substitute the missing fonts with a more appropriate font so that the book displays better. As the OperatorMono font is not free, we will be using a replacement font. I found out that the free and open source font FiraCode is an excellent font replacement for OperatorMono, so we'll be using that.

First, install the missing fonts running the following command in the terminal:

$ sudo apt-get install ttf-mscorefonts-installer fonts-firacode

After that, we need to tell Ubuntu to substitute the missing fonts for the ones we want instead of the default DejaVu Sans. For that, we need to create/edit the file ~/.config/fontconfig/fonts.conf and place this gist contents inside. This ill tell Ubuntu what fonts to use instead of the ones we don't have (feel free to experiment and set your preferred fonts instead). The next step is to reset the font cache, run the following command in a terminal:

$ fc-cache

Finally, just open the document and the new fonts should be in place and the book should be displayed beautifully as it was intended: screenshot from 2018-05-22 11-00-14 screenshot from 2018-05-22 11-07-05

So far I can confirm this works if using Evince or Okular for displaying PDF files.

axelitus commented 6 years ago

For the missing font SourceSerifPro-Semibold you could go with SourceSerifPro-Bold or maybe @paulredmond can embed the missing font an release an updated PDF version with it (embedding the other fonts would be difficult due to copyright issues I think).

paulredmond commented 6 years ago

Thanks so much @axelitus! I think you mentioned the PDF was working correctly on Windows? I thought I had embedded the font correctly, but I am trying to get a feel for if I have any copyright/embedding issues. I thought I had set up the export correctly, trying to debug other platforms.

This is the first report I've seen with the issue so far, thanks for you help uncovering and reporting info about it!

axelitus commented 6 years ago

Actually, I have to say that in Windows it is also not displayed as intended (what I mean is unless you have purchased and installed the OperatorMono font in your system, the code listings won't appear as you designed them).

But nevertheless, in Windows, the readability is not affected, at least with my current setup (Windows 10 Pro + Adobe CC [plus certainly some additional fonts installed by it]).

I'm attaching a screenshot so you can see how it is rendered in Windows: 2018-05-22_13h49_33 2018-05-22_13h48_56

So I wasn't even aware that it was not the font you used originally, and maybe that's why you didn't have any issues with it. I'm thinking that you would be better off with a font that you could embed or that is available as the PDF14 standard fonts (meh :disappointed:). FireCode is a nice replacement.

axelitus commented 6 years ago

It would be so awesome to have something like web fonts for PDF files :thinking:... but so insecure hehe

paulredmond commented 6 years ago

Ya, I might have to switch to Fira Code or something...ugh.

paulredmond commented 6 years ago

Thanks to your help, I am working on a PDF update with Fira Mono. I don't want to deal with ligatures and they are opinionated IMO (some people love them, others not so much) and they risk some readability in book form.

For those coming to this issue down the road, Gumroad will be updated with a new version of the PDF with all fonts embedded properly (including Fira Mono for code) as a free update to all purchasers.

paulredmond commented 6 years ago

For those coming to this issue, I've updated Gumroad with a new version of the "fancy" PDF. I love Operator Mono, but they do not allow embedding and I didn't want to do outlines.

I've updated the code font to Fira Mono. I chose plain Fira Mono because it feels similar to Operator, and I avoided Fira Code because ligatures are loved by some and hated by others. I feel that ligatures will only get in the way of readability, and since I was having PDF embedding issues, I didn't want to know/deal/care about ligatures in an embedded, cross-platform, cross-pdf-reader-thingy. đź‘Ť

pavel-mironchik commented 6 years ago

@paulredmond I recently got your book from Gumroad. I saw in your tweet that "basic" PDF is generated file and there is the "fancy" one with your custom design. I however see files "docker-for-php-developers-basic.pdf" and "docker-php-developers-full.pdf" and the last looks like this: screenshot_20180903_125751 Am I missing something? I use Okular on Kubuntu 18.04.

paulredmond commented 6 years ago

Is that the only place you’re seeing the font being weird? I may have missed a few spots converting the font, if you see it elsewhere feel free to post it here.

pavel-mironchik commented 6 years ago

Is that the only place you’re seeing the font being weird?

Nope, I found such font in:

Didn't read the book further page 85.

paulredmond commented 6 years ago

@pavel-mironchik yes, I see what you're saying. There are a couple places where the fonts were not converted from Operator to Fira. I am going to go through each listing and update, if you see any more, I'd appreciate if you can post it here! Thanks.

paulredmond commented 6 years ago

@pavel-mironchik thanks to your report, I was able to find it in one more listing, and in the chapter page numbers. Thank you so much for taking the time to submit your issues! 🎉

I don't have an ETA of when I will update the PDF in Gumroad, but the impact should be minimal until I update the file. Thanks again!

paulredmond commented 4 years ago

Releasing a new version of the PDF, Mobi, and ePub book soon. Please let me know if you still find any issues with font rendering in the Fancy custom PDF version. All other versions are rendered by Leanpub and shouldn't have any issues.