Пример #1
0
  // convert value in other unit to this unit
  public float toUnit(TeXParser parser, float value, TeXUnit otherUnit) throws TeXSyntaxException {
    if (equals(otherUnit)) {
      return value;
    }

    if (otherUnit.equals(FixedUnit.PT)) {
      return value / parser.getListener().emToPt(1f);
    }

    return otherUnit.toPt(parser, value) / parser.getListener().emToPt(1f);
  }
Пример #2
0
  // convert value in this unit to other unit
  public float fromUnit(TeXParser parser, float value, TeXUnit otherUnit)
      throws TeXSyntaxException {
    if (equals(otherUnit)) {
      return value;
    }

    if (otherUnit.equals(FixedUnit.PT)) {
      return parser.getListener().emToPt(value);
    }

    return otherUnit.fromPt(parser, parser.getListener().emToPt(value));
  }