Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    PostScript::FontMetrics 1.10

    Download button

    No screenshots available
    Downloads: 759  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Johan Vromans, Squirrel Consultancy | More programs
    Perl Artistic License / FREE
    October 24th, 2007, 18:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    PostScript::FontMetrics description

    PostScript::FontMetrics is a Perl module to fetch data from Adobe Font Metrics file.

    PostScript::FontMetrics is a Perl module to fetch data from Adobe Font Metrics file.

    SYNOPSIS

    my $info = new PostScript::FontMetrics (filename, options);
    print STDOUT ("Name = ", $info->FontName, "n");
    print STDOUT ("Width of LAV = ", $info->kstringwidth("LAV", 10), "n");

    This package allows Adobe standard font metric files, so called .afm files, to be read and (partly) parsed.
    True Type fonts are understood as well, their metrics are extracted. This requires Martin Hosken's Font::TTF package to be installed (available on CPAN).

    CONSTRUCTOR

    new ( FILENAME [ , OPTIONS ])
    The constructor will read the file and parse its contents.

    OPTIONS

    error => [ 'die' | 'warn' | 'ignore' ]

    DEPRECATED. Please use 'eval { ... }' to intercept errors.
    How errors must be handled. Default is to call die(). In any case, new() returns a undefined result. Setting 'error' to 'ignore' may cause surprising results.

    verbose => value

    Prints verbose info if value is true.

    trace => value

    Prints tracing info if value is true.

    debug => value

    Prints debugging info if value is true. Implies 'trace' and 'verbose'.

    INSTANCE METHODS

    Note: Most of the info from the AFM file can be obtained by calling a method of the same name, e.g. FontName and IsFixedPitch.

    Each of these methods can return undef if the corresponding information could not be found in the file.

    FileName

    The name of the file, e.g. 'tir_____.afm'. This is not derived from the metrics data, but the name of the file as passed to the new method.

    MetricsData

    The complete contents of the file, normalised to Unix-style line endings.

    CharWidthData

    Returns a reference to a hash with the character widths for each glyph.

    EncodingVector

    Returns a reference to an array with the glyph names for each encoded character.

    CharBBoxData

    Returns a reference to a hash with the bounding boxes (a 4-element array) for each glyph.

    KernData

    Returns a reference to a hash with the kerning data for glyph pairs. It is indexed by two glyph names (two strings separated by a comma, e.g. $kd->{"A","B"}).

    setEncoding ( vector )

    Sets the current encoding vector. The argument must be a reference to an array of exactly 256 elements, or the name of a pre-defined encoding ("StandardEncoding" or "ISOLatin1Encoding").

    stringwidth ( string [ , pointsize ] )

    Returns the width of the string, in character space units.
    Deprecated: When a pointsize argument is supplied, the resultant width is scaled to user space units. This assumes that the font maps 1000 character space units to one user space unit (which is generally the case).

    kstringwidth ( string [ , pointsize ] )

    Returns the width of the string in character space units, taking kerning information into account.

    Deprecated: When a pointsize argument is supplied, the resultant width is scaled to user space units. This assumes that the font maps 1000 character space units to one user space unit (which is generally the case).

    kstring ( string [ , extent ] )

    Returns an array reference (in scalar context) or an array (in array context) with substrings of the given string, interspersed with kerning info. The kerning info is the amount of movement needed for the correct kerning, in character space (which is usually 1000 times a PostScript point). The substrings are ready for printing: non-ASCII characters have been encoded and parentheses are put around them.

    If the extend argument is supplied, this amount of displacement is added to each space in the string.
    For example, for a given font, the following call:

    $typesetinfo = $metrics->kstring ("ILVATAB");
    could return in $typesetinfo:
    [ "(IL)", -97, "(V)", -121, "(A)", -92, "(T)", -80, "(AB)" ]

    There are several straightforward ways to process this.
    By translating to a series of 'show' and 'rmoveto' operations:

    foreach ( @$typesetinfo ) {
    if ( /^(/ ) {
    print STDOUT ($_, " shown");
    }
    else {
    printf STDOUT ("%.3f 0 rmoveton", ($_*$fontsize)/$fontscale);
    }
    }

    Or, assuming the following definition in the PostScript preamble (48 is the font size):

    /Fpt 48 1000 div def
    /TJ {{ dup type /stringtype eq
    { show }
    { Fpt mul 0 rmoveto }
    ifelse } forall } bind def

    the following Perl code would suffice:

    print PS ("[ @$typesetinfo ] TJn");
    char

    Returns a one-character string that will render as the named glyph in the current encoding, or undef if this glyph is currently not encoded.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Adobe Font Metrics | fetch data | Perl module | Adobe | Font | Metrics

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM