encodeString function

dynamic encodeString(
  1. dynamic s,
  2. dynamic strings
)

Implementation

encodeString(s, strings) {
  var sid;

  // Is the string in the CFF standard strings?
  var i = cffStandardStrings.indexOf(s);
  if (i >= 0) {
      sid = i;
  }

  // Is the string already in the string index?
  i = strings.indexOf(s);
  if (i >= 0) {
      sid = i + cffStandardStrings.length;
  } else {
      sid = cffStandardStrings.length + strings.length;
      strings.push(s);
  }

  return sid;
}