0
這是怎麼回事?開羅+ Pango佈局非左對齊
pango_font_description_set_family(font.get(),"Serif");
pango_font_description_set_absolute_size(font.get(), 16 * PANGO_SCALE);
int w;
int h;
pango_layout_set_font_description (layout.get(),font.get());
pango_layout_set_width(layout.get(),960*PANGO_SCALE/4);
pango_layout_set_text(layout.get(),"Lorem ipsum dolor sit amet, consctetur adipiscing elit. Nulla vel enim est. Phasellus quis lacinia urna.", -1);
//I want right alignment for this layout
pango_layout_set_alignment(layout.get(),PANGO_ALIGN_RIGHT);
pango_layout_get_pixel_size(layout.get(),&w,&h);
cairo_set_source_rgb (cr.get(), 0.0, 0.0, 0.0);
//Move draw point to the right edge, taking the size of the layout into account
cairo_move_to (cr.get(), 960 - 16 - w,16);
pango_cairo_show_layout(cr.get(), layout.get());
//Draw test rectangle around the text.
cairo_rectangle(cr.get(),960-16-w,16,w,h);
cairo_stroke(cr.get());
cairo_surface_write_to_png(surf.get(),"test.png");
如圖所示,文本位於所需位置的右側。我如何正確定位文本? cairo_move_to
顯然不是這裏的正確選擇,或者是否存在影響PANGO_ALIGN_CENTER
和PANGO_ALIGN_RIGHT
行爲的任何已知錯誤。 PANGO_ALIGN_LEFT
按預期工作。