Add superscript symbol using the AddSymbol API

David Runemalm

I've noticed that if I specify a bounding box to be right after the last character and slightly above it, it will be added correctly.

The problem is that I don't know how to calculate the bounding box so that the degree sign ends up in superscript and after the last symbol in the recognized text.

Do you know how to specify the bounding box for my superscript degree sign or even better, is there a way to specify the symbol to be in superscript when I add it using the AddSymbol API?

Regards,David

Best Answer

O

Olivier @MyScript
said
almost 3 years ago

Dear David,

the bounding box of each symbol can be gotten as follows:-First, you have to implement the OnRecognitionListener:public class MainActivity extends Activity implements MathWidgetApi.OnRecognitionListener{-Then, after calling the configure, you should set it: mWidget.configure(math, standard); mWidget.setOnRecognitionListener(this);-last, in the onRecognitionEnd function, you have to get the result as SymbolList. For each symbol, you can get the bounding box: @Override public void onRecognitionEnd(MathWidgetApi mathWidgetApi) {

Olivier @MyScript

said
almost 3 years ago

Answer

Dear David,

the bounding box of each symbol can be gotten as follows:-First, you have to implement the OnRecognitionListener:public class MainActivity extends Activity implements MathWidgetApi.OnRecognitionListener{-Then, after calling the configure, you should set it: mWidget.configure(math, standard); mWidget.setOnRecognitionListener(this);-last, in the onRecognitionEnd function, you have to get the result as SymbolList. For each symbol, you can get the bounding box: @Override public void onRecognitionEnd(MathWidgetApi mathWidgetApi) {

David Runemalm

Thank you, great illustration of the calculus!Would you also point me to the API for finding out the bounding box of the previous operand?

Regards,David

C

Claire @MyScript

said
almost 3 years ago

We are aware that it is difficult to evaluate bounding box coordinates with the current widget version and we hope to change it in the future. In the meantime, we can provide you with explanations for this particular case to help you moving forward. Firstly, the bounding box size will have to be set proportionally to the font, then you will have to apply a calculus to define the superscript bounding box size compared to the bounding box size of the previous operand, as shown below: