'Parse the font mapping file.
The format is, AFAIK: texname fontname [effects and filenames]
Effects are PostScript snippets like ".177 SlantFont",
filenames begin with one or two less-than signs. A filename
ending in enc is an encoding file, other filenames are font
files. This can be overridden with a left bracket: <[foobar
indicates an encoding file named foobar.
There is some difference between <foo.pfb and <<bar.pfb in
subsetting, but I have no example of << in my TeX installation.'

def _parse(self, file):

    empty_re = re.compile('%|\\s*$')
    word_re = re.compile('(?x)    (?:\n                                                                    "<\\[    (?P<enc1>        [^"]+                )"    |    #    quoted    encoding    marked    by    [\n                                                                    "<            (?P<enc2>        [^"]+.enc)"    |    #    quoted    encoding,    ends    in    .enc\n                                                                    "<<?    (?P<file1>    [^"]+                )"    |    #    quoted    font    file    name\n                                                                    "                (?P<eff1>        [^"]+                )"    |    #    quoted    effects    or    font    name\n                                                                    <\\[        (?P<enc3>        \\S+                        )        |    #    encoding    marked    by    [\n                                                                    <                (?P<enc4>        \\S+        .enc)        |    #    encoding,    ends    in    .enc\n                                                                    <<?        (?P<file2>    \\S+                        )        |    #    font    file    name\n                                                                                        (?P<eff2>        \\S+                        )                #    effects    or    font    name\n                                                )')
    effects_re = re.compile('(?x)    (?P<slant>    -?[0-9]*(?:\\.[0-9]+))    \\s*    SlantFont\n                                                                                |    (?P<extend>-?[0-9]*(?:\\.[0-9]+))    \\s*    ExtendFont')
    lines = (line.strip() for line in file if (not empty_re.match(line)))
    for line in lines:
        (effects, encoding, filename) = ('', None, None)
        words = word_re.finditer(line)
        w = next(words)
        texname = (w.group(u'eff2') or w.group(u'eff1'))
        w = next(words)
        psname = (w.group(u'eff2') or w.group(u'eff1'))
        for w in words:
            eff = (w.group(u'eff1') or w.group(u'eff2'))
            if eff:
                effects = eff
                continue
            enc = (w.group(u'enc4') or w.group(u'enc3') or w.group(u'enc2') or w.group(u'enc1'))
            if enc:
                if (encoding is not None):
                    matplotlib.verbose.report((u'Multiple    encodings    for    %s    =    %s' % (texname, psname)), u'debug')
                encoding = enc
                continue
            filename = (w.group(u'file2') or w.group(u'file1'))
        effects_dict = {}
        for match in effects_re.finditer(effects):
            slant = match.group(u'slant')
            if slant:
                effects_dict[u'slant'] = float(slant)
            else:
                effects_dict[u'extend'] = float(match.group(u'extend'))
        self._font[texname] = PsFont(texname=texname, psname=psname, effects=effects_dict, encoding=encoding, filename=filename)
