Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
text_rotate.c File Reference
#include "cairo_test.h"

Go to the source code of this file.

Defines

#define WIDTH   150
#define HEIGHT   150
#define NUM_TEXT   20
#define TEXT_SIZE   12

Functions

static void draw (cairo_t *cr, int width, int height)
int main (void)

Variables

cairo_test_t test

Define Documentation

#define HEIGHT   150

Definition at line 63 of file text_rotate.c.

#define NUM_TEXT   20

Definition at line 64 of file text_rotate.c.

#define TEXT_SIZE   12

Definition at line 65 of file text_rotate.c.

#define WIDTH   150

Definition at line 62 of file text_rotate.c.


Function Documentation

static void draw ( cairo_t *  cr,
int  width,
int  height 
) [static]

Definition at line 75 of file text_rotate.c.

{
    int i, x_off, y_off;
    cairo_text_extents_t extents;
    static char text[] = "cairo";

    cairo_select_font (cr, "Bitstream Vera Sans",
                     CAIRO_FONT_SLANT_NORMAL,
                     CAIRO_FONT_WEIGHT_NORMAL);
    cairo_scale_font (cr, TEXT_SIZE);

    cairo_set_rgb_color (cr, 0,0,0);

    cairo_translate (cr, WIDTH/2.0, HEIGHT/2.0);

    cairo_text_extents (cr, text, &extents);

    if (NUM_TEXT == 1) {
       x_off = y_off = 0;
    } else {
       y_off = - round (extents.height / 2.0);
       x_off = round ((extents.height+1) / (2 * tan (M_PI/NUM_TEXT)));
    }
  
    for (i=0; i < NUM_TEXT; i++) {
       cairo_save (cr);
       cairo_rotate (cr, 2*M_PI*i/NUM_TEXT);
       cairo_set_line_width (cr, 1.0);
       cairo_rectangle (cr, x_off - 0.5, y_off - 0.5, extents.width + 1, extents.height + 1);
       cairo_set_rgb_color (cr, 1, 0, 0);
       cairo_stroke (cr);
       cairo_move_to (cr, x_off - extents.x_bearing, y_off - extents.y_bearing);
       cairo_set_rgb_color (cr, 0, 0, 0);
       cairo_show_text (cr, "cairo");
       cairo_restore (cr);
    }
}

Here is the caller graph for this function:

int main ( void  )

Definition at line 114 of file text_rotate.c.

{
    return cairo_test (&test, draw);
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    "text_rotate",
    "Tests show_text under various rotations",
    WIDTH, HEIGHT
}

Definition at line 67 of file text_rotate.c.