Reading font metrics

R

Ray(:bies, :mundo)

Hi, I'm looking for a way to read Truetype & PS Type 1 font metrics so
that I can generate a list of installed fonts by name in a Ruby script.
I have been searching the Internet for some tips on how-to with no luck
so far. Can anyone point me in the right direction?
Ta, Ray.
 
A

Austin Ziegler

Hi, I'm looking for a way to read Truetype & PS Type 1 font metrics so
that I can generate a list of installed fonts by name in a Ruby script.
I have been searching the Internet for some tips on how-to with no luck
so far. Can anyone point me in the right direction?

I haven't implemented it yet, but there's definite information you can
get from one of the TeX distributions. Look for ttf2afm.

-austin
 
D

Dave Howell

Hi, I'm looking for a way to read Truetype & PS Type 1 font metrics so
that I can generate a list of installed fonts by name in a Ruby script.
I have been searching the Internet for some tips on how-to with no luck
so far. Can anyone point me in the right direction?

Hmm. First, you should figure out if your operating system offers a way
to do that. For example, on the Macintosh, fonts are almost certainly
in three different locations (/System/Library/Font, /Library/Fonts,
~/Library/Fonts) and could easily be in five or more (/System
Folder/Font, /Network/Library/Fonts). Using RubyCocoa to make a call to
the OS's font manager delivers a list of installed fonts without having
to try to track them all down. Dunno what the Win equivalent would be.

Second, if what you want are font names, you don't need any special
tool for PostScript fonts. .pfb files start with a text header that
contains the name of the font. Just read the first 1k or so of the file
into memory, and grep for the line with the info you want. In the case
of Caflisch Script Bold, your choices are:

/FullName (Caflisch Script Bold) readonly def
/FamilyName (Caflisch Script) readonly def
/FontName /CaflischScript-Bold def

You'll have to figure out which of those you want. All three are
required in a PostScript font.

TrueType fonts are more likely to be all-binary, and have to be run
through a translator of some kind. "ttf2afm" is a good tool for this;
it's available on a lot of platforms. The output will be very similar
to the above:

FullName Caflisch Script Bold
FamilyName Caflisch Script
FontName CaflischScript-Bold
 
P

Patrick Gundlach

Ray(:bies said:
Hi, I'm looking for a way to read Truetype & PS Type 1 font metrics so
that I can generate a list of installed fonts by name in a Ruby script.
I have been searching the Internet for some tips on how-to with no luck
so far. Can anyone point me in the right direction?
Ta, Ray.

Hi,

I have just started a rubyforge project ('fontlib') that should be able
to do so. I'll take
some code from 'rfil' (the ruby font installler library - ) and put it
there. There is currently
only type1 support and truetype via the ttftoafm (from your favourite
TeX distribution).

Just in case you want to reply off-list: pg <at> levana . de

Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,211
Messages
2,571,092
Members
47,693
Latest member
david4523

Latest Threads

Top