# t1Lib

fontTools.t1Lib.py – Tools for PostScript Type 1 fonts (Python2 only)

Functions for reading and writing raw Type 1 data:

read(path)

  reads any Type 1 font file, returns the raw data and a type indicator: ‘LWFN’, ‘PFB’ or ‘OTHER’, depending on the format of the file pointed to by ‘path’. Raises an error when the file does not contain valid Type 1 data.

write(path, data, kind=’OTHER’, dohex=False)

  writes raw Type 1 data to the file pointed to by ‘path’. ‘kind’ can be one of ‘LWFN’, ‘PFB’ or ‘OTHER’; it defaults to ‘OTHER’. ‘dohex’ is a flag which determines whether the eexec encrypted part should be written as hexadecimal or binary, but only if kind is ‘OTHER’.

exception fontTools.t1Lib.T1Error
  add_note()

    Exception.add_note(note) – add a note to the exception

  args
  with_traceback()

    Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class fontTools.t1Lib.T1Font(path, encoding='ascii', kind=None)

  Type 1 font class.

  Uses a minimal interpeter that supports just about enough PS to parse Type 1 fonts.

  createData()
  encode_eexec(eexec_dict)
  getData()
  getGlyphSet()

    Return a generic GlyphSet, which is a dict-like object mapping glyph names to glyph objects. The returned glyph objects have a .draw() method that supports the Pen protocol, and will have an attribute named ‘width’, but only after the .draw() method has been called.

    In the case of Type 1, the GlyphSet is simply the CharStrings dict.

  parse()
  saveAs(path, type, dohex=False)

fontTools.t1Lib.assertType1(data)

fontTools.t1Lib.deHexString(hexstring)

fontTools.t1Lib.decryptType1(data)

fontTools.t1Lib.findEncryptedChunks(data)

fontTools.t1Lib.isHex(text)

fontTools.t1Lib.longToString(long)

fontTools.t1Lib.read(path, onlyHeader=False)

  reads any Type 1 font file, returns raw data

fontTools.t1Lib.readLWFN(path, onlyHeader=False)

  reads an LWFN font file, returns raw data

fontTools.t1Lib.readOther(path)

  reads any (font) file, returns raw data

fontTools.t1Lib.readPFB(path, onlyHeader=False)

  reads a PFB font file, returns raw data

fontTools.t1Lib.stringToLong(s)

fontTools.t1Lib.write(path, data, kind='OTHER', dohex=False)

fontTools.t1Lib.writeLWFN(path, data)

fontTools.t1Lib.writeOther(path, data, dohex=False)

fontTools.t1Lib.writePFB(path, data)