Interactive Ink

How to set character spacing in text mode

I am developing applications using Android's Interactive Ink.  

I would like to specify the character spacing of Japanese text converted in text mode.

I thought that it was impossible to specify character spacing in Interactive Ink settings.

So I added a program to specify character spacing in the drawText method of the canvas class of UIReferenceImplementation.



As a result, although the character spacing became narrower, Japanese is drawText by word break and gaps are made. 

I will post the image at that time.


In the example of this image, drawText is separated by the words "奥様" "は" "取り扱い" "注意".


Is it possible to specify the character spacing by setting Interactive Ink?

Also, if you can not set the character spacing in Interactive Ink, how can I set the character spacing clearer?

Dear Gildas.

Thank you for reply.

It certainly succeeded in narrowing the character spacing.

1 person likes this

Hello kousuke fujii,

There are actually 2 classes that deal with text positioning in the UIReferenceImplementation:

  • `FontMetricsProvider` provides the glyphs positions to the iink SDK, so that we know exactly where each letter is positioned.
  • `Canvas` draws the text.

So if you want to change character spacing, you must change both these classes.

I suggest you try adding  textPaint.setLetterSpacing(-0.3F); at the following locations:

  • Canvas.setFontProperties()
  • FontMetricsProvider.updatePaint()

This way, iink SDK gets the exact information of what is going to be displayed, which should give you what you're looking for.

Best regards


Login or Signup to post a comment