Re: [gtk-list] gtk+ text entry and font sizes, help requested




Michael Craig <mcraig@tjhsst.edu> writes:

> Hi,
> 
> I'm rather new to gtk+ but have begun using it quite seriously the past few
> days. I have a problem involving text entry widgets that
> I haven't been able to resolve, even though it seems somewhat
> simple. I'm trying to reduce the onscreen length of a text
> entry widget. For example I might set the max. allowable
> characters to 4, but the actual length of the widget onscreen
> is always much longer, and aside from setting the usize I
> don't know how to make it shorter. Is there a way to make it
> shorter without having to set the usize, so that it will look
> right no matter what font is in use? 

Not really, though there should be.

> If not, is it somehow
> possible to get information on the font that is currently
> being used (specifically in my case, the maximum height and
> width of the largest character)? Any help would be greatly
> appreciated.

 - You don't really need to set the height.
  
   gtk_widget_set_usize (entry, 50, -1);

   Means 50 pixels wide, and the normal height.

 - The height of a font can be computed as:
  
   font->ascent + font->descent

 - The maximum width of the font can't be gotten currently without
   digging into the X font structures, but you can probably 
   approximate it with something like:

    max_width = gtk_char_width (font, "W");

Regards,
                            Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]