Discussion:
[directfb-users] Measure text size
Sagaert Johan
2012-02-10 00:29:26 UTC
Permalink
Hi

Is there a function i could use to measure the size of a string given the used font and fontsize ?

I have only limited space on my screen and want to scroll the text if its size (width) would be larger then the screen width.
(like a banner )

Thanks in advance.

Sagaert Johan
Pravinkumar Chavan
2012-02-10 05:05:03 UTC
Permalink
Post by Sagaert Johan
Hi
Is there a function i could use to measure the size of a string given the
used font and fontsize ?
I have only limited space on my screen and want to scroll the text if its
size (width) would be larger then the screen width.
(like a banner )
Thanks in advance.
Sagaert Johan
http://directfb.org/docs/DirectFB_Tutorials/text.html may be this could
help you...
_______________________________________________
directfb-users mailing list
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users
--
**
_________________________

Pravinkumar Chavan
Software Engineer
+919867107370
En Route Media Pvt. Ltd.


**
*_________________________*
*
*
Ezequiel García
2012-02-10 20:16:20 UTC
Permalink
Oops, forgot to send to directfb-users list.

---------- Forwarded message ----------
From: Ezequiel García <***@gmail.com>
Date: Fri, 10 Feb 2012 11:53:50 -0300
Subject: Re: [directfb-users] Measure text size
To: Sagaert Johan <***@skynet.be>

Hi,
Post by Sagaert Johan
Is there a function i could use to measure the size of a string given the
used font and fontsize ?
Yes. The function is IDirectFBFont::GetStringExtents():

http://www.directfb.org/docs/DirectFB_Reference_1_4/IDirectFBFont_GetStringExtents.html

Here goes a small "pseudo-code" example (won't compile):

IDirectFB* dfb;
IDirectFBFont* font;
DFBFontDescription font_desc;
DFBRectangle rect;

// Create main interface
DirectFBCreate(&dfb);

// Create font
dfb->CreateFont(dfb, "Tiresias.ttf", &font_desc, &font);

// Measure a text
font->GetStringExtents(font, "measure this", -1/*measure whole
string*/, &rect, NULL);

That's all. Hope it helps,
Ezequiel.

Loading...