pango_layout_set_alignment not working for printing



Hi,

I have code that is printing Pango-formatted text, and its working fine. But
now I have a case where I want to print some text centered, which I'm trying
to do using pango_layout_set_alignment and I can't get that to work.

At the start of the print I call gtk_print_context_create_pango_layout to
create a PangoLayout, and then pango_layout_set_text and
pango_layout_set_attributes to set the text and pango attributes in it. I
then print the text line-by-line using pango_layout_get_line_readonly to
extract the line and pango_cairo_show_layout_line to render it. This all
works fine - I can set attributes like font size and color and they print as
they should.

So, to try to print some text centered I added a call to
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER) on the PangoLayout
right after setting the text and attributes in it, and that did nothing -
the text still prints left-aligned.

I also tried pango_layout_set_justify which also did nothing, and to make
sure the layout was wide enough, added this which also made no difference:
        gdouble pageWidth = gtk_print_context_get_width(context);
        pango_layout_set_width(layout, pageWidth * PANGO_SCALE);

Anyone got any ideas what I might be missing?

Ian 




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