# cffLib: Read and write Adobe CFF fonts

### Overview:

> cffLib: read/write Adobe CFF fonts

> OpenType fonts with PostScript outlines embed a completely independent font file in Adobe’s Compact Font Format. So dealing with OpenType fonts requires also dealing with CFF. This module allows you to read and write fonts written in the CFF format.

> In 2016, OpenType 1.8 introduced the CFF2 format which, along with other changes, extended the CFF format to deal with the demands of variable fonts. This module parses both original CFF and CFF2.

### Submodules:

cffLib contains submodules for converting between CCF and CFF2. Each can be used within other Python scripts or run as a subcommand of the `fonttools` command-line tool:

> - CFFToCFF2: convert CFF to CFF2
> - CFF2ToCFF: convert CFF2 to CFF

It also contains submodules for manipulating CFF-formatted glyphs:

> - specializer: T2CharString operator specializer and generalizer
> - width: T2CharString glyph width optimizer

### Module members:

class fontTools.cffLib.CFFFontSet

  Bases: `object`

  A CFF font “file” can contain more than one font, although this is extremely rare (and not allowed within OpenType fonts).

  This class is the entry point for parsing a CFF table. To actually manipulate the data inside the CFF font, you will want to access the `CFFFontSet`’s `TopDict` object. To do this, a `CFFFontSet` object can either be treated as a dictionary (with appropriate `keys()` and `values()` methods) mapping font names to `TopDict` objects, or as a list.

      from fontTools import ttLib
      tt = ttLib.TTFont("Tests/cffLib/data/LinLibertine_RBI.otf")
      tt["CFF "].cff
      # <fontTools.cffLib.CFFFontSet object at 0x101e24c90>
      tt["CFF "].cff[0] # Here's your actual font data
      # <fontTools.cffLib.TopDict object at 0x1020f1fd0>

  decompile(file, otFont, isCFF2=None)

    Parse a binary CFF file into an internal representation. `file` should be a file handle object. `otFont` is the top-level `fontTools.ttLib.ttFont.TTFont` object containing this CFF file.

    If `isCFF2` is passed and set to `True` or `False`, then the library makes an assertion that the CFF header is of the appropriate version.

  keys()
  values()
  compile(file, otFont, isCFF2=None)

    Write the object back into binary representation onto the given file. `file` should be a file handle object. `otFont` is the top-level `fontTools.ttLib.ttFont.TTFont` object containing this CFF file.

    If `isCFF2` is passed and set to `True` or `False`, then the library makes an assertion that the CFF header is of the appropriate version.

  toXML(xmlWriter)

    Write the object into XML representation onto the given `fontTools.misc.xmlWriter.XMLWriter`.

        writer = xmlWriter.XMLWriter(sys.stdout)
        tt["CFF "].cff.toXML(writer)

  fromXML(name, attrs, content, otFont=None)

    Reads data from the XML element into the `CFFFontSet` object.

  convertCFFToCFF2(otFont)
  convertCFF2ToCFF(otFont)
  desubroutinize()
  remove_hints()
  remove_unused_subroutines()

class fontTools.cffLib.CFFWriter(isCFF2)

  Bases: `object`

  Helper class for serializing CFF data to binary. Used by `CFFFontSet.compile()`.

  add(table)
  toFile(file)

fontTools.cffLib.calcOffSize(largestOffset)

class fontTools.cffLib.IndexCompiler(items, strings, parent, isCFF2=None)

  Bases: `object`

  Base class for writing CFF INDEX data to binary.

  getItems(items, strings)
  getOffsets()
  getDataLength()
  toFile(file)

class fontTools.cffLib.IndexedStringsCompiler(items, strings, parent, isCFF2=None)

  Bases: `IndexCompiler`

  getItems(items, strings)

class fontTools.cffLib.TopDictIndexCompiler(items, strings, parent, isCFF2=None)

  Bases: `IndexCompiler`

  Helper class for writing the TopDict to binary.

  getItems(items, strings)
  getChildren(strings)
  getOffsets()
  getDataLength()
  toFile(file)

class fontTools.cffLib.FDArrayIndexCompiler(items, strings, parent, isCFF2=None)

  Bases: `IndexCompiler`

  Helper class for writing the Font DICT INDEX to binary.

  getItems(items, strings)
  getChildren(strings)
  toFile(file)
  setPos(pos, endPos)

