nanogui: Finding out width of a text string in terms of pixels


Previous by date: 28 Sep 2006 15:48:00 +0100 Re: Using own true type font with Nano-X, Kiran Mahajan
Next by date: 28 Sep 2006 15:48:00 +0100 Re: Using own true type font with Nano-X, Greg Haerr
Previous in thread: 28 Sep 2006 15:48:00 +0100 Finding out width of a text string in terms of pixels, pratish ganguly
Next in thread:

Subject: Re: [nanogui] Finding out width of a text string in terms of pixels
From: tj ####@####.####
Date: 28 Sep 2006 15:48:00 +0100
Message-Id: <451BE0A3.2090001@comcast.net>

Your problem is you are not correctly using the C language.  You include 
targt the variables (text_width, etc) in the GrGetGCTextSize() call. You 
cannot do that, you pass the ADDRESS, i.e. a pointer, of those tartget 
variables to the GrGetGCTextSize() call. For what you have below the 
call would be:

GrGetGCTextSize( gc , "A" , 1 , (int)NULL , &text_width , &text_height , 
&text_base );

This is not a nano-X convention. This is a C language rule.

tj

pratish ganguly wrote:

> Dear all,
>
> I am trying to find out the width of a text string and write it on the
> middle of the screen using .
> I have tried
>
>    GR_SIZE text_width;        /* variable to store text width of normal
> text             */
>    GR_SIZE text_height;        /* variable to store text height of normal
> text            */
>    GR_SIZE text_base;        /* variable to store text baselineheight of
> normal text            */
>
>    GrGetGCTextSize( gc , "A" , 1 , (int)NULL , text_width , text_height ,
> text_base );
>
>     GrText(wid ,  gc , 400 - ((int)text_width_n * 7) , 240 , "books
> selected", 14 , (int)NULL );         // on a 800 X 480 display
>
> But the text does not appear exactly where I want it to be printed.
> I tried to use other APIs like GrGetFontInfo , but was a little 
> confused by
> the pointer to GR_FONT_INFO structure used in it.
> I tried to find information about the structure on the net.
> It said that it is defined in graphics.h in /usr/src.
> As I could not find graphics.h in my /usr/src directory , I have no
> information about the structure.
> Am I missing something here ?
> Please help in resolving this problem by giving pointers to the solution.
> Also it would be a great help for me if someone could refer some pointers
> for me to find information about the GR_FONT_INFO structure.
>
> Thanks and regards.
>
> Pratish Ganguly
>


Previous by date: 28 Sep 2006 15:48:00 +0100 Re: Using own true type font with Nano-X, Kiran Mahajan
Next by date: 28 Sep 2006 15:48:00 +0100 Re: Using own true type font with Nano-X, Greg Haerr
Previous in thread: 28 Sep 2006 15:48:00 +0100 Finding out width of a text string in terms of pixels, pratish ganguly
Next in thread:


Powered by ezmlm-browse 0.20.