2

I'm having a problem with Pango rendering under a rotated matrix. I'm attempting to draw a label (see code below) which happens inside of an animating Cairo matrix rotation.

As the label rotates, the text jitters, seeming to grow and shrink in weight, becoming thickest at diagonal angles, and thinnest at orthogonal angles. See this comparison:

http://www5.picturepush.com/photo/a/4666818/640/Anonymous/pango-rotation.jpg

I'd like the rotated text to generate as if it were just rotating shape paths, and not trying to change the look of the text based on the angle. Any ideas of how I could do this?

Thanks, Sean


        //Draw text with Pango
        PangoLayout *layout;
        PangoFontDescription *desc;

        // pCr is the cairomm context ptr.
        // pCr->cobj() is the underlying C Cairo context ptr.
        pCr->set_source_rgb(0.0, 0.0, 1.0);

        layout = pango_cairo_create_layout(pCr->cobj());
        // text is the label string
        pango_layout_set_text(layout, text.c_str(), -1);

        desc = pango_font_description_from_string("Sans Bold 12");
        pango_layout_set_font_description(layout, desc);

        pango_cairo_layout_path(pCr->cobj(), layout);
        pCr->fill();

        pango_font_description_free(desc);
        g_object_unref(layout);
4

1 回答 1

0

我只能将 Cairo 和 Pango 与 Python 一起使用,而不是 C,但我的第一个猜测是修补 ANTIALIAS:

pCr.set_antialias(cairo.ANTIALIAS_DEFAULT)

(这是python的语法,不是C)

您可以尝试cairo.ANTIALIAS_SUBPIXELcairo.ANTIALIAS_NONE查看是否有区别。

此外,我在您的代码中找不到任何旋转,但也许您在渲染文本后旋转文本,此时您应该先执行旋转,然后渲染(像素化)文本(矢量路径)。

希望能帮助到你。

于 2011-08-16T19:08:09.643 回答