Logo Search packages:      
Sourcecode: matplotlib version File versions

matplotlib::afm Namespace Reference


Detailed Description

This is a python interface to Adobe Font Metrics Files.  Although a
number of other python implementations exist (and may be more complete
than mine) I decided not to go with them because either they were
either

  1) copyrighted or used a non-BSD compatible license

  2) had too many dependencies and I wanted a free standing lib

  3) Did more than I needed and it was easier to write my own than
     figure out how to just get what I needed from theirs

It is pretty easy to use, and requires only built-in python libs::

    >>> from afm import AFM
    >>> fh = file('ptmr8a.afm')
    >>> afm = AFM(fh)
    >>> afm.string_width_height('What the heck?')
    (6220.0, 683)
    >>> afm.get_fontname()
    'Times-Roman'
    >>> afm.get_kern_dist('A', 'f')
    0
    >>> afm.get_kern_dist('A', 'y')
    -92.0
    >>> afm.get_bbox_char('!')
    [130, -9, 238, 676]
    >>> afm.get_bbox_font()
    [-168, -218, 1000, 898]


AUTHOR:
  John D. Hunter <jdh2358@gmail.com>


Classes

class  AFM

Functions

def _parse_char_metrics
def _parse_composites
def _parse_header
def _parse_kern_pairs
def _parse_optional
def _sanity_check
def _to_bool
def _to_list_of_floats
def _to_list_of_ints
def parse_afm

Variables

 _to_float = float
 _to_int = int
 _to_str = str
tuple afm = AFM(fh)
tuple fh = file(os.path.join(pathname,fname))
string pathname = '/usr/local/share/fonts/afms/adobe'


Generated by  Doxygen 1.6.0   Back to index