Saturday, 8 June 2013

PhD week 66: LaTeX fonts

As part of my research, I will be making labels that indicate the type status of a number of weevil specimens. To create these, I have adapted my previous method of creating specimen labels in LaTeX to include a coloured background. The result of this is that I need to make the font on the labels bigger and bolder.

Unfortunately, because of the idiosyncratic way that I had established my fonts in the document, this ended up being not as trivial as checking out the TeX font catalogue. Instead I wanted to get an idea of what fonts were available on my system, and set about trying to create a font sampler of my very own.

While it wasn't difficult to get a list of the fonts on my computer (using the advice given at StackExchange), it became somewhat more tricky to get an idea of what they looked like. Attempting to compile a test document revealed two errors: The first was that some fonts could not be loaded:

"Font xxxx not loadable: Bad metric (TFM) file"
In addition, some that passed the first test, threw a second error when compiled by themselves:
"mktexpk: don't know how to create bitmap font for xxxx"

A quick email to the texhax mailing list quickly elicited some useful responses, including a very useful code fragment that gets around the first error. The second one was a little harder to overcome. Updating my map file (as suggested by another StackExchange post) didn't seem to do the trick, and messing around in the man pages of mktexpk and related programs didn't suggest any possibilities to one as unfamiliar with the programs as I am.

The breakthrough came when I had the realisation that I could extract the names of the fonts directly from the map file itself. Using this in conjunction with the code fragment mentioned above, I was able to get a document that compiled correctly when broken into three parts of c. 3000 fonts to get around size and space limitations.

I did encounter the error

"pdfTeX error: (file xxxxx.pfb): cannot open Type 1 font file for reading"
which I solved by manually removing the offending lines from the .tex document. There (thankfully!) weren't many of these, so this was not a particularly arduous step. If you try and replicate this though, you have been warned! If you figure out how to get around this, please let me know.

I used R (via Sweave) to extract the names of the fonts from the map file and to create the tex file. Undoubtedly other languages could do the same thing, but I chose to stick with what I'm familiar with. The file is available from gitHub

PILN Soundbites
FAO report: Edible insects. Future prospects for food and feed security
Where to buy tango music
NHBS: Relentless Evolution by John Thompson

1 comment:

almostakbl company said...

صبابين قهوة بالرياض يقوموا بتقديم أعلى مستوى من الخدمة الراقية في الأفراح والمناسبات بكل أشكالها ولا قدر الله العزاء فمنذ اليوم لا تتعب نفسك وترهقها بالاعتناء بالضيوف فضيوفك الكرام هم ضيوفنا وسوف نحرص على راحتهم جيدا من حيث الضيافة التي لا مثيل لها وأيضا تذوق طعم رائع من القهوة العربية ، من المعروف أن العزائم والأفراح تحتاج إلى توع خاص من الإعدادات وهنا في صبابين قهوة بالرياض نعمل على تقديم حسن ضيافة في حفلات التخرج والختان وجلسات الشعر فإذا أردت التميز أمام الضيوف تواصل معنا على أرقام الهاتف .
مباشرين قهوة بالرياض
قهوجيين بالرياض
مباشرين قهوة بجدة
صبابين قهوة بالرياض
صباب قهوة
صبابين قهوة بجدة