Hi, I'm trying to add a superscript degree sign (∘) in my math view controller.
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
over 8 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) {
List<MathWidgetApi.Symbol> symbols = mWidget.getResultAsSymbolList(); int nbSymbols = symbols.size();
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:
Please let us know if you have any other questions. Best regards
D
David Runemalm
said
over 8 years ago
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
O
Olivier @MyScript
said
over 8 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) {
List<MathWidgetApi.Symbol> symbols = mWidget.getResultAsSymbolList(); int nbSymbols = symbols.size();
David Runemalm
Hi,
I'm trying to add a superscript degree sign (∘) in my math view controller.
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
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) {
List<MathWidgetApi.Symbol> symbols = mWidget.getResultAsSymbolList();
int nbSymbols = symbols.size();
for(int i=0;i<nbSymbols;i++)
{
RectF boundingBox = symbols.get(i).boundingBox;
float top = boundingBox.top;
...
}
Let us know if you need further help.
Best regards,
Olivier
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstDeleted Agent
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:
Please let us know if you have any other questions.
Best regards
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
Olivier @MyScript
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) {
List<MathWidgetApi.Symbol> symbols = mWidget.getResultAsSymbolList();
int nbSymbols = symbols.size();
for(int i=0;i<nbSymbols;i++)
{
RectF boundingBox = symbols.get(i).boundingBox;
float top = boundingBox.top;
...
}
Let us know if you need further help.
Best regards,
Olivier