views:

117

answers:

1

How can I determine if a TrueType file is italic? Ideally this would be a way via PHP, Ruby, or the linux command line. I am currently running ttf2pt1 to generate an afm file for the ttf file, and the afm file clearly shows the weight of the font, indicating to me if the font is Bold, but I can't find out how to determine if the font is italic or oblique.

+1  A: 

Here's a quick Perl script to do it, using the Font::FreeType module:

#!/usr/bin/perl -w
use strict;
use Font::FreeType;

for my $file (@ARGV) {
    printf "%s is %s\n", $file, Font::FreeType->new->face($file)->is_italic
        ? 'italic' : 'not italic';
}

You can probably use a different language, if it has an extension for using FreeType.

Chris Jester-Young
That works well, thank you!!
Josh