Reading font metrics

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.

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

-austin

···

On 8/31/06, Ray(:bies, :mundo) <ray@thecarrascos.com> wrote:

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?

--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
               * austin@halostatue.ca * http://www.halostatue.ca/feed/
               * austin@zieglers.ca

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

···

On Aug 31, 2006, at 14:10, Ray(:bies, :mundo) wrote:

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?

Ray(:bies, :mundo) wrote:

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

···

--
Posted via http://www.ruby-forum.com/.