Home: Perl Programming Help: Win32 Programming Help:
Reading font name from file

New User

Feb 28, 2003, 9:54 AM

Views: 6230
Reading font name from file

Given a filename (let's say "ARIBLK.TTF"), is there some way to return the name of the font itself ("Arial Black")? I'm trying to dynamically produce an HTML page containing samples of all the fonts on my machine. There may well be a better way of viewing the fonts on my machine, but I'm really interested in seeing if it's doable in Perl for my own amusement. I'm looking for the READ_FONT_NAME_FROM_FILE() below:

use strict; 
my $dir = 'C:/WINNT/Fonts';
my @fontfiles = glob("$dir/*.ttf $dir/*.fon");

map {
print qq|<font face="$ff">This text is using the $ff font.</font><br>\n|;



Feb 28, 2003, 10:38 AM

Views: 6227
Re: [jdb] Reading font name from file

Try [url="http://search.cpan.org/author/MHOSKEN/Font-TTF-0.32/"]Font::TTF from CPAN.
"...there's some good in this world, Mr. Frodo, and it's worth fighting for." - Samwise Gamgee, The Two Towers

New User

Feb 28, 2003, 11:35 AM

Views: 6225
Re: [Melvosh] Reading font name from file

I've looked into that Font::TTF mod in the past with no joy; I still don't really understand it as I know just about nothing about font tables, but I checked it out again just now for kicks, and I did find an example of reading names of installed fonts out of the Registry (using Win32::Registry) in one of the Font::TTF .pm files. So I've managed to produce the file I was going for - Tanks, Melvosh!