Input

@typescale {
  scale: 1.25;
  font-size: 1rem;
  line-height: 1.5rem;
}

.text-xxl {
  typescale: 3 2;
}

.text-xl {
  typescale: 2 1.5;
}

.text-l {
  typescale: 1 1.5;
}

.text-m {
  typescale: 0 1;
}

.text-s {
  typescale: -1 1;
}

.text-xs {
  typescale: -2 0.5;
}

Output

.text-xxl {
  font-size: calc(1.953125 * 1rem);
  line-height: calc(2 * 1.5rem);
}

.text-xl {
  font-size: calc(1.5625 * 1rem);
  line-height: calc(1.5 * 1.5rem);
}

.text-l {
  font-size: calc(1.25 * 1rem);
  line-height: calc(1.5 * 1.5rem);
}

.text-m {
  font-size: calc(1 * 1rem);
  line-height: calc(1 * 1.5rem);
}

.text-s {
  font-size: calc(0.8 * 1rem);
  line-height: calc(1 * 1.5rem);
}

.text-xs {
  font-size: calc(0.64 * 1rem);
  line-height: calc(0.5 * 1.5rem);
}

Result

text-xxxl: Sample text

text-xxl: Sample text

text-xl: Sample text

text-l: Sample text

text-m: Sample text

text-s: Sample text

text-xs: Sample text


Configuration (optional)

@typescale ([name]) {
  /* default values */
  scale: 1.25;
  font-size: 1rem;
  line-height: 1.5rem;
}

Usage

.[your-style] {
  typescale: ([name]) [index] ([line-height-fraction])
}