How to use subscript in textBlock

Is there any easy way to get subscript into a textBlock? For example a way to simplify the following to only use one textBlock instead of 3 and also be less brittle?

I was able to type a subscript 2 directly into the text string using the macOS emoji keyboard

<textBlock
  text="tCO₂e"
  fontSize={20}
  height={20}
  horizontalAlignment={Control.HORIZONTAL_ALIGNMENT_LEFT}
  verticalAlignment={Control.VERTICAL_ALIGNMENT_CENTER}
/>

Note that the subscript was clipped off at the bottom with resizeToFit={true} so I set the height to 20 to fix it.

On macOS you can popup the emoji keyboard using Ctrl+Cmd+Space and then search for “subscript” to show all the possible subscript values.

On Windows you can use the Character Map app.

1 Like