Text resizing isn't linear

已查看 113 次
跳至第一个未读帖子

שחר לנגבהיים

未读,
2019年11月10日 11:16:542019/11/10
收件人 skia-discuss
Hi,
As this video shows, some fonts don't scale linearly on all continuous values when drawn using SkTextBlob - there's a subtle jitter when the size "jumps" between some values.
From what I read, this isn't necessarily a bug - some fonts just don't scale linearly. 
I do need linear scaling, and I found a suggestion - to extract the glyph paths for a certain size, and scale them manually.

Has someone tried to tackle such an issue with Skia? I couldn't understand from the API how to extract a glyph run for a combination of font and text, or how to scale a glyph run. If anyone has any pointers, I'd really appreciate the help.
 

Ben Wagner

未读,
2019年11月11日 09:36:082019/11/11
收件人 skia-d...@googlegroups.com
If you want something close to linear scaling for text you'll want to
set hinting to none, set baseline snapping to false, set subpixel to
true, and set linear metrics to true. This will generally give you
something close. In your example, it appears what you are seeing is
the baseline snapping. For full animation you may still see some
wiggle. We're currently working on a way to work around that (it's a
trade-off of performance vs accuracy for animations).
> --
> You received this message because you are subscribed to the Google Groups "skia-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/69b3f098-c44c-48ed-99f2-65ed516ed045%40googlegroups.com.

Ben Wagner

未读,
2019年11月11日 09:37:572019/11/11
收件人 skia-d...@googlegroups.com
Note that there is an issue with trying to draw from paths, which is
that not all glyphs have paths. In particular, color glyphs may be
bitmaps or a set of colored paths (or something even more complex).

Shachar Langbeheim

未读,
2019年11月11日 11:14:342019/11/11
收件人 skia-discuss
Thanks for the help!
Is there a branch in which I can test this thing you're working on?

Ben Wagner

未读,
2019年11月11日 12:45:462019/11/11
收件人 skia-d...@googlegroups.com
Not at the moment, there is
https://skia-review.googlesource.com/c/skia/+/252927 , which is
probably the right API, but we will need to actually implement it
differently.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CA%2B_KjGa1Dwvg3ENB6S1QhTb5X3S0eCNGqsiWtoLYPDbJwa8J%3Dw%40mail.gmail.com.

Shachar Langbeheim

未读,
2019年11月17日 03:14:482019/11/17
收件人 skia-discuss
Thanks, your suggestion has improved things, but as you predicted it hasn't completely solved the issue.
Compare this to this. The wiggle seems to have disappeared, but the animation still isn't smooth, and also after some point the subpixel edging causes a stroke to appear. 
Are there any other avenues you can think of?

Shawn Riordan

未读,
2019年11月17日 10:19:022019/11/17
收件人 skia-discuss
If the text is not changing, you could just draw the text and shadow once (at highest scale / resolution) into an off-screen surface.  Then grab the image from that surface. Then the animation would be a bunch of calls to SkCanvas::drawImage() using a different matrix each time.
>> > To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.

>> > To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/69b3f098-c44c-48ed-99f2-65ed516ed045%40googlegroups.com.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "skia-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.

>> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CAE1kqqQ0dDBST3zTN3YQcwhew2E7WKt%3D7K%3DnHGOx59x%3DiBwAJA%40mail.gmail.com.
>
> --
> You received this message because you are subscribed to the Google Groups "skia-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CA%2B_KjGa1Dwvg3ENB6S1QhTb5X3S0eCNGqsiWtoLYPDbJwa8J%3Dw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.

Shachar Langbeheim

未读,
2019年11月17日 13:27:532019/11/17
收件人 skia-discuss
This solution is suboptimal for several reasons - for example, the highest scale / resolution won't necessarily scale well for every smaller resolution, and it means that I need to keep a separate offscreen surface for every single text.
I think that scaling the path is a better way to go, once I understand how to extract the path from a text blob.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/9bb1520c-2680-48d0-9a39-cf58d5f8e0d6%40googlegroups.com.

Shachar Langbeheim

未读,
2019年12月8日 04:47:292019/12/8
收件人 skia-discuss
If anyone is interested, using SkTextUtils::GetPath and then transforming the path seems to do the trick.
回复全部
回复作者
转发
0 个新帖子