Text with spaces split to new line when using pango_layout
I am new to the Embedded Linux. I am trying to display a string text different alignments. But when I use the Pango. It aligned correctly for the single words without space characters in it. But some my string contains spaces to separate words. But it aligned int the new line when using the pango_layout.
I am running my application in Ubuntu using GCC as the compiler and the system include directory shows pongo-1.0.
And my code is given below
pLayOut = pango_cairo_create_layout(pCntxt);
pango_layout_set_text(pLayOut, "Sample text #1", -1);
desc = pango_font_description_from_string(font);
pango_layout_set_font_description(pLayOut, desc);
pango_font_description_free(desc);
cairo_set_source_rgb(pCntxt, pRgbBlk->rgbRed, pRgbBlk->rgbGreen, pRgbBlk->rgbBlue);
//Set width of the layout to align correctly
cairo_text_extents(pCntxt, "Sample text #1", &extents);
pango_layout_set_width(pLayOut, extents.width);
cairo_move_to(pCntxt, pPar->tpUlX, pPar->tpUlY);
pango_layout_set_alignment(pLayOut, pPar->tpAlign);
pango_cairo_update_layout(pCntxt, pLayOut);
pango_cairo_show_layout(pCntxt, pLayOut);
The output of the left alignment
Sample
text
#1
The output of right alignment
Sample
text
#1
If I set the width to -1, The output will print in a single line but won't align the text in either way.
Please help me..., I am tired of trying this.
Edited by Arun Kumar K S