Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I often need to convert text files to PDF from the command line. I currently use enscript, a2pdf, cupsfilter, etc. The feature I'm missing is the ability to use an OS X font instead of one of the "standard Unix" fonts. I'm particularly interested in the AmericanTypewriter font. Is there an existing tool to do that or perhaps an Apple Script? If not, are there any other ideas?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

The solution is to create an afm version of the font you want to use which is American-typewriter for the enscript program to create with.

What you need to do is grab a copy of the AmericanTypewriter font. Which is located at /Library/Fonts/AmericanTypewriter.ttc

Next obtain and run the program ttf2pt1. Copy the output file that you can name atw.afm to enscript's afm directory located at /usr/share/enscript/afm.

Edit the "font.map" file located in /usr/share/enscript/afm

Add in the AmericanTypewriter font to the list.

AmericanTypewriter         atw
AvantGarde-Demi            agd
...                        ...

Lastly re-run the enscript and choose the new font, process as you would normally after that but now including the AmericanTypewriter font.

enscript -f "AmericanTypewriter12" -p postScriptOutputfile yourFile.txt
share|improve this answer
1  
A modification of your procedure worked for me. Thanks for pointing me in the right direction! ttf2afm did not want to convert a ttc file (which, as I understand, is a collection of ttf fonts). I needed to use ttf2pt1 and the procedure outline here: svn.savannah.gnu.org/svn/emacswiki/emacswikipages/EnscriptPrint –  Dominique Apr 19 '12 at 15:21
    
Glad you were able to get it work, I updated the answer above accordingly to reflect your finding. –  MrDaniel Apr 19 '12 at 15:35

If you have some basic LaTeX knowledge (and a working LaTeX installation), I strongly recommend you to take a look at Fletcher Penney's Multimarkdown, an extended Markdown interpreter, which has a great customizable feature of converting text files to .tex –from there, it's obviously a short step to a beautiful .pdf document formatted in accordance with your needs.

Check Chapter 5 of the Multimarkdown manual on how to customize LaTeX output – you will need to install both Multimarkdown (installer) and the support files.

Then, nothing prevents you from using XeTeX instead of LaTeX, which will allow you to use the fontspec package to select any font installed on your system. I haven't actually tried, but it should be fairly easy to create a simple custom LaTeX template for Multimarkdown (without the Author & Title information and all that) to produce PDF output in the font of your choice.

share|improve this answer
    
Thank you. I am familiar with Markdown and LaTeX but it's not an option for me as I need to convert the files without changing them. And they predate Markdown. –  Dominique Apr 19 '12 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.