[cairo] Rendering with PANGO_GRAVITY_EAST leads to different results with image and vectoriel buffer (pdf)

kiwitargetgranule kiwitargetgranule at gmail.com
Thu May 21 18:48:37 PDT 2009


Hello,
when rendering the following japanese utf-8 layout "おろしポン酢" with
PANGO_GRAVITY_EAST, the pdf result is just the first char (CASE define)
while the image result is the entire string.
i certainly missed something but what ? or is this a bug?
thanks in advance
Tristan

========================================
#include <pango/pangocairo.h>
#include <cairo/cairo.h>
#include <cairo/cairo-pdf.h>

#define CASE

int
main (int argc, char *argv[])
{

        cairo_surface_t *surface;
        cairo_t *cr;

    #ifdef CASE
    surface = cairo_pdf_surface_create ("hello.pdf",2000,2000);
    #else
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2000,
2000);
    #endif

        cr = cairo_create (surface);

    PangoFontDescription *font_description;
    PangoLayout *layout;
    PangoContext *context;

    font_description = pango_font_description_new ();
    pango_font_description_set_family (font_description, "serif");
    pango_font_description_set_weight (font_description, PANGO_WEIGHT_BOLD);
    pango_font_description_set_absolute_size (font_description, 100 *
PANGO_SCALE);

    layout = pango_cairo_create_layout (cr);
    pango_layout_set_font_description (layout, font_description);
    pango_layout_set_text (layout, "おろしポン酢", -1);

    //for vertical text
    context=pango_layout_get_context(layout);
    pango_context_set_base_gravity(context,PANGO_GRAVITY_EAST);
    pango_context_set_gravity_hint(context, PANGO_GRAVITY_HINT_STRONG);
    pango_layout_context_changed(layout);

    cairo_set_source_rgb (cr, 0.0, 1.0, 1.0);
    cairo_paint (cr);

    cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
    cairo_move_to (cr, 1000.0, 1000.0);

    /* Inform Pango to re-layout the text with the new transformation */
    pango_cairo_update_layout (cr, layout);

    pango_cairo_show_layout (cr, layout);

    g_object_unref (layout);
    pango_font_description_free (font_description);

    #ifdef CASE
    cairo_show_page(cr);
    #else
        cairo_surface_write_to_png (surface, "hello.png");
    #endif

        cairo_destroy (cr);
        cairo_surface_destroy (surface);

        return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20090522/5b92fb72/attachment.htm 


More information about the cairo mailing list