Re: deriving from PangoLayout



Havoc Pennington <hp redhat com> writes:

> Sven Neumann <sven gimp org> writes:
> > 
> > I'd like to change the behaviour of PangoLayout in an application, 
> > but the current design of PangoLayout makes this impossible. I don't 
> > know exactly how this could be solved, but I'll explain what I'm
> > trying to achieve...
> > 
> > I want to draw text to a fixed-size area of the screen and I want
> > to indicate the fact that text has been cut off by showing ellipses 
> > after the last word that fits on the screen.
> 
> Everyone is wanting to do this... we have a number of requests already
> and haven't even shipped yet... ;-)
> 
> See:
>   http://bugzilla.gnome.org/show_bug.cgi?id=59071
> 
> Feature is punted from 2.0 though.
> 
> > Normally I'd try to achieve this by deriving from PangoLayout, adding
> > a height argument and overriding some class functions, but the 
> > current design gives me no chance at all to implement this without
> > copying the whole PangoLayout code which is something I want to 
> > avoid. Owen, do you see any chance to make the PangoLayout struct
> > public and to add virtual functions that can be overriden from
> > derived classes?
> 
> What would the virtual functions be? It's hard for me to envision a
> way to make PangoLayout extensible, since it's huge hunks of
> interdependent text processing. Most features we've added to it so far
> have involved changing quite a few areas of the code.

Actually, I think some changes in this direction are possible.

Less than 1000 of PangoLayout's 4500 lines of code are actually
about shaping and breaking into lines, while the rest are
accessors and functions for handling the laid out text.

So, it should be possible to allow replacing those lines
of code while maintaining the rest, though that would require
some quite substantial code rewriting to remove implicit
assumptions about the positioning of the laid out text.

Certainly not for Pango-1.0.

And I don't think subclassing is the appropriate mechanism
for doing ellipsization....  you really don't want to even
think about replacing those 1000 lines of code unless you
really know what you are doing / are desperate.

You should be able to do a decent job with ellipsing with
the current API, in fact.     

Regards,
                                        Owen





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