class fontTools.cffLib.GlobalSubrsCompiler(items, strings, parent, isCFF2=None)

  Bases: `IndexCompiler`

  Helper class for writing the global subroutine INDEX to binary.

  getItems(items, strings)

class fontTools.cffLib.SubrsCompiler(items, strings, parent, isCFF2=None)

  Bases: `GlobalSubrsCompiler`

  Helper class for writing the local subroutine INDEX to binary.

  setPos(pos, endPos)

class fontTools.cffLib.CharStringsCompiler(items, strings, parent, isCFF2=None)

  Bases: `GlobalSubrsCompiler`

  Helper class for writing the CharStrings INDEX to binary.

  getItems(items, strings)
  setPos(pos, endPos)

class fontTools.cffLib.Index(file=None, isCFF2=None)

  Bases: `object`

  This class represents what the CFF spec calls an INDEX (an array of variable-sized objects). Index items can be addressed and set using Python list indexing.

  compilerClass

    alias of `IndexCompiler`

  produceItem(index, data, file, offset)
  append(item)

    Add an item to an INDEX.

  getCompiler(strings, parent, isCFF2=None)
  clear()

    Empty the INDEX.

class fontTools.cffLib.GlobalSubrsIndex(file=None, globalSubrs=None, private=None, fdSelect=None, fdArray=None, isCFF2=None)

  Bases: `Index`

  This index contains all the global subroutines in the font. A global subroutine is a set of `CharString` data which is accessible to any glyph in the font, and are used to store repeated instructions - for example, components may be encoded as global subroutines, but so could hinting instructions.

  Remember that when interpreting a `callgsubr` instruction (or indeed a `callsubr` instruction) that you will need to add the “subroutine number bias” to number given:

      tt = ttLib.TTFont("Almendra-Bold.otf")
      u = tt["CFF "].cff[0].CharStrings["udieresis"]
      u.decompile()

      u.toXML(XMLWriter(sys.stdout))
      # <some stuff>
      # -64 callgsubr <-- Subroutine which implements the dieresis mark
      # <other stuff>

      tt["CFF "].cff[0].GlobalSubrs[-64] # <-- WRONG
      # <T2CharString (bytecode) at 103451d10>

      tt["CFF "].cff[0].GlobalSubrs[-64 + 107] # <-- RIGHT
      # <T2CharString (source) at 103451390>

  (“The bias applied depends on the number of subrs (gsubrs). If the number of subrs (gsubrs) is less than 1240, the bias is 107. Otherwise if it is less than 33900, it is 1131; otherwise it is 32768.”, Subroutine Operators <https://docs.microsoft.com/en-us/typography/opentype/otspec180/cff2charstr#section4.4>)

  compilerClass

    alias of `GlobalSubrsCompiler`

  subrClass

    alias of `T2CharString`

  charStringClass

    alias of `T2CharString`

  produceItem(index, data, file, offset)
  toXML(xmlWriter)

    Write the subroutines index into XML representation onto the given `fontTools.misc.xmlWriter.XMLWriter`.

        writer = xmlWriter.XMLWriter(sys.stdout)
        tt["CFF "].cff[0].GlobalSubrs.toXML(writer)

  fromXML(name, attrs, content)
  getItemAndSelector(index)

class fontTools.cffLib.SubrsIndex(file=None, globalSubrs=None, private=None, fdSelect=None, fdArray=None, isCFF2=None)

  Bases: `GlobalSubrsIndex`

  This index contains a glyph’s local subroutines. A local subroutine is a private set of `CharString` data which is accessible only to the glyph to which the index is attached.

  compilerClass

    alias of `SubrsCompiler`

class fontTools.cffLib.TopDictIndex(file=None, cff2GetGlyphOrder=None, topSize=0, isCFF2=None)

  Bases: `Index`

  This index represents the array of `TopDict` structures in the font (again, usually only one entry is present). Hence the following calls are equivalent:

      tt["CFF "].cff[0]
      # <fontTools.cffLib.TopDict object at 0x102ed6e50>
      tt["CFF "].cff.topDictIndex[0]
      # <fontTools.cffLib.TopDict object at 0x102ed6e50>

  compilerClass

    alias of `TopDictIndexCompiler`

  produceItem(index, data, file, offset)
  toXML(xmlWriter)

class fontTools.cffLib.FDArrayIndex(file=None, isCFF2=None)

  Bases: `Index`

  compilerClass

    alias of `FDArrayIndexCompiler`

  toXML(xmlWriter)
  produceItem(index, data, file, offset)
  fromXML(name, attrs, content)

class fontTools.cffLib.VarStoreData(file=None, otVarStore=None)

  Bases: `object`

  decompile()
  compile()
  writeXML(xmlWriter, name)
  xmlRead(name, attrs, content, parent)
  getNumRegions(vsIndex)

class fontTools.cffLib.FDSelect(file=None, numGlyphs=None, format=None)

  Bases: `object`

  append(fdSelectValue)

class fontTools.cffLib.CharStrings(file, charset, globalSubrs, private, fdSelect, fdArray, isCFF2=None, varStore=None)

  Bases: `object`

  The `CharStrings` in the font represent the instructions for drawing each glyph. This object presents a dictionary interface to the font’s CharStrings, indexed by glyph name:

      tt["CFF "].cff[0].CharStrings["a"]
      # <T2CharString (bytecode) at 103451e90>

  See `fontTools.misc.psCharStrings.T1CharString` and `fontTools.misc.psCharStrings.T2CharString` for how to decompile, compile and interpret the glyph drawing instructions in the returned objects.

  keys()
  values()
  has_key(name)
  getItemAndSelector(name)
  toXML(xmlWriter)
  fromXML(name, attrs, content)

fontTools.cffLib.readCard8(file)

fontTools.cffLib.readCard16(file)

fontTools.cffLib.readCard32(file)

fontTools.cffLib.writeCard8(file, value)

fontTools.cffLib.writeCard16(file, value)

fontTools.cffLib.writeCard32(file, value)

fontTools.cffLib.packCard8(value)

fontTools.cffLib.packCard16(value)

fontTools.cffLib.packCard32(value)

fontTools.cffLib.buildOperatorDict(table)

fontTools.cffLib.buildOpcodeDict(table)

fontTools.cffLib.buildOrder(table)

fontTools.cffLib.buildDefaults(table)

fontTools.cffLib.buildConverters(table)

class fontTools.cffLib.SimpleConverter

  Bases: `object`

  read(parent, value)
  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.ASCIIConverter

  Bases: `SimpleConverter`

  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.Latin1Converter

  Bases: `SimpleConverter`

  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

fontTools.cffLib.parseNum(s)

fontTools.cffLib.parseBlendList(s)

class fontTools.cffLib.NumberConverter

  Bases: `SimpleConverter`

  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.ArrayConverter

  Bases: `SimpleConverter`

  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.TableConverter

  Bases: `SimpleConverter`

  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.PrivateDictConverter

  Bases: `TableConverter`

  getClass()
  write(parent, value)

class fontTools.cffLib.SubrsConverter

  Bases: `TableConverter`

  getClass()
  write(parent, value)

class fontTools.cffLib.CharStringsConverter

  Bases: `TableConverter`

  write(parent, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.CharsetConverter

  Bases: `SimpleConverter`

  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.CharsetCompiler(strings, charset, parent)

  Bases: `object`

  setPos(pos, endPos)
  getDataLength()
  toFile(file)

fontTools.cffLib.getStdCharSet(charset)

fontTools.cffLib.getCIDfromName(name, strings)

fontTools.cffLib.getSIDfromName(name, strings)

fontTools.cffLib.packCharset0(charset, isCID, strings)

fontTools.cffLib.packCharset(charset, isCID, strings)

fontTools.cffLib.parseCharset0(numGlyphs, file, strings, isCID)

fontTools.cffLib.parseCharset(numGlyphs, file, strings, isCID, fmt)

class fontTools.cffLib.EncodingCompiler(strings, encoding, parent)

  Bases: `object`

  setPos(pos, endPos)
  getDataLength()
  toFile(file)

class fontTools.cffLib.EncodingConverter

  Bases: `SimpleConverter`

  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

fontTools.cffLib.readSID(file)

  Read a String ID (SID) — 2-byte unsigned integer.

fontTools.cffLib.parseEncodingSupplement(file, encoding, strings)
  Parse the CFF Encoding supplement data:

    - nSups: number of supplementary mappings

    - each mapping: (code, SID) pair

  and apply them to the encoding list in place.

fontTools.cffLib.parseEncoding0(charset, file)

  Format 0: simple list of codes. After reading the base table, optionally parse the supplement.

fontTools.cffLib.parseEncoding1(charset, file)

  Format 1: range-based encoding. After reading the base ranges, optionally parse the supplement.

fontTools.cffLib.packEncoding0(charset, encoding, strings)

fontTools.cffLib.packEncoding1(charset, encoding, strings)

class fontTools.cffLib.FDArrayConverter

  Bases: `TableConverter`

  write(parent, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.FDSelectConverter

  Bases: `SimpleConverter`

  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

class fontTools.cffLib.VarStoreConverter

  Bases: `SimpleConverter`

  write(parent, value)
  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

fontTools.cffLib.packFDSelect0(fdSelectArray)

fontTools.cffLib.packFDSelect3(fdSelectArray)

fontTools.cffLib.packFDSelect4(fdSelectArray)

class fontTools.cffLib.FDSelectCompiler(fdSelect, parent)

  Bases: `object`

  setPos(pos, endPos)
  getDataLength()
  toFile(file)

class fontTools.cffLib.VarStoreCompiler(varStoreData, parent)

  Bases: `object`

  setPos(pos, endPos)
  getDataLength()
  toFile(file)

class fontTools.cffLib.ROSConverter

  Bases: `SimpleConverter`

  xmlWrite(xmlWriter, name, value)
  xmlRead(name, attrs, content, parent)

fontTools.cffLib.addConverters(table)

class fontTools.cffLib.TopDictDecompiler(strings, parent=None)

  Bases: `DictDecompiler`

  operators = {(12, 0): ('Copyright', 'SID'), (12, 1): ('isFixedPitch', 'number'), (12, 2): ('ItalicAngle', 'number'), (12, 20): ('SyntheticBase', 'number'), (12, 21): ('PostScript', 'SID'), (12, 22): ('BaseFontName', 'SID'), (12, 23): ('BaseFontBlend', 'delta'), (12, 3): ('UnderlinePosition', 'number'), (12, 30): ('ROS', ('SID', 'SID', 'number')), (12, 31): ('CIDFontVersion', 'number'), (12, 32): ('CIDFontRevision', 'number'), (12, 33): ('CIDFontType', 'number'), (12, 34): ('CIDCount', 'number'), (12, 35): ('UIDBase', 'number'), (12, 36): ('FDArray', 'number'), (12, 37): ('FDSelect', 'number'), (12, 38): ('FontName', 'SID'), (12, 4): ('UnderlineThickness', 'number'), (12, 5): ('PaintType', 'number'), (12, 6): ('CharstringType', 'number'), (12, 7): ('FontMatrix', 'array'), (12, 8): ('StrokeWidth', 'number'), 0: ('version', 'SID'), 1: ('Notice', 'SID'), 13: ('UniqueID', 'number'), 14: ('XUID', 'array'), 15: ('charset', 'number'), 16: ('Encoding', 'number'), 17: ('CharStrings', 'number'), 18: ('Private', ('number', 'number')), 2: ('FullName', 'SID'), 24: ('VarStore', 'number'), 25: ('maxstack', 'number'), 3: ('FamilyName', 'SID'), 4: ('Weight', 'SID'), 5: ('FontBBox', 'array')}

class fontTools.cffLib.PrivateDictDecompiler(strings, parent=None)

  Bases: `DictDecompiler`

  operators = {(12, 10): ('BlueShift', 'number'), (12, 11): ('BlueFuzz', 'number'), (12, 12): ('StemSnapH', 'delta'), (12, 13): ('StemSnapV', 'delta'), (12, 14): ('ForceBold', 'number'), (12, 15): ('ForceBoldThreshold', 'number'), (12, 16): ('lenIV', 'number'), (12, 17): ('LanguageGroup', 'number'), (12, 18): ('ExpansionFactor', 'number'), (12, 19): ('initialRandomSeed', 'number'), (12, 9): ('BlueScale', 'number'), 10: ('StdHW', 'number'), 11: ('StdVW', 'number'), 19: ('Subrs', 'number'), 20: ('defaultWidthX', 'number'), 21: ('nominalWidthX', 'number'), 22: ('vsindex', 'number'), 23: ('blend', 'blendList'), 6: ('BlueValues', 'delta'), 7: ('OtherBlues', 'delta'), 8: ('FamilyBlues', 'delta'), 9: ('FamilyOtherBlues', 'delta')}

class fontTools.cffLib.DictCompiler(dictObj, strings, parent, isCFF2=None)

  Bases: `object`

  maxBlendStack = 0
  setPos(pos, endPos)
  getDataLength()
  compile(reason)
  toFile(file)
  arg_number(num)
  arg_SID(s)
  arg_array(value)
  arg_delta(value)
  arg_delta_blend(value)

    A delta list with blend lists has to be all blend lists.

    The value is a list is arranged as follows:

        [
                [V0, d0..dn]
                [V1, d0..dn]
                ...
                [Vm, d0..dn]
        ]

    `V` is the absolute coordinate value from the default font, and `d0-dn` are the delta values from the n regions. Each `V` is an absolute coordinate from the default font.

    We want to return a list:

        [
                [v0, v1..vm]
                [d0..dn]
                ...
                [d0..dn]
                numBlends
                blendOp
        ]

    where each `v` is relative to the previous default font value.

fontTools.cffLib.encodeNumber(num)

class fontTools.cffLib.TopDictCompiler(dictObj, strings, parent, isCFF2=None)

  Bases: `DictCompiler`

  opcodes = {'BaseFontBlend': (b'\x0c\x17', 'delta'), 'BaseFontName': (b'\x0c\x16', 'SID'), 'CIDCount': (b'\x0c"', 'number'), 'CIDFontRevision': (b'\x0c ', 'number'), 'CIDFontType': (b'\x0c!', 'number'), 'CIDFontVersion': (b'\x0c\x1f', 'number'), 'CharStrings': (b'\x11', 'number'), 'CharstringType': (b'\x0c\x06', 'number'), 'Copyright': (b'\x0c\x00', 'SID'), 'Encoding': (b'\x10', 'number'), 'FDArray': (b'\x0c$', 'number'), 'FDSelect': (b'\x0c%', 'number'), 'FamilyName': (b'\x03', 'SID'), 'FontBBox': (b'\x05', 'array'), 'FontMatrix': (b'\x0c\x07', 'array'), 'FontName': (b'\x0c&', 'SID'), 'FullName': (b'\x02', 'SID'), 'ItalicAngle': (b'\x0c\x02', 'number'), 'Notice': (b'\x01', 'SID'), 'PaintType': (b'\x0c\x05', 'number'), 'PostScript': (b'\x0c\x15', 'SID'), 'Private': (b'\x12', ('number', 'number')), 'ROS': (b'\x0c\x1e', ('SID', 'SID', 'number')), 'StrokeWidth': (b'\x0c\x08', 'number'), 'SyntheticBase': (b'\x0c\x14', 'number'), 'UIDBase': (b'\x0c#', 'number'), 'UnderlinePosition': (b'\x0c\x03', 'number'), 'UnderlineThickness': (b'\x0c\x04', 'number'), 'UniqueID': (b'\r', 'number'), 'VarStore': (b'\x18', 'number'), 'Weight': (b'\x04', 'SID'), 'XUID': (b'\x0e', 'array'), 'charset': (b'\x0f', 'number'), 'isFixedPitch': (b'\x0c\x01', 'number'), 'maxstack': (b'\x19', 'number'), 'version': (b'\x00', 'SID')}
  getChildren(strings)

class fontTools.cffLib.FontDictCompiler(dictObj, strings, parent, isCFF2=None)

  Bases: `DictCompiler`

  opcodes = {'BaseFontBlend': (b'\x0c\x17', 'delta'), 'BaseFontName': (b'\x0c\x16', 'SID'), 'CIDCount': (b'\x0c"', 'number'), 'CIDFontRevision': (b'\x0c ', 'number'), 'CIDFontType': (b'\x0c!', 'number'), 'CIDFontVersion': (b'\x0c\x1f', 'number'), 'CharStrings': (b'\x11', 'number'), 'CharstringType': (b'\x0c\x06', 'number'), 'Copyright': (b'\x0c\x00', 'SID'), 'Encoding': (b'\x10', 'number'), 'FDArray': (b'\x0c$', 'number'), 'FDSelect': (b'\x0c%', 'number'), 'FamilyName': (b'\x03', 'SID'), 'FontBBox': (b'\x05', 'array'), 'FontMatrix': (b'\x0c\x07', 'array'), 'FontName': (b'\x0c&', 'SID'), 'FullName': (b'\x02', 'SID'), 'ItalicAngle': (b'\x0c\x02', 'number'), 'Notice': (b'\x01', 'SID'), 'PaintType': (b'\x0c\x05', 'number'), 'PostScript': (b'\x0c\x15', 'SID'), 'Private': (b'\x12', ('number', 'number')), 'ROS': (b'\x0c\x1e', ('SID', 'SID', 'number')), 'StrokeWidth': (b'\x0c\x08', 'number'), 'SyntheticBase': (b'\x0c\x14', 'number'), 'UIDBase': (b'\x0c#', 'number'), 'UnderlinePosition': (b'\x0c\x03', 'number'), 'UnderlineThickness': (b'\x0c\x04', 'number'), 'UniqueID': (b'\r', 'number'), 'VarStore': (b'\x18', 'number'), 'Weight': (b'\x04', 'SID'), 'XUID': (b'\x0e', 'array'), 'charset': (b'\x0f', 'number'), 'isFixedPitch': (b'\x0c\x01', 'number'), 'maxstack': (b'\x19', 'number'), 'version': (b'\x00', 'SID')}
  getChildren(strings)

class fontTools.cffLib.PrivateDictCompiler(dictObj, strings, parent, isCFF2=None)

  Bases: `DictCompiler`

  maxBlendStack = 513
  opcodes = {'BlueFuzz': (b'\x0c\x0b', 'number'), 'BlueScale': (b'\x0c\t', 'number'), 'BlueShift': (b'\x0c\n', 'number'), 'BlueValues': (b'\x06', 'delta'), 'ExpansionFactor': (b'\x0c\x12', 'number'), 'FamilyBlues': (b'\x08', 'delta'), 'FamilyOtherBlues': (b'\t', 'delta'), 'ForceBold': (b'\x0c\x0e', 'number'), 'ForceBoldThreshold': (b'\x0c\x0f', 'number'), 'LanguageGroup': (b'\x0c\x11', 'number'), 'OtherBlues': (b'\x07', 'delta'), 'StdHW': (b'\n', 'number'), 'StdVW': (b'\x0b', 'number'), 'StemSnapH': (b'\x0c\x0c', 'delta'), 'StemSnapV': (b'\x0c\r', 'delta'), 'Subrs': (b'\x13', 'number'), 'blend': (b'\x17', 'blendList'), 'defaultWidthX': (b'\x14', 'number'), 'initialRandomSeed': (b'\x0c\x13', 'number'), 'lenIV': (b'\x0c\x10', 'number'), 'nominalWidthX': (b'\x15', 'number'), 'vsindex': (b'\x16', 'number')}
  setPos(pos, endPos)
  getChildren(strings)

class fontTools.cffLib.BaseDict(strings=None, file=None, offset=None, isCFF2=None)

  Bases: `object`

  decompile(data)
  postDecompile()
  getCompiler(strings, parent, isCFF2=None)
  toXML(xmlWriter)
  fromXML(name, attrs, content)

class fontTools.cffLib.TopDict(strings=None, file=None, offset=None, GlobalSubrs=None, cff2GetGlyphOrder=None, isCFF2=None)

  Bases: `BaseDict`

  The `TopDict` represents the top-level dictionary holding font information. CFF2 tables contain a restricted set of top-level entries as described here, but CFF tables may contain a wider range of information. This information can be accessed through attributes or through the dictionary returned through the `rawDict` property:

      font = tt["CFF "].cff[0]
      font.FamilyName
      # 'Linux Libertine O'
      font.rawDict["FamilyName"]
      # 'Linux Libertine O'

  More information is available in the CFF file’s private dictionary, accessed via the `Private` property:

      tt["CFF "].cff[0].Private.BlueValues
      # [-15, 0, 515, 515, 666, 666]

  converters = {'BaseFontBlend': <fontTools.cffLib.ArrayConverter object>, 'BaseFontName': <fontTools.cffLib.ASCIIConverter object>, 'CIDCount': <fontTools.cffLib.NumberConverter object>, 'CIDFontRevision': <fontTools.cffLib.NumberConverter object>, 'CIDFontType': <fontTools.cffLib.NumberConverter object>, 'CIDFontVersion': <fontTools.cffLib.NumberConverter object>, 'CharStrings': <fontTools.cffLib.CharStringsConverter object>, 'CharstringType': <fontTools.cffLib.NumberConverter object>, 'Copyright': <fontTools.cffLib.Latin1Converter object>, 'Encoding': <fontTools.cffLib.EncodingConverter object>, 'FDArray': <fontTools.cffLib.FDArrayConverter object>, 'FDSelect': <fontTools.cffLib.FDSelectConverter object>, 'FamilyName': <fontTools.cffLib.Latin1Converter object>, 'FontBBox': <fontTools.cffLib.ArrayConverter object>, 'FontMatrix': <fontTools.cffLib.ArrayConverter object>, 'FontName': <fontTools.cffLib.Latin1Converter object>, 'FullName': <fontTools.cffLib.Latin1Converter object>, 'ItalicAngle': <fontTools.cffLib.NumberConverter object>, 'Notice': <fontTools.cffLib.Latin1Converter object>, 'PaintType': <fontTools.cffLib.NumberConverter object>, 'PostScript': <fontTools.cffLib.ASCIIConverter object>, 'Private': <fontTools.cffLib.PrivateDictConverter object>, 'ROS': <fontTools.cffLib.ROSConverter object>, 'StrokeWidth': <fontTools.cffLib.NumberConverter object>, 'SyntheticBase': <fontTools.cffLib.NumberConverter object>, 'UIDBase': <fontTools.cffLib.NumberConverter object>, 'UnderlinePosition': <fontTools.cffLib.NumberConverter object>, 'UnderlineThickness': <fontTools.cffLib.NumberConverter object>, 'UniqueID': <fontTools.cffLib.NumberConverter object>, 'VarStore': <fontTools.cffLib.VarStoreConverter object>, 'Weight': <fontTools.cffLib.ASCIIConverter object>, 'XUID': <fontTools.cffLib.ArrayConverter object>, 'charset': <fontTools.cffLib.CharsetConverter object>, 'isFixedPitch': <fontTools.cffLib.NumberConverter object>, 'maxstack': <fontTools.cffLib.NumberConverter object>, 'version': <fontTools.cffLib.ASCIIConverter object>}
  compilerClass

    alias of `TopDictCompiler`

  decompilerClass

    alias of `TopDictDecompiler`

  defaults = {'CIDCount': 8720, 'CIDFontRevision': 0, 'CIDFontType': 0, 'CIDFontVersion': 0, 'CharstringType': 2, 'Encoding': 0, 'FontBBox': [0, 0, 0, 0], 'FontMatrix': [0.001, 0, 0, 0.001, 0, 0], 'ItalicAngle': 0, 'PaintType': 0, 'StrokeWidth': 0, 'UnderlinePosition': -100, 'UnderlineThickness': 50, 'isFixedPitch': 0}
  order = ['maxstack', 'ROS', 'SyntheticBase', 'version', 'Notice', 'Copyright', 'FullName', 'FontName', 'FamilyName', 'Weight', 'isFixedPitch', 'ItalicAngle', 'UnderlinePosition', 'UnderlineThickness', 'PaintType', 'CharstringType', 'FontMatrix', 'UniqueID', 'FontBBox', 'StrokeWidth', 'XUID', 'PostScript', 'BaseFontName', 'BaseFontBlend', 'CIDFontVersion', 'CIDFontRevision', 'CIDFontType', 'CIDCount', 'charset', 'UIDBase', 'Encoding', 'Private', 'FDSelect', 'FDArray', 'CharStrings', 'VarStore']
  getGlyphOrder()

    Returns a list of glyph names in the CFF font.

  postDecompile()
  toXML(xmlWriter)
  decompileAllCharStrings()
  recalcFontBBox()

class fontTools.cffLib.FontDict(strings=None, file=None, offset=None, GlobalSubrs=None, isCFF2=None, vstore=None)

  Bases: `BaseDict`

  defaults = {}
  converters = {'BaseFontBlend': <fontTools.cffLib.ArrayConverter object>, 'BaseFontName': <fontTools.cffLib.ASCIIConverter object>, 'CIDCount': <fontTools.cffLib.NumberConverter object>, 'CIDFontRevision': <fontTools.cffLib.NumberConverter object>, 'CIDFontType': <fontTools.cffLib.NumberConverter object>, 'CIDFontVersion': <fontTools.cffLib.NumberConverter object>, 'CharStrings': <fontTools.cffLib.CharStringsConverter object>, 'CharstringType': <fontTools.cffLib.NumberConverter object>, 'Copyright': <fontTools.cffLib.Latin1Converter object>, 'Encoding': <fontTools.cffLib.EncodingConverter object>, 'FDArray': <fontTools.cffLib.FDArrayConverter object>, 'FDSelect': <fontTools.cffLib.FDSelectConverter object>, 'FamilyName': <fontTools.cffLib.Latin1Converter object>, 'FontBBox': <fontTools.cffLib.ArrayConverter object>, 'FontMatrix': <fontTools.cffLib.ArrayConverter object>, 'FontName': <fontTools.cffLib.Latin1Converter object>, 'FullName': <fontTools.cffLib.Latin1Converter object>, 'ItalicAngle': <fontTools.cffLib.NumberConverter object>, 'Notice': <fontTools.cffLib.Latin1Converter object>, 'PaintType': <fontTools.cffLib.NumberConverter object>, 'PostScript': <fontTools.cffLib.ASCIIConverter object>, 'Private': <fontTools.cffLib.PrivateDictConverter object>, 'ROS': <fontTools.cffLib.ROSConverter object>, 'StrokeWidth': <fontTools.cffLib.NumberConverter object>, 'SyntheticBase': <fontTools.cffLib.NumberConverter object>, 'UIDBase': <fontTools.cffLib.NumberConverter object>, 'UnderlinePosition': <fontTools.cffLib.NumberConverter object>, 'UnderlineThickness': <fontTools.cffLib.NumberConverter object>, 'UniqueID': <fontTools.cffLib.NumberConverter object>, 'VarStore': <fontTools.cffLib.VarStoreConverter object>, 'Weight': <fontTools.cffLib.ASCIIConverter object>, 'XUID': <fontTools.cffLib.ArrayConverter object>, 'charset': <fontTools.cffLib.CharsetConverter object>, 'isFixedPitch': <fontTools.cffLib.NumberConverter object>, 'maxstack': <fontTools.cffLib.NumberConverter object>, 'version': <fontTools.cffLib.ASCIIConverter object>}
  compilerClass

    alias of `FontDictCompiler`

  orderCFF = ['FontName', 'FontMatrix', 'Weight', 'Private']
  orderCFF2 = ['Private']
  decompilerClass

    alias of `TopDictDecompiler`

  setCFF2(isCFF2)

class fontTools.cffLib.PrivateDict(strings=None, file=None, offset=None, isCFF2=None, vstore=None)

  Bases: `BaseDict`

  converters = {'BlueFuzz': <fontTools.cffLib.NumberConverter object>, 'BlueScale': <fontTools.cffLib.NumberConverter object>, 'BlueShift': <fontTools.cffLib.NumberConverter object>, 'BlueValues': <fontTools.cffLib.ArrayConverter object>, 'ExpansionFactor': <fontTools.cffLib.NumberConverter object>, 'FamilyBlues': <fontTools.cffLib.ArrayConverter object>, 'FamilyOtherBlues': <fontTools.cffLib.ArrayConverter object>, 'ForceBold': <fontTools.cffLib.NumberConverter object>, 'ForceBoldThreshold': <fontTools.cffLib.NumberConverter object>, 'LanguageGroup': <fontTools.cffLib.NumberConverter object>, 'OtherBlues': <fontTools.cffLib.ArrayConverter object>, 'StdHW': <fontTools.cffLib.NumberConverter object>, 'StdVW': <fontTools.cffLib.NumberConverter object>, 'StemSnapH': <fontTools.cffLib.ArrayConverter object>, 'StemSnapV': <fontTools.cffLib.ArrayConverter object>, 'Subrs': <fontTools.cffLib.SubrsConverter object>, 'blend': None, 'defaultWidthX': <fontTools.cffLib.NumberConverter object>, 'initialRandomSeed': <fontTools.cffLib.NumberConverter object>, 'lenIV': <fontTools.cffLib.NumberConverter object>, 'nominalWidthX': <fontTools.cffLib.NumberConverter object>, 'vsindex': <fontTools.cffLib.NumberConverter object>}
  decompilerClass

    alias of `PrivateDictDecompiler`

  compilerClass

    alias of `PrivateDictCompiler`

  defaults = {'BlueFuzz': 1, 'BlueScale': 0.039625, 'BlueShift': 7, 'ExpansionFactor': 0.06, 'ForceBold': 0, 'LanguageGroup': 0, 'defaultWidthX': 0, 'initialRandomSeed': 0, 'nominalWidthX': 0}
  order = ['vsindex', 'blend', 'BlueValues', 'OtherBlues', 'FamilyBlues', 'FamilyOtherBlues', 'BlueScale', 'BlueShift', 'BlueFuzz', 'StdHW', 'StdVW', 'StemSnapH', 'StemSnapV', 'ForceBold', 'ForceBoldThreshold', 'lenIV', 'LanguageGroup', 'ExpansionFactor', 'initialRandomSeed', 'defaultWidthX', 'nominalWidthX', 'Subrs']
  property in_cff2
  getNumRegions(vi=None)

class fontTools.cffLib.IndexedStrings(file=None)

  Bases: `object`

  SID -> string mapping.

  getCompiler()
  getSID(s)
  getStrings()
  buildStringMapping()