Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 157

Advertising
background image

KTD-S0057-I

Page 153 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


XAllocNamedColor (sys.disp, sys.cmap, OBJ2_COL1, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_stroke

(cr);

cairo_move_to (cr, x_off - extents->x_bearing, y_off - extents->y_bearing);

XAllocNamedColor (sys.disp, sys.cmap, OBJ2_COL2, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_show_text (cr, text);

cairo_restore

(cr);

}
}


static void draw_cairo_object1 (XSystem sys, cairo_t *cr)
{
cairo_text_extents_t

extents;

cairo_font_options_t

*font_options;

const char text[] = "cairo";

int x_off, y_off;

cairo_matrix_t

m;

cairo_save

(cr);

cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);

cairo_set_font_size (cr, TEXT_SIZE);

font_options = cairo_font_options_create ();

cairo_get_font_options (cr, font_options);

cairo_font_options_set_hint_metrics

(font_options, CAIRO_HINT_METRICS_OFF);

cairo_set_font_options (cr, font_options);

cairo_font_options_destroy

(font_options);

cairo_translate (cr, TEXT_WIDTH / 2.0, TEXT_HEIGHT / 2.0);

cairo_text_extents (cr, text, &extents);

x_off = floor (0.5 + (extents.height + 1.0) / (2.0 * tan (M_PI / (double) NUM_TEXT)));

y_off = -floor (0.5 + extents.height / 2.0);

cairo_save

(cr);

cairo_matrix_init_identity

(&m);

draw_quadrant (sys, cr, text, &extents, &m, x_off, y_off);

cairo_matrix_init (&m, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0);

draw_quadrant (sys, cr, text, &extents, &m, x_off, y_off);

cairo_restore

(cr);

cairo_save

(cr);

cairo_scale (cr, -1.0, -1.0);

cairo_matrix_init_identity

(&m);

draw_quadrant (sys, cr, text, &extents, &m, x_off, y_off);

cairo_matrix_init (&m, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0);

draw_quadrant (sys, cr, text, &extents, &m, x_off, y_off);

cairo_restore

(cr);

cairo_restore

(cr);

}

Advertising
This manual is related to the following products: