Measure Text Height

515 views
Skip to first unread message

Jay Van Diyk

unread,
Aug 11, 2013, 9:28:37 AM8/11/13
to skia-d...@googlegroups.com

Hi, How do we measure Text Height? I couldn't find a function that does this

MeasureText() only returns the width. 

Any thoughts?

Ratnakar Pai

unread,
Aug 11, 2013, 10:30:49 AM8/11/13
to skia-d...@googlegroups.com
Hi,

You could try SkPaint::getFontSpacing(). This gives the recommended line spacing for the current font-strike set on the paint.

If you want the absolute height(instead of recommended spacing), you could try the SkPaint::getFontMetrics() API and calculate fTop+fBottom for the text height.



--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jay Van Diyk

unread,
Aug 12, 2013, 8:28:58 AM8/12/13
to skia-d...@googlegroups.com
Hi ratpi,

Thanks for the reply.

I tried your SkPaint::getFontMetrics() API but get

SkPaint::FontMetrics *metrics;
 skPaint->getFontMetrics(metrics);
SkScalar height = metrics->fTop+metrics->fBottom;


But I got the negative value instead.

Could you elaborate on what fTop and fBottom actually are?

I read the docs but can't seem to understand.
Sorry.

Thank you

Jay
Reply all
Reply to author
Forward
0 new messages