Wednesday, February 17, 2010

Random Setup Things for Mac

From BrainLog, instructions for getting Ctrl-left and Ctrl-right working like you expect in the terminal:

  • From the Terminal menu, select Window Settings..., then select "Keyboard" from the dropdown menu.
  • Click on "control cursor left" from the menu, then click the Edit button.
  • Click the little "delete" button until the text box is empty. Now press ESC, then "b"; the box should now contain "\033b". Click OK.
  • Do the same for "control cursor right," using ESC then "f" as the character sequence.

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.

Wednesday, February 10, 2010

Installing the MinionPro Tex Package

I have recently gone through the somewhat difficult process of installing the MinionPro package for use with TeX / LaTeX on my Mac, but now it works. I followed the nice instructions on the nice instructions available through this blog:

http://carlo-hamalainen.net/blog/?p=8

But I found I needed a little fiddling. Here's what I did:


cd ~/Desktop

texmf_folder=~/Library/texmf/

curl http://mirror.ctan.org/fonts/mnsymbol.zip > mnsymbol.zip

unzip mnsymbol.zip
cd mnsymbol/tex
latex MnSymbol.ins
mkdir -p $texmf_folder/tex/latex/MnSymbol/
mkdir -p $texmf_folder/fonts/source/public/MnSymbol/
mkdir -p $texmf_folder/doc/latex/MnSymbol/
cp MnSymbol.sty $texmf_folder/tex/latex/MnSymbol/MnSymbol.sty
cd ..
cp source/* $texmf_folder/fonts/source/public/MnSymbol/
cp MnSymbol.pdf README $texmf_folder/doc/latex/MnSymbol/
mkdir -p $texmf_folder/fonts/map/dvips/MnSymbol
mkdir -p $texmf_folder/fonts/enc/dvips/MnSymbol
mkdir -p $texmf_folder/fonts/type1/public/MnSymbol
mkdir -p $texmf_folder/fonts/tfm/public/MnSymbol
cp enc/MnSymbol.map $texmf_folder/fonts/map/dvips/MnSymbol/
cp enc/*.enc $texmf_folder/fonts/enc/dvips/MnSymbol/
cp pfb/*.pfb $texmf_folder/fonts/type1/public/MnSymbol/
cp tfm/* $texmf_folder/fonts/tfm/public/MnSymbol/

sudo mktexlsr
sudo updmap-sys --enable MixedMap MnSymbol.map

curl http://mirror.ctan.org/fonts/minionpro/scripts.zip > scripts.zip
mkdir minionpro-scripts
cd minionpro-scripts
unzip ../scripts.zip

find /Library/Fonts/ -iname '*minion*pro*otf' -exec cp -v '{}' otf/ ';'
sudo apt-get install lcdf-typetools
./convert.sh

mkdir -p $texmf_folder/fonts/type1/adobe/MinionPro/
cp pfb/*.pfb $texmf_folder/fonts/type1/adobe/MinionPro/

# It turned out to be very important to get this 2.030 version; a mismatch gives missing characters!
curl https://lists.berlios.de/pipermail/minionpro-devel/attachments/20090814/4e956ea2/attachment.zip > enc-2.030-beta.zip
curl http://mirror.ctan.org/fonts/minionpro/metrics-full.zip > metrics-full.zip
curl http://mirror.ctan.org/fonts/minionpro/metrics-base.zip > metrics-base.zip
curl http://mirror.ctan.org/fonts/minionpro/metrics-opticals.zip > metrics-opticals.zip

cd $texmf_folder
unzip ~/Desktop/metrics-base.zip
unzip ~/Desktop/metrics-full.zip
unzip ~/Desktop/enc-2.030-beta.zip

sudo mktexlsr
sudo updmap-sys --enable MixedMap MnSymbol.map