[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: installing fonts manually for tex



Ian Melnick <dazed@vonsteuben.cps.k12.il.us> said,
> Hello all,
> 
> I went through a lot of trouble trying to get the computer modern fonts
> installed correctly for dvips, etc, when I finally came across the
> tetex-extra package, which solved all my problems. My question is, using
> the downloadable cmps-unix.tar.gz file from ctan, how would I have
> installed this manaully? Is there a guide somewhere for installing pfb
> fonts, generating the maps properly, updating it with updmap, and
> getting it to *work*?

I just installed and started playing with LaTeX last Wednesday, and let
me tell you, coming from absolutely no knowledge about the system,
trying to get vector fonts to work with it was a hellish endeavor.

It actually took me close to two days of tinkering before I could get a
PDF to spit out actual vector text, despite following multiple
walkthroughs and trying command after command in my .tex document. I did
actually get it to work, though, and I want to be of some assistance.

As far as generating the font from a given TrueType or PostScript Type 1
font, I can't really help you there, but I can tell you what I did to
start writing documents that look decent and print very nicely...

First of all, for simplicity's sake, you're probably going to want to
stick with the font packages that are on CTAN. I've only been using the
Adobe fonts for the time being, mostly because they're very professional
and offer a variety of styles (serif, sans-serif, etc.).

Adobe fonts are found here:
http://www.ctan.org/tex-archive/fonts/psfonts/adobe/?preferredCTAN=tug.ctan.org&action=/tex-archive/fonts/psfonts/

Now, what you'll have to do is download the .tar.gz of each complete
font directory, you can do that by clicking the "You can get this
_entire directory_" link inside each of the font directories on the CTAN
page. Once you have it, you must dump the files in their proper
locations *by hand*. It's a pain in the ass to be sure.

After installing one font and feeling the repetitive stress injuries
begin to set in, I decided to simplify the matter for myself. I wrote a
Perl script to install CTAN font packages. I will share it with
everyone, with the caveat that it is built for installing fonts on my
system, so your mileage may vary.

## BIG LONG PERL SCRIPT FOLLOWS ##

#!/usr/bin/perl
#
# Attempt to automate the installation of LaTeX font packages from CTAN.
# This script copies files. That's all it does. It's not magic.
#
# It has a wand, but it doesn't use it.
#
# No warranty, no license, no copyright, nothing. You got it, you own it.
#

# Strict is fun!
use strict;

# Set this variable to the base directory of your local LaTeX
# files (traditionally /usr/local/share/texmf), no trailing slash.
my $texbase = '/usr/local/share/texmf';
my %filebox = ();

# Chomp because the shell will return a linebreak at the end.
# Use pwd to find out where we've been run from.
chomp(my $srcdir = `pwd`);

print "Locating LaTeX font files within $srcdir...\n";
$srcdir =~ /([^\/]*)$/;
my $fontspec = $1;
my ($foundry, $fontname) = split(/\./,$fontspec);
print "Using foundry '$foundry' and font name '$fontname'.\n";

my %destinations = (	'tfm' =>	"$texbase/fonts/tfm/$foundry/$fontname/",
			'vf' =>		"$texbase/fonts/vf/$foundry/$fontname/",
			'fd' =>		"$texbase/tex/latex/$foundry/$fontname/"
			);

my @allfiles = `find $srcdir`;
foreach my $curfile (@allfiles) {
	chomp($curfile);
	next if $curfile !~ /\.(tfm|vf|fd)$/;
	push @{ $filebox{$1} }, $curfile;
#	print "$curfile (". scalar @{ $filebox{$1} } .")\n";
}

foreach my $ftype (keys %filebox) {
	print "I found ". scalar @{ $filebox{$ftype} } ." '$ftype' files.\n";
}

foreach my $dest (values %destinations) {
	print "Checking for $dest.\n";
	unless(-e $dest) {
		print "The directory $dest does not exist. Create it?\n";
		print "Create directory? {y/n}: ";
		read STDIN, my $do, 2;
		if($do =~ /^y/i) {
			print "Creating $dest...\n";
			system("mkdir $dest 2>/dev/null");
			my $exit_value = $? >> 8;
			die("!!! Unable to create the directory!\n") if $exit_value > 0;
		} elsif($do =~ /^n/i) {
			print "Aborting.\n";
			die("!!! Directory not created by user choice.\n");
		} else {
			print "I'll take that as a no. Aborting.\n";
			die("!!! Directory not created due to user typo!\n");
		}
	}
}

foreach my $ftype (keys %filebox) {
	foreach my $file (@{ $filebox{$ftype} }) {
		print 'Copying ';
		print $file;
		print ' to ';
		print $destinations{$ftype};
		print ".\n";
		system("cp $file " . $destinations{$ftype} . " 2>/dev/null");
		my $exit_value = $? >> 8;
		die("!!! Unable to copy file!\n") if $exit_value > 0;
	}
}

Now, this script requires a few things from you. First of all, it
REQUIRES that you rename the directory containing the font files. Once
you decompress/untar the .tar.gz from CTAN, rename the directory
<foundry>.<fontname>.

Example: If you downloaded Adobe Garamond, rename the directory
adobe.garamond. The script will use that to create an adobe directory if
necessary, and then a garamond directory under that (again, if
necessary). It will prompt you before creating any directories (make
sure you have directory creation privileges for your TeX base directory,
or just run as root).

The only thing this script WON'T do for you is place the .map file in
your dvips/config directory (traditionally
/usr/local/share/texmf/dvips/config) and add the map line to your
config.ps in the same directory (+p <mapname>.map)

So.

1) Tweak my script as necessary (change paths, sanity check it, etc.)
2) Place the script in your path somewhere (it works based on your
   current working directory)
3) Download and decompress/untar a CTAN font directory.
4) Rename it as <foundry>.<fontname>
5) Switch into that directory.
6) Run my ``latex-font-installer'' as I call it (name it whatever your
   heart desires).
7) Cross your fingers.
8) Place the .map file in your dvips/config directory and then add the
   map line ``+p <map file>.map'' in your config.ps in the same
   directory (if you don't have that set up, read another guide for
   creating localized dvips settings).
9) Run texhash
10) Hopefully everything will work!

Phew.

I don't know if any of this will help you, but getting it working was
extremely satisfying for me, and it's well worth it to have PDFs coming
out of LaTeX that don't look like crap, so I hope you have good luck
with it.


-- 
Aaron Bieber
-
Graphic Design // Web Design
http://www.fisheyemultimedia.com/
aaron@fisheyemultimedia.com



Reply to: