[cairo] Intermittent issues using cairo_rotate to rotate an array of text glyphs

Bill Spitzak spitzak at gmail.com
Wed Jan 6 10:38:06 PST 2016


You have to set the font after you do the transform.

However I did not expect this mess, I thought what Cairo did was draw the
font as though the transform it was using before was still in effect (ie
"font lock", similar to the proposed "line width lock").

On Wed, Jan 6, 2016 at 7:45 AM, Matthew Conway <mconway at espial.com> wrote:

> I'm trying to rotate an array of glyphs (where each glyph represents a
> textual character).
>
> Consider the following:
>
> ----------------
> | A TEXT LABEL |
> ----------------
>
> Where the rectangle is a solid coloured background and the text is drawn
> (centered) on top of the rectangle (think subtitles being displayed on a TV
> screen).
>
> For some situations, I need to rotate the text label (rectangle and text)
> 90 degrees clockwise. I do not expect the text rotation to be vertical as
> shown here:
>
> |̄ ̄ ̄ |
> | A |
> |   |
> | T |
> | E |
> | X |
> | T |
> |   |
> | L |
> | A |
> | B |
> | E |
> | L |
> |___|
>
> Instead, I am expecting the text to be rotated (in position) with the
> label.
>
> Sometimes (about 25% of the time), Cairo seems to be rotating random text
> characters and drawing them over the top of other correctly rotated
> characters.
>
> /* Draw the labels background */
> cairo_rectangle( cr, x, y, width, height );
> cairo_set_source_rgba( cr, red, green, blue, alpha );
> cairo_fill( vg->cairo_context );
>
> /* Rotate 90 degrees clockwise and show the text */cairo_translate( cr, x,
> y );
> cairo_rotate( cr, 1.5708 );
> cairo_show_glyphs( cr, glyphs, num_glyphs );
>
>
> Notes:
> 1. The glyphs are created by freetype libraries.
> 2. The system is using Wayland to draw the text labels.
>
>
> I've tried quite a few things, the most successful was to add a call to
> show_glyphs before translating, which reduces the issue to show
> approximatley 5% of the time:
>
> /* Rotate 90 degrees clockwise and show the text */
> cairo_show_glyphs( cr, glyphs, num_glyphs );
> cairo_translate( cr, x, y );
> cairo_rotate( cr, 1.5708 );
> cairo_show_glyphs( cr, glyphs, num_glyphs );
>
>
> I've taken a photo of the screen to show what the issue looks like, it can
> be viewed here:
> http://postimg.org/image/x4g4fne5h/
>
>
> I'm using:
> - latest cairo 1.14.6
> - freetype to create the font glyphs
> - Wayland
>
>
> Thanks,
> Matt.
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20160106/dec8a78b/attachment.html>


More information about the cairo mailing list