Pango - how to turn off hyphenation for char wrapping?

I’m using pango for my utf8 to postscript program paps and realized that the behavior of char-wrapping has changed some time ago to insert hyphens. As paps may be used for creating paper copies of source code, this is highly undesirable as the hyphens may be interpreted as being part of the code. So my question is simply, how do you turn off this behavior? I.e. I want to enable char wrapping without hyphens.

I actually found it quite quickly. You need to attach a “non-hyphen” attribute to the pango layout like this:

  PangoAttrList *attrs = pango_attr_list_new ();
  pango_attr_list_insert(attrs, pango_attr_insert_hyphens_new(FALSE));
  pango_layout_set_attributes (layout,attrs);

Now I just wonder who “owns” the memory of attrs and the return of pango_attr_insert_hyphens_new(FALSE). Is the ownership taken over by the layout or am I supposed to free them on my own? I must admit I never fully understood the ownership model in gtk and pango…

pango_attr_list_insert is transfer-full, therefore your code is okay and does not leak.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.