Re: pango_cairo_update_layout()
- From: Behdad Esfahbod <behdad behdad org>
- To: Theo Veenker <Theo Veenker let uu nl>
- Cc: gtk-i18n-list gnome org
- Subject: Re: pango_cairo_update_layout()
- Date: Thu, 23 Oct 2008 12:26:48 -0400
Theo Veenker wrote:
> Hi,
Hi,
> A question regarding pango_cairo_update_layout(). The example in
> http://library.gnome.org/devel/pango/stable/pango-Cairo-Rendering.html
> contains the following fragment:
>
> for (i = 0; i < N_WORDS; i++)
> {
> int width, height;
> double angle = (360. * i) / N_WORDS;
> double red;
>
> cairo_save (cr);
>
> /* Gradient from red at angle == 60 to blue at angle == 240 */
> red = (1 + cos ((angle - 60) * G_PI / 180.)) / 2;
> cairo_set_source_rgb (cr, red, 0, 1.0 - red);
>
> cairo_rotate (cr, angle * G_PI / 180.);
>
> /* Inform Pango to re-layout the text with the new transformation */
> pango_cairo_update_layout (cr, layout);
>
> pango_layout_get_size (layout, &width, &height);
> cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
> pango_cairo_show_layout (cr, layout);
>
> cairo_restore (cr);
> }
>
> Why is it that it doesn't make a difference whether
> pango_cairo_update_layout()
> is called or not. The output is the same. Is it really necessary to call
> this
> function if only the cairo context changes? Why? In my own code I also
> don't
> notice any diffrence if I just drop the pango_cairo_update_layout() call.
It's very delicate. For example, if you have hinting enabled, then the size
of a layout with identity matrix may be different from one of a rotated matrix
as hinting is only done with axis-aligned transforms. And for pango to pick
up the matrix from your cairo_t you need to make that function call.
behdad
> Theo
>
>
> _______________________________________________
> gtk-i18n-list mailing list
> gtk-i18n-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]