[cairo] cairo + pango + vertical text
Kalle Vahlman
kalle.vahlman at gmail.com
Wed Oct 31 02:21:51 PDT 2007
2007/10/31, Nguyen Vu Hung <vuhung16plus at gmail.com>:
[snip]
> I've tried the following code, but the text "hihi" didn't get rotated.
[...]
> pango_context_set_base_gravity ( context, PANGO_GRAVITY_SOUTH);
The documentation pointed to above states:
"Gravity of normal Latin text is south."
So you are getting what you asked for, normally orientated latin text.
You are not rotating the output of the layout either as far as I can
tell, there's no cairo_rotate visible in the code excerpt.
Now, if you want this (a layout rotated 90 degrees clockwise):
h
i
h
i
you'll probably want to use GRAVITY_EAST (to rotate the glyphs
counter-clockwise). This alone won't suffice though, since this is
latin script and thus will be handled with the SOUTH rotation
automatically unless you set the gravity hint to
PANGO_GRAVITY_HINT_STRONG to force the gravity setting for latin text
too.
So the code looks something like:
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_move_to (cr, x, y);
cairo_rotate(cr, 90 / (180.0 / G_PI));
pango_cairo_show_layout (cr, layout);
Hope this helps.
--
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi
More information about the cairo
mailing list