This page explains how you can use iink SDK without using iink SDK rendering.
MyScript iink SDK was primarily designed as a graphical-oriented, interactive solution that lets end users easily input and edit their handwriting. With the Editor, interactivity is rendering driven, relying on iink SDK rendering.
Sometimes, however, it makes sense to integrate iink SDK off-screen, without any user interface or with a user interface based on your own rendering, not on iink SDK one.
It may be required to add handwriting recognition capabilities to an existing non-interactive application in batch mode. It might also be useful to process input in incremental mode without displaying the recognition result, for instance to implement an ink search indexing service.
Off-screen setup is very similar to the graphical use case:
Clear the editor between sessions - A common mistake in batch mode is to forget cleaning the part between imports, which causes new ink to be stacked on top of the one from the previous session. In most cases, you thus have to clear the part before processing new input. Creating a new part for each new session and removing the previous one will free the memory from a potentially unwanted undo/redo history.
pointerEvents()
on the editor, make sure to set the processGesture
parameter to false
to avoid side-effects and lengthy recognition time.waitForIdle()
on the editor to wait for the recognition to complete before exporting.// Configure the engine to disable guides (recommended)
engine.getConfiguration().setBoolean("text.guides.enable", false);
// Create a renderer with a null render target
float dpiX = ...;
float dpiY = ...;
Renderer renderer = engine.createRenderer(dpiX, dpiY, null);
// Create the editor with a default tool controller
Editor editor = engine.createEditor(renderer);
// The editor requires a font metrics provider and a view size *before* calling setPart()
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
Map<String, Typeface> typefaceMap = new HashMap<>();
editor.setFontMetricsProvider(new FontMetricsProvider(displayMetrics, typefaceMap));
editor.setViewSize(640, 480);
// Create a temporary package and part for the editor to work with
ContentPackage package = null;
try
{
package = engine.createPackage("text.iink");
}
catch (IOException e)
{
e.printStackTrace();
}
ContentPart part = package.createPart("Text");
editor.setPart(part);
The editor can now be used to process pointer events and export the results.
Up to iink SDK 2.0, it was necessary to use the iink SDK rendering in order to benefit from iink SDK interactive features. In 2.1, while keeping our classical Editor and its related objects and interfaces, we introduced the Offscreen Interactivity feature based on an OffscreenEditor.
This new feature lets the integrator programmatically drive the content model update by keeping the incremental recognition principle and using gesture notifications. The application can rely on its own rendering to manage the captured strokes and display its model. Recognition results are available on demand with dedicated APIs.
For the moment, this feature is only available for “Raw Content” parts. It relies on these new objects and interfaces:
Editor
and content of changesets. The goal of the HistoryManager
is to allow you to use undo/redo to preserve text recognition, rather than redoing strokes, which can change stroke order and recognition output.HistoryManager
is associated with an OffscreenEditor
on creation, only if offscreen-editor.history-manager.enable
is set to true
(by default this parameter is false
).
It can then be accessed with OffscreenEditor
getHistoryManager()
method.➤ For more details, refer to the API documentation documentation and/or ask question on our developer forum.