Getting length, in pixels, of a line of text




How can I determine how long a line of text will be, in pixels, in any 
given font?

I want to use a GtkText widget to display lines of text which have varying
lengths (think xconsole), and which will mostly be longer than the GtkText
widget is wide.  I don't want the lines to wrap, because it makes
these lines difficult to read: there is important info in the first 15 chars
or so.  

So, I thought, I will put the GtkText into a GtkScrolledWindow, and adjust
the width of the GtkText to be just longer than the width, in pixels, of 
the longest line it contains.  Then, hopefully, I could use the 
GtkScrolledWindow horizontal scrollbar to scroll right to read the rest of
the long line, if I wanted.

Is there a gtk/gdk solution to this question?

Many thanks

Chris
--
Chris Malek, Sys. Admin.           cmalek@etho.caltech.edu
Division of Biology, 216-76
California Institute of Technology
Pasadena, CA  91125



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