Measure Text Length in Pixel?

450 views
Skip to first unread message

Jay Van Diyk

unread,
Jul 30, 2013, 8:24:16 AM7/30/13
to skia-d...@googlegroups.com
Hi,

I am trying to retrieve the size of a text in pixel.

Here is a function I wrote:

int TextDrawer::width(const void *text)
{
    SkScalar width = skPaint->measureText(text, 2);
    return width;
}

and when I use the function like this.

QString outputString="HELLO SKIA";
textDrawer->width((void *)outputString.utf16());


It works, but it returns 56 . I dont know what unit is that value in, but it is definitely not in PIXEL as I wanted it to be.

Question:

How do I measure a text's width in PIXEL????

Thank you

Jay

Mike Reed

unread,
Jul 30, 2013, 9:31:28 AM7/30/13
to skia-d...@googlegroups.com
measureText returns the advance-width for the text string, based on the typeface and textsize currently set on the paint. It is returned in pixels, but may be fractional, depending on the typeface and settings (e.g. kSubpixelText, kLinearText, etc.).



--
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 9, 2013, 1:20:35 AM8/9/13
to skia-d...@googlegroups.com
Thank you
Reply all
Reply to author
Forward
0 new messages