How do I align these letters to the same baseline?

23 Views Asked by At

Given the following letters, all are absolutely aligned vertically to the bottom, however I need to align them to their baseline.

enter image description here

How can that calculate the letter vertical offset?

  • Each letter is currently displayed vertically with y = bottomY - fontSize (all in pixels)
  • fontSize is proportional to h (i.e. fontSize = h * 0.5 for 50%)
  • the descent value d is a variable obtained per font family, e.g. d = h * 0.22

I know that, for a scaling of 1 (100%), the offset should be 0, and it seems like for 0.5 (50%), the offset seems to offset = d / 2, but what about when the scaling is 0.1 (10%)?

Thank you for helping me understand the math behind this.