Re: Has the pango_itemize call changed since libpango 1.8? We now get severe valgrind issues (invalid read and others) associated with this call.



On Mon, 2007-03-26 at 02:14 -0700, Alan W. Irwin wrote:
> On 2007-03-26 02:35-0400 Behdad Esfahbod wrote:
> 
> > Pango 1.8.1 should easily compile on a recent distro.
> 
> The actual issue is what is the proper way to call pango_itemize, and I
> think compiling old libraries (with the emphasis on the plural because
> libpango has many library dependencies) to test our existing code is an
> extremely uncertain way to find out the answer to that question.
> 
> > More recent versions of Pango have a lot
> > of setters and getters for PangoContext:
> 
> > http://developer.gnome.org/doc/API/2.0/pango/pango-Text-Processing.html
> 
> Thanks for that helpful tip.  Does anybody have a pointer to actual working
> code that uses these PangoContext setters to establish the first argument to
> pango-itemize?

   15 /** Manage PangoContext*
   16  */
   17 class ContextMgr : public Manager<PangoContext*> {
   18   public:
   19     ContextMgr(
   20         const char* const lang="en_US.UTF-8",
   21         const int dpiX = 72,
   22         const int dpiY = 72) {
   23       _t = pango_ft2_get_context(dpiX, dpiY);
   24       pango_context_set_language(_t, pango_language_from_string(lang));
   25       pango_context_set_base_dir(_t, PANGO_DIRECTION_LTR);

That looks OK

   26     }
   27 
   28     ~ContextMgr() {
   29       if (_t && isOwner())
   30         free(_t); // there is no corresponding pango_context_free in the API
 
Youch! PangoContext derives from GObject, so g_object_unref().

Generally, very few people use pango_itemize() directly; PangoLayout is vastly
easier to use and works for most uses. Off-hand the only code (other tha
PangoLayout) that I can think that uses pango_itemize() directly is GtkHtml
but I would not recommend the source code to that as a reference; it's
pretty messy code and not one bit simple.

My general recommendation is:

 - Use PangoLayout unless you need something that is very different from 
   rectangular paragraphs of text. (Single unwrapped lines or strings
   are a subset of rectangular paragaphs...)
 - Use cairo for Postscript output instead of rolling your own on top
   of PangoFT2.

						- Owen





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