Monday, February 15, 2010

Changing Fonts in a PDF File

I tried an experiment this evening to see if a PDF can be successfully edited as a text-file, and the results are fairly promising. I wanted to achieve plots with all text in Minion Pro so they would match the body text in a LaTeX document I am preparing. I took the brute-force approach of performing replacing every instance of "Helvetica-Bold" with "MinionPro-Bold"; "Helvetica-BoldOblique" with "MinionPro-BoldItalic"; "Helvetica" with "MinionPro-Regular", etc. And it worked!

The only real problem with this method is that a PDF has the characters individually placed, so character spacing looks a little funky with the new font. Some characters take up more or less space between the two fonts. Even so, I thought this was a pretty neat trick.

On a related note, I was able to get ROOT to use an arbitrary font for internal display of plots. The program is supposed to be limited to the 14 fonts included in the font table (which is not modifiable), but you can game the system by simply replacing the font file with a different one. For example, you can navigate to $ROOTSYS/fonts/ and copy comic.ttf over all the arial*.ttf files. Now, whenever ROOT wants to use Arial (which is the default), it actually loads Comic Sans.

Now, the ideal would be for ROOT to magically gain the ability to export LaTeX files the way that some other programs like Matlab and gnuplot can, so that all the text is directly rendered by the pdflatex engine, giving the correct size and identical rendering. But I don't have my fingers crossed on that one. I think I can hack something pretty reasonable out of what I've found so far.

1 comment:

  1. King of Spades Casino | ShootingCasino.com
    The King of Spades casino offers 제왕카지노 a variety of games from multiple card 인카지노 games including Slots, Blackjack, Baccarat and 카지노사이트 Poker.

    ReplyDelete