Re: Use Pango Layouts with GooCanvas Text



Damon, thanks for the reply. I have tried to split the text using newline characters in several ways, but the problem is that the number of characters in each line depends on the size of text, which the user can select. Using Pango Layouts in the Gnome Canvas code, this could be done by using a Pango::LayoutLine which would simply return this number through the get_length() method.

I have spent a lot of time on this and have gone through all the examples, but don't see the Goocanvas::Text class providing similar functionality. Please let me know if I am missing something.

On a somewhat related note, how can I manipulate *just* the size of text in Goocanvas without modifying the font family?

Thanks,

Aditya

Damon Chaplin wrote:
On Fri, 2009-08-21 at 16:35 -0700, Aditya Rajgarhia wrote:
Hi,

I am a beginner with GTK and am porting a project from Gnome Canvas to
GooCanvas (using the C++ APIs). I have mostly finished it, but there
are a few things I can't figure out. One of them is how to ellipsize
Text while using multiple lines.

In the existing code. the Gnome Canvas code creates a Pango layout
from the Gnome Canvas Text like this:

   Glib::RefPtr<Pango::Layout> layout =
      Glib::wrap(GNOME_CANVAS_TEXT(text->gobj())->layout, TRUE);

and then calls a utility function which ellipsizes the text in a
particular way:

   text->property_text() = Ellipsize(string, layout, width, lines);

The Ellipsize function then splits the string into multiple lines
using Pango::LayoutLine, ellipsizes it and returns the text.

How can a achieve a similar functionality with GooCanvas? I tried
replacing GNOME_CANVAS_TEXT in the above code with GOO_CANVAS_TEXT but
that is not valid. Of course, GooCanvas::Text does have a
property_ellipsize() but I want multiple lines, preferably while using
the same mechanism (the Pango stuff) that the existing code uses.

GooCanvasText can ellipsize multiple lines, if you separate them with
newline characters.

If you really need your own code for custom ellipsization I think you'll
have to create your own canvas item.

Damon




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