Displaying mathematical equations

Hi all,
I’m trying to build a math game where i would like to display some (simple) mathematical equations. Is there a way to write for example: x^2 = 5 where the ^2 term is displayed in the propper way as is the case by Latex. Is there already a library of some sort that i can use or do i need to use a 3rd party to display these equations? I’m quite new at this, so maybe i’m looking at the wrong place.
Thanks in advance,

1 Like

Hello, I am not aware of a plugin or feature for Solar2D that can perform that formatting on text for you automatically.

The way I understand it, there is no native way of adding superscript/subscript in fonts and it’s something that you may have to handle in your program by changing font sizes and text positions to make them appear as superscript or subscript.

That being said, text is just another display object once it’s rendered and you can fetch its width and height and then write your own routines for adding mathematical symbols and superscript etc relative to the positions of other text. It’s definitely doable and writing your functions, even though a little tedious at first, will provide you more flexibility for how you want to implement things and it’s obviously a one-time thing and will be available to you for future projects.

Welcome to Solar2D and hope my suggestions helped :slight_smile:

1 Like

Like @famousdoggstudios said, I don’t think there are any ready made solutions for this. However, like they already hinted at, creating a custom solution for LaTeX formatting shouldn’t be all that difficult especially if you utilise bitmap fonts since positioning superscript, subscript and other mathematical notations becomes relatively easy with bitmap fonts (as opposed to using display.newText()).

1 Like