parseCFFDict function

dynamic parseCFFDict(
  1. dynamic data,
  2. dynamic start,
  3. dynamic size
)

Implementation

parseCFFDict(data, start, size) {
  start = start != null ? start : 0;
  var parser = Parser(data, start);
  var entries = [];
  var operands = [];
  size = size != null ? size : data.length;

  while (parser.relativeOffset < size) {
    var op = parser.parseByte();

    // The first byte for each dict item distinguishes between operator (key) and operand (value).
    // Values <= 21 are operators.
    if (op <= 21) {
      // Two-byte operators have an initial escape byte of 12.
      if (op == 12) {
        op = 1200 + parser.parseByte();
      }

      entries.add([op, operands]);
      operands = [];
    } else {
      // Since the operands (values) come before the operators (keys), we store all operands in a list
      // until we encounter an operator.
      operands.add(parseOperand(parser, op));
    }
  }

  return entriesToObject(entries);
}