'Read the font from a file, decoding into usable parts.'

def _read(self, file):

    rawdata = file.read()
    if (not rawdata.startswith('\x80')):
        return rawdata
    data = ''
    while (len(rawdata) > 0):
        if (not rawdata.startswith('\x80')):
            raise RuntimeError((u'Broken    pfb    file    (expected    byte    128,    got    %d)' % ord(rawdata[0])))
        type = ord(rawdata[1])
        if (type in (1, 2)):
            (length,) = struct.unpack(str(u'<i'), rawdata[2:6])
            segment = rawdata[6:(6 + length)]
            rawdata = rawdata[(6 + length):]
        if (type == 1):
            data += segment
        elif (type == 2):
            data += binascii.hexlify(segment)
        elif (type == 3):
            break
        else:
            raise RuntimeError((u'Unknown    segment    type    %d    in    pfb    file' % type))
    return data
