processFontSize method

FontExpression processFontSize()

Implementation

FontExpression processFontSize() {
  // font-size[/line-height]
  //
  // Possible size values:
  // * xx-small
  // * small
  // * medium [default]
  // * large
  // * x-large
  // * xx-large
  // * smaller
  // * larger
  // * ##length in px, pt, etc.
  // * ##%, percent of parent elem's font-size
  // * inherit
  LengthTerm? size;
  LineHeight? lineHt;
  var nextIsLineHeight = false;
  for (; _index < _exprs.expressions.length; _index++) {
    var expr = _exprs.expressions[_index];
    if (size == null && expr is LengthTerm) {
      // font-size part.
      size = expr;
    } else if (size != null) {
      if (expr is OperatorSlash) {
        // LineHeight could follow?
        nextIsLineHeight = true;
      } else if (nextIsLineHeight && expr is LengthTerm) {
        assert(expr.unit == TokenKind.UNIT_LENGTH_PX);
        lineHt = LineHeight(expr.value as num, inPixels: true);
        nextIsLineHeight = false;
        _index++;
        break;
      } else {
        break;
      }
    } else {
      break;
    }
  }

  return FontExpression(_exprs.span, size: size, lineHeight: lineHt);
}