使用pango_layout时,空格分隔为新行的文本

问题描述

我是嵌入式Linux的新手。我正在尝试显示不同对齐方式的字符串文本。但是当我使用Pango时。它对于单个单词正确对齐,其中没有空格字符。但是我的某些字符串包含空格以分隔单词。但是在使用pango_layout时,它会将int新行对齐。 我正在使用GCC作为编译器在Ubuntu中运行应用程序,系统包含目录显示pongo-1.0。

下面是我的代码

 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,rgbRed,rgbGreen,rgbBlue);

   //Set width of the layout to align correctly
   cairo_text_extents(pCntxt,&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);

左对齐的输出

Sample 
text 
#1

右对齐的输出

 Sample 
   text 
     #1 

如何使用Pango布局将其绘制成一行?我在Pango布局中尝试了其他几个选项,但没有运气

我想要这样的文字

              Sample text #1//Using left align
Sample text #1  //Using right align
            X,Y location here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)