How to print superscript in vtkTextActor?

How to print superscript in vtkTextActor?

For example: for text.SetInput('mm^2'), I hope it show:

image

import vtkmodules.all as vtk

text = vtk.vtkTextActor()
text.SetInput('mm^2')
text.SetDisplayPosition(100, 100)
property = text.GetTextProperty()
property.SetFontSize(20)

render = vtk.vtkRenderer()
render.AddActor(text)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
iren.Start()

I can not find a solution in network.

This document should help. I would look for tests that exercise the math text feature.

https://www.paraview.org/Wiki/ParaView/Equation_Rendering

@danlipsa Thank you for the kindly reply. The document said ParaView will check text for a pair of "$" symbols surrounding a MathText expression..

So, the code is modified as text.SetInput('$mm^2$'). The vtkTextActor can show the superscript.

However, it also report some bugs:

It require matplotlib is installed. And it do not support multiple lines.

Hope vtk provide native method to render superscript.

Multiline support has been fixed recently:
https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7458

I don’t know about the warning you see. Please file a bug report if it is not there alread.

Thanks!

@danlipsa I have posted a question about this warning. Please have a look about more details.