Conversion

In iink SDK terminology, “conversion” refers to the replacement of some handwritten content by a clean, typeset equivalent.

Conversion vs. recognition

Conversion is an explicit action you can trigger to replace ink content with a typeset equivalent. It is different from the recognition process it relies on, which runs in background and interprets any input, making it interactive.

You can convert any content block by calling the Convert() method of your editor object.

Target state

When calling Convert(), you are expected to provide the target state you want to reach:

  • DigitalPublish - Typeset content, adapted for publication (small font size, and fitted graphics in the case of a Text Document),
  • DigitalEdit - Typeset content, suitable for edition (font size that is large enough for editing, expanded graphics).
You can convert back and forth between the DigitalPublish and DigitalEdit states.

Fonts

Selecting a font family

To convert your text content, iink SDK needs to have information about the font family you use. The family choice relies on your styling options: by default a font family is defined for each content type that you can modify by setting a theme. If the font family is not installed on the device on which your application is running, iink will use the device default font family.

If the font family that is actually used by the device does not support all symbols, you might get some inappropriate squares or symbols displayed instead of expected glyphs. In order to improve this situation, you can consider two options:

  • Either you have the possiblity to install the default font family on the targetted device.

  • Or you have another font family available on the device that supports more symbols than the device default font family. In this case, you can set a theme to use this font family.

Computing font metrics

In addition, iink SDK requires you to attach to your editor an object implementing the IFontMetricsProvider interface using SetFontMetricsProvider().

As implementing a font metrics provider is a rather touchy task, MyScript provides you via the iink SDK example repository with a reference implementation.

If you rely on the reference implementation, registering an editor with the editor view automatically attaches a font metrics provider to your editor.

Application to the example

You can add a button to the example calculator to trigger the conversion. As previously explained, associating the editor view with the editor automatically attaches a font metrics provider.

As a math part is composed of a single block (hosting the math content), you can select it using the GetRootBlock() method of the editor. If pressing the “solve” button of the UI calls a Solve() method of the Calculator object, an implementation can be:

public void Solve()
{
  editor.Convert(editor.GetRootBlock(), ConversionState.DIGITAL_EDIT);
}
As you are dealing with math content and did not deactivate the solver, converting the math will trigger solving, if the required conditions are in place.

Here is an example of what it could look like:

The next step of the guide will take you through the ability to import or export content.

We use cookies to ensure that we give you the best experience on our website Read the privacy policy