head 1.5; access; symbols; locks; strict; comment @ * @; 1.5 date 2005.05.17.15.24.39; author cworth; state Exp; branches; next 1.4; commitid 22b4428a0cb74567; 1.4 date 2005.05.17.14.31.43; author cworth; state Exp; branches; next 1.3; commitid 2e0428a004e4567; 1.3 date 2005.04.02.04.20.39; author cworth; state Exp; branches; next 1.2; 1.2 date 2004.02.19.23.22.10; author dajobe; state Exp; branches; next 1.1; 1.1 date 2003.12.18.03.17.27; author cworth; state Exp; branches; next ; desc @@ 1.5 log @ * bevels.c: * caps_joins.c: * hering.c: * outline.c: * snapping.c: * spiral.c: * splines_tolerance.c: * star_and_ring.c: * stars.c: * text-rotate.c: * text.c: Remove stale includes of write_png.h. @ text @/* * Copyright © 2003 USC, Information Sciences Institute * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of the * University of Southern California not be used in advertising or * publicity pertaining to distribution of the software without * specific, written prior permission. The University of Southern * California makes no representations about the suitability of this * software for any purpose. It is provided "as is" without express * or implied warranty. * * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Carl D. Worth */ #include #include #define TEXT "hello, world" #define WIDTH 450 #define HEIGHT 900 #define STRIDE (WIDTH * 4) unsigned char image[STRIDE*HEIGHT]; int main (void) { int i; cairo_surface_t *surface; cairo_t *cr; cairo_matrix_t matrix; double angle; surface = cairo_image_surface_create_for_data (image, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, STRIDE); cr = cairo_create (surface); cairo_set_source_rgb (cr, 0., 0., 0.); cairo_select_font_face (cr, "serif", 0, 0); cairo_set_font_size (cr, 40); cairo_translate (cr, 40, 40); #define NUM_STRINGS 3.0 cairo_select_font_face (cr, "mono", 0, 0); cairo_set_font_size (cr, 12); cairo_show_text (cr, "+CTM rotation"); cairo_save (cr); cairo_select_font_face (cr, "serif", 0, 0); cairo_set_font_size (cr, 40); for (i=0; i < NUM_STRINGS; i++) { angle = (double) i * 0.5 * M_PI / (NUM_STRINGS - 1); cairo_save (cr); cairo_rotate (cr, angle); cairo_move_to (cr, 100, 0); cairo_show_text (cr, "Text"); cairo_restore (cr); } cairo_restore (cr); cairo_translate (cr, 0, HEIGHT / 3); cairo_move_to (cr, 0, 0); cairo_show_text (cr, "+CTM rotation"); cairo_rel_move_to (cr, 0, 12); cairo_show_text (cr, "-font rotation"); cairo_save (cr); cairo_select_font_face (cr, "serif", 0, 0); cairo_set_font_size (cr, 40); for (i=0; i < NUM_STRINGS; i++) { angle = (double) i * 0.5 * M_PI / (NUM_STRINGS - 1); cairo_save (cr); cairo_rotate (cr, angle); cairo_matrix_init_identity (&matrix); cairo_matrix_scale (&matrix, 40, 40); cairo_matrix_rotate (&matrix, - angle); cairo_set_font_matrix (cr, &matrix); cairo_move_to (cr, 100, 0); cairo_show_text (cr, "Text"); cairo_restore (cr); } cairo_restore (cr); cairo_translate (cr, 0, HEIGHT / 3); cairo_move_to (cr, 0, 0); cairo_show_text (cr, "+CTM rotation"); cairo_rel_move_to (cr, 0, 12); cairo_show_text (cr, "-CTM rotation"); cairo_save (cr); cairo_select_font_face (cr, "serif", 0, 0); cairo_set_font_size (cr, 40); for (i=0; i < NUM_STRINGS; i++) { angle = (double) i * 0.5 * M_PI / (NUM_STRINGS - 1); cairo_save (cr); cairo_rotate (cr, angle); cairo_move_to (cr, 100, 0); cairo_rotate (cr, -angle); cairo_show_text (cr, "Text"); cairo_restore (cr); } cairo_restore (cr); cairo_surface_write_to_png (surface, "text-rotate.png"); cairo_destroy (cr); cairo_surface_destroy (surface); return 0; } @ 1.4 log @ * Makefile: * bevels.c: (set_hex_color), (main): * caps_joins.c: (main), (stroke_v_twice), (draw_caps_joins): * hering.c: (main), (draw_hering): * outline.c: (main), (create_gradient), (draw_outlines): * snapping.c: (snap_point_for_fill), (snap_point_for_stroke), (snap_line_width), (snap_path_for_fill), (snap_path_for_stroke), (draw_nested), (main): * spiral.c: (main), (draw_spiral): * splines_tolerance.c: (main), (draw_splines): * star_and_ring.c: (star_path), (fill_ring), (fill_star), (main): * stars.c: (main), (draw_stars): * text-rotate.c: (main): * text.c: (box_text), (box_glyphs), (main): Update all programs to match recent cairo API changes. @ text @a30 2 #include "write_png.h" @ 1.3 log @ * caps_joins.c: * hering.c: * outline.c: * spiral.c: * splines_tolerance.c: * stars.c: * text-rotate.c: * text.c: * write_png.c: * write_png.h: Convert file encodings to utf-8. @ text @d39 1 a39 1 char image[STRIDE*HEIGHT]; d44 1 d46 1 a46 1 cairo_matrix_t *matrix; d49 2 a50 1 cr = cairo_create (); d52 1 a52 2 cairo_set_target_image (cr, image, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, STRIDE); d54 1 a54 1 cairo_set_rgb_color (cr, 0., 0., 0.); d56 2 a57 2 cairo_select_font (cr, "serif", 0, 0); cairo_scale_font (cr, 40); d61 1 a61 1 cairo_select_font (cr, "mono", 0, 0); d63 1 a63 1 cairo_scale_font (cr, 12); d67 2 a68 2 cairo_select_font (cr, "serif", 0, 0); cairo_scale_font (cr, 40); d87 2 a88 2 cairo_select_font (cr, "serif", 0, 0); cairo_scale_font (cr, 40); d93 4 a96 4 matrix = cairo_matrix_create (); cairo_matrix_rotate (matrix, - angle); cairo_transform_font (cr, matrix); cairo_matrix_destroy (matrix); d111 2 a112 2 cairo_select_font (cr, "serif", 0, 0); cairo_scale_font (cr, 40); d124 1 a124 1 write_png_argb32 (image, "text-rotate.png", WIDTH, HEIGHT, STRIDE); d128 2 @ 1.2 log @ * text.c, text-rotate.c: Remove FcFini call from newer fontconfig than I have here (2.2.1). May leak memory if valgrind checking. @ text @d2 1 a2 1 * Copyright © 2003 USC, Information Sciences Institute @ 1.1 log @ * Makefile (EXAMPLES): Add text-rotate. * text-rotate.c: New program demonstrating text rotation. @ text @a126 2 FcFini (); @