i'm either using the wrong package or i'm just too tired to figure it out.

I'm basically cataloging all of my fonts on my windows box, I have over 100, so I want to do it efficiently. I can't figure out how to get the font's name out of the font file. Below is the basic code and output, which gives me practically every piece of info, except for the most basic, the font's name.

SCRIPT

#!perl.exe -w use strict; use Font::TTF::Font; use CGI qw(:all); use Data::Dumper; print header(); my $infont = "c:/windows/fonts/D24000D5.TTF"; my $f = Font::TTF::Font->open($infont) || die "could not open font:<BR +>$!"; print "<pre>".Dumper($f)."</pre>"; $f->release; exit;

OUTPUT

$VAR1 = bless( { 'loca' => bless( { 'glyphs' => [], ' INFILE' => bless( \*Symbol::GEN0, 'IO::File' ), ' PARENT' => $VAR1, ' NAME' => 'loca', ' LENGTH' => 528, ' OFFSET' => 31404, ' CSUM' => 3174816727 }, 'Font::TTF::Loca' ), 'head' => bless( { 'flags' => 3, 'lowestRecPPEM' => 6, ' NAME' => 'head', ' CSUM' => 3212545405, 'unitsPerEm' => 2048, 'glyphDataFormat' => 0, ' read' => 1, 'magicNumber' => 1594834165, 'checkSumAdjustment' => 2521350520, 'fontRevision' => '1.00498962402344', 'xMax' => 2332, 'indexToLocFormat' => 0, ' LENGTH' => 54, 'yMax' => 1813, 'modified' => [ 0, 2883461375 ], 'macStyle' => 0, 'xMin' => '-116', 'fontDirectionHint' => 2, ' OFFSET' => 30260, 'yMin' => '-472', ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, 'version' => '1', 'created' => [ 0, 2883461375 ] }, 'Font::TTF::Head' ), 'cvt ' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'cvt ', ' LENGTH' => 122, ' OFFSET' => 1040, ' CSUM' => 769665920 }, 'Font::TTF::Cvt_' ), 'cmap' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'cmap', ' LENGTH' => 754, ' OFFSET' => 284, ' CSUM' => 590882806 }, 'Font::TTF::Cmap' ), 'maxp' => bless( { 'maxContours' => 5, 'maxComponentDepth' => 1, 'maxComponentElements' => 2, ' NAME' => 'maxp', ' CSUM' => 152502762, 'maxCompositePoints' => 110, 'maxStackElements' => 2048, ' read' => 1, 'maxFunctionDefs' => 0, ' LENGTH' => 32, 'maxStorage' => 0, ' OFFSET' => 31932, 'maxPoints' => 164, 'maxInstructionDefs' => 0, 'maxCompositeContours' => 4, 'maxTwilightPoints' => 4, ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, 'numGlyphs' => 263, 'maxSizeOfInstructions' => 213, 'version' => '1', 'maxZones' => 2 }, 'Font::TTF::Maxp' ), 'post' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'post', ' LENGTH' => 1840, ' OFFSET' => 32492, ' CSUM' => 2346503743 }, 'Font::TTF::Post' ), 'hmtx' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'hmtx', ' LENGTH' => 1052, ' OFFSET' => 30352, ' CSUM' => 1362962598 }, 'Font::TTF::Hmtx' ), 'glyf' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'glyf', ' LENGTH' => 29094, ' OFFSET' => 1164, ' CSUM' => 4161335985 }, 'Font::TTF::Glyf' ), ' OFFSET' => 0, 'name' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'name', ' LENGTH' => 528, ' OFFSET' => 31964, ' CSUM' => 3339688555 }, 'Font::TTF::Name' ), ' fname' => 'c:/windows/fonts/D24000D5.TTF', ' INFILE' => $VAR1->{'loca'}{' INFILE'}, 'prep' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'prep', ' LENGTH' => 29, ' OFFSET' => 34332, ' CSUM' => 796688338 }, 'Font::TTF::Prep' ), 'OS/2' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'OS/2', ' LENGTH' => 78, ' OFFSET' => 204, ' CSUM' => 1792378936 }, 'Font::TTF::OS_2' ), 'hhea' => bless( { ' INFILE' => $VAR1->{'loca'}{' INFILE'}, ' PARENT' => $VAR1, ' NAME' => 'hhea', ' LENGTH' => 36, ' OFFSET' => 30316, ' CSUM' => 272959505 }, 'Font::TTF::Hhea' ) }, 'Font::TTF::Font' );

--
paul

In reply to Font::TTF Give Me the Font Name by vbrtrmn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.