9

My issue is that during smooth scaling applied to Skia canvas (with concat method) the text appears to scale in "spurts", non-uniformly. The issue is particularly evident on Android platform with FreeType 2 back-end.

I believe this is how general text scaling works in Skia - first apply text size to font engine, then extract glyph bitmap and transform it with "remainder" matrix to achieve the desired final size. But somehow final remaining scaling is not applied which results in such spurts amidst transition between integral values of text size. The same thing with pure Java/Android canvas appears to work impeccably (text scales smoothly).

My question is how can I fix that behavior? Maybe there is some build configuration flag I could tweak, maybe SkPaint runtime flag?

Skia revision is m59.

Vsevolod Ganin
  • 623
  • 8
  • 22

2 Answers2

2

I don't know Skia, but generally when I see this behavior with scaling text, it's because you're casting your scaling float to an int.

float scale = someValue;
int someOtherVar = scale;
... some scaling math on someOtherVar...
text.setScale(someOtherVar)

This will cause the described behavior

Never convert any scaling variables to int's until the very last step.

NapkinTrout
  • 269
  • 1
  • 9
  • Thank you. This is definitely not the case here because any other geometry on canvas scales properly and smoothly. And I don't apply any additional scale on text or something. – Vsevolod Ganin Sep 25 '17 at 08:40
0

When painting text, try setting Paint.isLinearText. This causes Skia to render the text to a path before applying transformations. My testing shows that this causes scaling to become smooth.