The most reasonable way to render multi-line text, and the most reasonable way to depend on skia

686 views
Skip to first unread message

Evan Zalys

unread,
Jun 3, 2013, 4:58:48 AM6/3/13
to skia-d...@googlegroups.com
Say I'm interested in rendering some text that takes up several lines within the confines fixed horizontal-width box. What's the general strategy to do this? Shall I take one word, then measure it (paint.measureText), see if it's within bounds, add another word, and keep on with this until I exceed the horizontal width of the container I wish to fit, and then start over on the next line with the overflowing word (maybe perhaps applying some hyphenation strategy upon overflow?) Is there a better way to do this?

Secondly, I'm interested in what you folks think the most reasonable way to depend on skia as a library is. It doesn't seem to have an install target that dumps a bunch of .a files in /usr/lib or what have you, and I understand the API isn't a stable thing, but I'd still like to incorporate it in my project and I'm not sure what the recommended organizational strategy is here.

Thanks!
Evan

a.c...@weelya.com

unread,
Jun 3, 2013, 6:15:18 AM6/3/13
to skia-d...@googlegroups.com
Hey Evan,

1. Here is what I've personally came up with :

https://gist.github.com/paraboul/bf92481c8c75a2f5f26b

2. I link against skia (every .a I need) statically.

Anthony.
> --
> 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 post to this group, send email to skia-d...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/skia-discuss?hl=en [1].
> For more options, visit https://groups.google.com/groups/opt_out
> [2].
>
>
>
> Links:
> ------
> [1] http://groups.google.com/group/skia-discuss?hl=en
> [2] https://groups.google.com/groups/opt_out

Ben Wagner

unread,
Jun 3, 2013, 10:18:44 AM6/3/13
to skia-d...@googlegroups.com
Note that Skia has something like this, see views/SkTextBox.cpp . It's
somewhat limited, however. Skia has been trying to avoid the
complexity of text shaping until it can be done correctly.
> Visit this group at http://groups.google.com/group/skia-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

杨继超

unread,
Jun 4, 2013, 6:12:44 AM6/4/13
to skia-d...@googlegroups.com
For a small amout of text, SkPaint::breakText is what you need.
For large amount of text, try guess algorithm(first guess a number and then fix it with measureText) or try to use binary divide algorithm.
Reply all
Reply to author
Forward
0 new messages