advanceFactor method

double advanceFactor(
  1. int index,
  2. bool inv
)

How far this codePoint index is within the glyph.

Implementation

double advanceFactor(int index, bool inv) {
  if (index >= indices.length) {
    return 0;
  }
  var glyphIndex = indices[index];
  int start = index;
  while (start > 0) {
    if (indices[start - 1] != glyphIndex) {
      break;
    }
    start--;
  }
  int end = index;
  while (end < indices.length - 1) {
    if (indices[end + 1] != glyphIndex) {
      break;
    }
    end++;
  }

  var f = (index - start) / (end - start + 1);
  if (inv) {
    return 1.0 - f;
  }
  return f;
}