On printing via Blurb’s PDF to Book: Part 5
“Troy”, who blipped in, made a comment and then disappeared, mentioned something called “xelatex” and how “lots of great fonts should be easy to use”. I’d never heard of XeLaTeX before, but I looked into it and it looked like a pretty nifty piece of software: “a typesetting system based on a merger of Donald Knuth’s TeX system with Unicode and modern font technologies”. Basically, it’s a version of LaTeX that can produce a PDF directly, and together with the fontspec package can use and embed any TrueType and OpenType fonts you have lying around. Well, the difficulty of using a variety of fonts was my only real complaint about using LaTeX to produce the book; otherwise I was thrilled with it–so much easier than all the manual layout I’d done in Scribus. So this weekend I thought I’d better take a look at xelatex and see if there was anything to it.
I’m a huge open-source fan, but I acknowledge that sometimes the path using open source tools can have significant hurdles. In any case I was prepared to make a modicum of effort at trying to get my Chickens, Anyone? book done with a TrueType font (I have a huge selection lying around) and published via the xelatex tool chain. The first part, getting xelatex installed, turned out to be remarkably easy. I’m running Ubuntu Linux, and a quick search via synaptic revealed that it was in the repositories. A couple clicks later, a quick change in the Makefile from pdflatex to xelatex and I was processing the book into a PDF with xelatex.
The second hurdle was figuring out how to use the TT font in the document. The examples using fontspec looked simple, it was basically a one liner to name the font you want to use, but you need to know the name first. A quick search revealed the otfinfo tool (part of the lcdf-typetools package, also in the Ubuntu repositories), which, when run on a bunch of .ttf files will tell you their names. It turns out that the names are just the common ones, such as “Garamond”, “Times New Roman”, etc. Simple. A quick edit to add the fontspec line, another make and boom, I’m cranking out PDFs now with great looking fonts and the fonts embedded.
The third hurdle was the first and only real roadblock, and it was a doozy, but I figured it out in the end. Blurb requires a kind of PDF called a PDF/X-3. It’s basically a PDF 1.3 version with some restrictions on the content and requiring certain tags and profiles to be present. When I was using pdflatex, I found a nice example with google that showed how to embed the proper strings in the latex file using special directives to make the resulting PDF smell like a PDF/X-3. Well, with xelatex I needed to get those same strings into the file, but the directives that I had used with pdflatex weren’t defined. It turns out that it can be done, and quite simply, but there is just not a whole lot of documentation out there right now on xelatex. I searched every nook and cranny of the web for that info, using clue after clue to get me closer and closer, but the info remained elusive. I was beginning to think that it could not be done without writing some kind of script to postprocess the PDF, when I finally stumbled upon a reference to a different piece of software, one that was probably an ancestor of xdvipdfmx (the piece of the xelatex tool chain that actually produces the PDF). It was a manual, and it was gold. It had lots of PDF directives defined and they seemed to be identical to those used in xelatex. I tried the two that looked right for the job–Bingo–Bob was now my uncle.
The final proof was getting the Blurb PDF to Book site to accept the PDFs all the way through the preflight check and then ordering the book. And now yet again another version of the book is ordered and I will report on it when it arrives. I took the opportunity to use some additional knowledge I had gained about the latex geometry package to tweak things a bit so it should even look a bit nicer.
All in all, I’m very tickled. I now have a way to crank out photo books with extremely precise specifications, using any TrueType or OpenType fonts I want, and using text markup instead of painful hours behind a GUI. In the next couple of days I’ll drop a new release of the latex templates onto the download area, incorporating these changes. I’ll make a brief post about it that at that time, so if you are interested in the updated templates, stay tuned.