head 1.8; access; symbols initial:1.1.1.1 start:1.1.1; locks; strict; comment @ * @; 1.8 date 2005.05.18.06.21.15; author keithp; state Exp; branches; next 1.7; commitid 431d428aded64567; 1.7 date 2005.05.02.20.24.38; author keithp; state Exp; branches; next 1.6; commitid 416842768c824567; 1.6 date 2005.03.14.21.43.06; author keithp; state Exp; branches; next 1.5; 1.5 date 2004.12.23.22.39.40; author keithp; state Exp; branches; next 1.4; 1.4 date 2004.12.19.00.06.26; author keithp; state Exp; branches; next 1.3; 1.3 date 2004.12.17.02.09.45; author keithp; state Exp; branches; next 1.2; 1.2 date 2004.12.14.08.34.27; author keithp; state Exp; branches; next 1.1; 1.1 date 2004.12.11.06.26.52; author keithp; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2004.12.11.06.26.52; author keithp; state Exp; branches; next ; desc @@ 1.8 log @2005-05-17 Keith Packard * cairo-5c.h: * cairo.5c: * cairo.c: (cairo_5c_get), (do_Cairo_create), (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable), (do_Cairo_get_target): * draw.c: (do_Cairo_paint), (do_Cairo_paint_with_alpha), (do_Cairo_mask), (do_Cairo_mask_surface), (do_Cairo_fill_preserve), (do_Cairo_stroke_preserve), (path_elt_new), (path_array), (do_Cairo_copy_path), (do_Cairo_copy_path_flat), (do_Cairo_append_path): * event.c: (do_Cairo_Surface_open_event): * examples/animate.5c: * examples/draw.5c: * examples/fob.5c: * examples/metrics.5c: * examples/sin.5c: * examples/spin.5c: * examples/spinman.5c: * examples/test.5c: * gstate.c: (do_Cairo_set_source_surface), (do_Cairo_identity_matrix), (do_Cairo_transform), (do_Cairo_user_to_device), (do_Cairo_user_to_device_distance), (do_Cairo_device_to_user), (do_Cairo_device_to_user_distance), (do_Cairo_reset_clip), (do_Cairo_clip_preserve): * gtk.c: (create_gtk_global): * init.c: (init_types), (nickle_init): * pattern.c: (do_Cairo_Pattern_create_for_surface), (do_Cairo_Pattern_add_color_stop_rgba), (do_Cairo_Pattern_add_color_stop_rgb): * surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark), (cairo_5c_surface_destroy), (do_Cairo_Surface_write_to_png), (do_Cairo_Surface_write_to_png_file), (do_Cairo_Surface_set_device_offset), (do_Cairo_Surface_create_similar), (do_Cairo_Surface_finish), (do_Cairo_Surface_destroy), (do_Cairo_Surface_width), (do_Cairo_Surface_height), (do_Cairo_Image_surface_create), (do_Cairo_Image_surface_create_from_png), (do_Cairo_Image_surface_create_from_png_file), (do_Cairo_Pdf_surface_create): * text.c: (do_Cairo_select_font_face), (do_Cairo_get_font_matrix): Another round of API changes for cairo 0.5, the putative final API structure. @ text @/* $Id: text.c,v 1.7 2005/05/02 20:24:38 keithp Exp $ * * Copyright © 2004 Keith Packard * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * (the "LGPL") or, at your option, under the terms of the Mozilla * Public License Version 1.1 (the "MPL"). If you do not alter this * notice, a recipient may use your version of this file under either * the MPL or the LGPL. * * You should have received a copy of the LGPL along with this library * in the file COPYING-LGPL-2.1; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * You should have received a copy of the MPL along with this library * in the file COPYING-MPL-1.1 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY * OF ANY KIND, either express or implied. See the LGPL or the MPL for * the specific language governing rights and limitations. * * The Original Code is the cairo graphics library. * * The Initial Developer of the Original Code is Keith Packard * * Contributor(s): * Keith Packard */ #include "cairo-5c.h" Value do_Cairo_select_font_face (Value cv, Value fv, Value sv, Value wv) { cairo_5c_t *c5c = cairo_5c_get (cv); char *family = StrzPart (fv, "invalid family"); cairo_font_slant_t slant = EnumIntPart (sv, "invalid slant"); cairo_font_weight_t weight = EnumIntPart (wv, "invalid weight"); if (!aborting) cairo_select_font_face (c5c->cr, family, slant, weight); return Void; } Value do_Cairo_set_font (Value cv, Value fv) { ENTER (); cairo_5c_t *c5c = cairo_5c_get (cv); char *name = StrzPart (fv, "invalid name"); FcPattern *pat, *match; cairo_font_face_t *font_face; double size = 0; FcResult result; if (aborting) RETURN (Void); pat = FcNameParse (name); FcConfigSubstitute (0, pat, FcMatchPattern); FcDefaultSubstitute (pat); match = FcFontMatch (0, pat, &result); FcPatternDestroy (pat); if (!match) { RaiseStandardException (exception_open_error, "can't open font", 1, fv); RETURN (Void); } FcPatternGetDouble (match, FC_SIZE, 0, &size); font_face = cairo_ft_font_face_create_for_pattern (match); FcPatternDestroy (match); if (!font_face) { RaiseStandardException (exception_open_error, "can't open font", 1, fv); RETURN (Void); } cairo_set_font_face (c5c->cr, font_face); cairo_set_font_size (c5c->cr, size); cairo_font_face_destroy (font_face); RETURN(Void); } Value do_Cairo_set_font_size (Value cv, Value sv) { cairo_5c_t *c5c = cairo_5c_get (cv); double size = DoublePart (sv, "invalid size"); if (!aborting) cairo_set_font_size (c5c->cr, size); return Void; } Value do_Cairo_set_font_matrix (Value cv, Value mv) { ENTER (); cairo_5c_t *c5c = cairo_5c_get (cv); cairo_matrix_t matrix; if (aborting) RETURN(Void); cairo_matrix_part (mv, &matrix, "invalid matrix"); if (aborting) RETURN(Void); cairo_set_font_matrix (c5c->cr, &matrix); RETURN(Void); } Value do_Cairo_get_font_matrix (Value cv) { ENTER (); cairo_5c_t *c5c = cairo_5c_get (cv); cairo_matrix_t matrix; Value ret; if (aborting) RETURN(Void); cairo_get_font_matrix (c5c->cr, &matrix); ret = new_cairo_matrix (&matrix); RETURN(ret); } Value do_Cairo_font_extents (Value cv) { ENTER (); cairo_5c_t *c5c = cairo_5c_get (cv); cairo_font_extents_t extents; Value ret; BoxPtr box; if (aborting) return Void; cairo_font_extents (c5c->cr, &extents); ret = NewStruct (TypeCanon (typeCairoFontExtents)->structs.structs, False); box = ret->structs.values; BoxValueSet (box, 0, NewDoubleFloat (extents.ascent)); BoxValueSet (box, 1, NewDoubleFloat (extents.descent)); BoxValueSet (box, 2, NewDoubleFloat (extents.height)); BoxValueSet (box, 3, NewDoubleFloat (extents.max_x_advance)); BoxValueSet (box, 4, NewDoubleFloat (extents.max_y_advance)); RETURN (ret); } Value do_Cairo_show_text (Value cv, Value uv) { cairo_5c_t *c5c = cairo_5c_get (cv); char *utf8 = StrzPart (uv, "invalid text"); if (!aborting) { cairo_show_text (c5c->cr, utf8); cairo_5c_dirty (c5c); } return Void; } Value do_Cairo_text_path (Value cv, Value uv) { cairo_5c_t *c5c = cairo_5c_get (cv); char *utf8 = StrzPart (uv, "invalid text"); if (!aborting) cairo_text_path (c5c->cr, utf8); return Void; } Value do_Cairo_text_extents (Value cv, Value uv) { ENTER (); cairo_5c_t *c5c = cairo_5c_get (cv); char *utf8 = StrzPart (uv, "invalid text"); cairo_text_extents_t extents; Value ret; BoxPtr box; if (aborting) return Void; cairo_text_extents (c5c->cr, utf8, &extents); ret = NewStruct (TypeCanon (typeCairoTextExtents)->structs.structs, False); box = ret->structs.values; BoxValueSet (box, 0, NewDoubleFloat (extents.x_bearing)); BoxValueSet (box, 1, NewDoubleFloat (extents.y_bearing)); BoxValueSet (box, 2, NewDoubleFloat (extents.width)); BoxValueSet (box, 3, NewDoubleFloat (extents.height)); BoxValueSet (box, 4, NewDoubleFloat (extents.x_advance)); BoxValueSet (box, 5, NewDoubleFloat (extents.y_advance)); RETURN (ret); } @ 1.7 log @2005-05-02 Keith Packard * cairo-5c.h: * cairo.5c: * cairo.c: (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable), (do_Cairo_get_target_surface): * event.c: (do_Cairo_Surface_open_event): * gstate.c: (do_Cairo_set_source_rgb), (do_Cairo_set_source_rgba), (do_Cairo_get_matrix), (do_Cairo_concat_matrix), (do_Cairo_set_matrix), (do_Cairo_get_operator), (do_Cairo_get_tolerance), (do_Cairo_get_current_point), (do_Cairo_get_fill_rule), (do_Cairo_get_line_width), (do_Cairo_get_line_cap), (do_Cairo_get_line_join), (do_Cairo_get_miter_limit): * gtk.c: (delete_drawing_area), (motion_notify_event), (button_press_event), (button_release_event), (gtk_repaint_timeout), (gtk_thread_main), (gtk_global_free), (create_gtk_global), (cairo_5c_tool_dirty), (cairo_5c_tool_enable): * init.c: (init_types), (nickle_init): * matrix.c: (cairo_matrix_part), (new_cairo_matrix): * pattern.c: (do_Cairo_set_source), (do_Cairo_get_source), (do_Cairo_Pattern_set_matrix), (do_Cairo_Pattern_get_matrix): * surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark), (cairo_5c_surface_destroy), (do_Cairo_Surface_create_image), (do_Cairo_Surface_write_to_png): * text.c: (do_Cairo_set_font), (do_Cairo_set_font_size), (do_Cairo_set_font_matrix), (do_Cairo_font_extents): Match cairo API as of today. * examples/draw.5c: * examples/fob.5c: * examples/graph.5c: * examples/grid.5c: * examples/led.5c: * examples/pie-new.5c: * examples/pie.5c: * examples/rottext.5c: * examples/sin.5c: * examples/spin-cairo.5c: * examples/spin.5c: * examples/spinman.5c: * examples/test.5c: * examples/text45.5c: Update examples to match API changes @ text @d1 1 a1 1 /* $Id: text.c,v 1.6 2005/03/14 21:43:06 keithp Exp $ d39 1 a39 1 do_Cairo_select_font (Value cv, Value fv, Value sv, Value wv) d47 1 a47 1 cairo_select_font (c5c->cr, family, slant, weight); d123 15 @ 1.6 log @2005-03-14 Keith Packard * cairo-5c.h: Must explicitly reference desired backends * pattern.c: (do_Cairo_current_pattern), (create_surface_from_png): Switch from deprecated functions to current ones * text.c: (do_Cairo_set_font): Fix sizing from supplied pattern * examples/graph.5c: metrics got fixed. @ text @d1 1 a1 1 /* $Id: text.c,v 1.5 2004/12/23 22:39:40 keithp Exp $ d58 1 a58 1 cairo_font_t *font; a59 1 cairo_matrix_t *scale; d80 1 a80 3 scale = cairo_matrix_create (); font = cairo_ft_font_create (match, scale); cairo_matrix_destroy (scale); d82 1 a82 1 if (!font) d89 3 a91 3 cairo_set_font (c5c->cr, font); cairo_scale_font (c5c->cr, size); cairo_font_destroy (font); d96 1 a96 1 do_Cairo_scale_font (Value cv, Value sv) d99 1 a99 1 double scale = DoublePart (sv, "invalid scale"); d102 1 a102 1 cairo_scale_font (c5c->cr, scale); d107 1 a107 1 do_Cairo_transform_font (Value cv, Value mv) d111 1 a111 1 cairo_matrix_t *matrix; d115 1 a115 1 matrix = cairo_matrix_part (mv, "invalid matrix"); d118 1 a118 2 cairo_transform_font (c5c->cr, matrix); cairo_matrix_destroy (matrix); d123 1 a123 1 do_Cairo_current_font_extents (Value cv) d133 1 a133 1 cairo_current_font_extents (c5c->cr, &extents); @ 1.5 log @2004-12-23 Keith Packard * Makefile.am: * cairo-5c.h: * cairo.5c: * cairo.c: (cairo_5c_get), (cairo_5c_mark), (cairo_5c_free), (cairo_foreign_mark), (cairo_foreign_free), (do_Cairo_create), (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable), (do_Cairo_set_target_surface), (do_Cairo_current_target_surface), (do_Cairo_destroy), (do_Cairo_copy), (do_Cairo_status), (do_Cairo_status_string), (do_Cairo_enable), (do_Cairo_disable): * draw.c: (do_Cairo_new_path), (do_Cairo_move_to), (do_Cairo_line_to), (do_Cairo_curve_to), (do_Cairo_arc), (do_Cairo_arc_negative), (do_Cairo_rel_move_to), (do_Cairo_rel_line_to), (do_Cairo_rel_curve_to), (do_Cairo_rectangle), (do_Cairo_close_path), (do_Cairo_fill), (do_Cairo_stroke), (do_Cairo_in_stroke), (do_Cairo_in_fill), (do_Cairo_stroke_extents), (do_Cairo_fill_extents), (do_Cairo_current_path_list), (do_Cairo_current_path_flat_list): * event.c: (do_Cairo_Surface_open_event): * examples/draw.5c: * examples/graph.5c: * examples/grid.5c: * examples/rottext.5c: * gstate.c: (do_Cairo_save), (do_Cairo_restore), (do_Cairo_set_operator), (do_Cairo_set_rgb_color), (do_Cairo_set_alpha), (do_Cairo_set_tolerance), (do_Cairo_set_fill_rule), (do_Cairo_set_line_width), (do_Cairo_set_line_cap), (do_Cairo_set_line_join), (do_Cairo_set_dash), (do_Cairo_set_miter_limit), (do_Cairo_identity_matrix), (do_Cairo_default_matrix), (do_Cairo_translate), (do_Cairo_scale), (do_Cairo_rotate), (do_Cairo_current_matrix), (do_Cairo_concat_matrix), (do_Cairo_set_matrix), (do_Cairo_transform_point), (do_Cairo_transform_distance), (do_Cairo_inverse_transform_point), (do_Cairo_inverse_transform_distance), (do_Cairo_init_clip), (do_Cairo_clip), (do_Cairo_current_operator), (do_Cairo_current_rgb_color), (do_Cairo_current_alpha), (do_Cairo_current_tolerance), (do_Cairo_current_point), (do_Cairo_current_fill_rule), (do_Cairo_current_line_width), (do_Cairo_current_line_cap), (do_Cairo_current_line_join), (do_Cairo_current_miter_limit): * gtk.c: (configure_event), (expose_event), (delete_drawing_area), (delete_event), (motion_notify_event), (button_press_event), (button_release_event), (gtk_repaint), (gtk_repaint_timeout), (gtk_global_mark), (gtk_global_free), (create_gtk_global), (gtk_tool_mark), (gtk_tool_free), (cairo_5c_tool_create), (cairo_5c_tool_destroy), (cairo_5c_tool_mark), (cairo_5c_tool_dirty), (cairo_5c_tool_disable), (cairo_5c_tool_enable), (cairo_5c_tool_display): * init.c: (init_types), (nickle_init): * pattern.c: (mark_cairo_pattern), (make_pattern_value), (do_Cairo_set_pattern), (do_Cairo_current_pattern), (do_Cairo_Pattern_create_for_surface): * surface.c: (create_cairo_window), (cairo_5c_surface_get), (cairo_5c_surface_mark), (cairo_5c_surface_free), (cairo_surface_foreign_mark), (cairo_surface_foreign_free), (do_Cairo_Surface_create_window), (do_Cairo_Surface_create_png), (do_Cairo_Surface_create_ps), (do_Cairo_Surface_create_similar), (do_Cairo_Surface_destroy), (do_Cairo_Surface_width), (do_Cairo_Surface_height): * text.c: (do_Cairo_select_font), (do_Cairo_set_font), (do_Cairo_scale_font), (do_Cairo_transform_font), (do_Cairo_current_font_extents), (do_Cairo_show_text), (do_Cairo_text_path), (do_Cairo_text_extents): Split cairo_t and cairo_surface_t functions apart, permitting more complex programs to be written that use more than a single window. Switch allocations around to mostly use the nickle memory allocator now. Requires updated nickle bits that expose this change in the foreign object API. @ text @d1 1 a1 1 /* $Id: text.c,v 1.4 2004/12/19 00:06:26 keithp Exp $ d57 1 a57 2 FcPattern *pat; static FT_Library ft_library; d59 3 a61 1 double scale = 0; a64 8 if (!ft_library) if (FT_Init_FreeType (&ft_library)) { RaiseStandardException (exception_open_error, "can't open FreeType", 1, fv); RETURN (Void); } d66 5 a70 2 FcPatternGetDouble (pat, FC_SIZE, 0, &scale); font = cairo_ft_font_create (ft_library, pat); d72 13 d93 1 a93 2 if (scale != 0) cairo_scale_font(c5c->cr, scale); @ 1.4 log @2004-12-18 Keith Packard * cairo.5c: Add matrix operations * cairo-5c.h: * text.c: (do_Cairo_set_font), (do_Cairo_transform_font): * init.c: (nickle_init): Add set_font and transform_font interfaces * examples/animate.5c: * examples/pie.5c: use set_font interface * surface.c: (do_Cairo_dup): Duplicate gstate in dup operator @ text @d1 1 a1 1 /* $Id: text.c,v 1.3 2004/12/17 02:09:45 keithp Exp $ d41 1 a41 1 cairo_5c_t *c5c = get_cairo_5c (cv); d55 1 a55 1 cairo_5c_t *c5c = get_cairo_5c (cv); d93 1 a93 1 cairo_5c_t *c5c = get_cairo_5c (cv); d105 1 a105 1 cairo_5c_t *c5c = get_cairo_5c (cv); d119 22 d143 1 a143 1 cairo_5c_t *c5c = get_cairo_5c (cv); d149 1 a149 1 dirty_cairo_5c (c5c); d157 1 a157 1 cairo_5c_t *c5c = get_cairo_5c (cv); d169 1 a169 1 cairo_5c_t *c5c = get_cairo_5c (cv); a187 7 Value do_Cairo_select_ft_font (Value pv) { /* XXX */ return Void; } @ 1.3 log @2004-12-16 Keith Packard * Makefile.am: * autogen.sh: * cairo.5c: * configure.in: Add cairo.5c and install it to nickle libary * cairo-5c.h: * draw.c: (do_Cairo_rectangle), (do_Cairo_in_stroke), (do_Cairo_in_fill), (do_Cairo_stroke_extents), (do_Cairo_fill_extents), (cairo_5c_move_to), (do_Cairo_current_path), (do_Cairo_current_path_flat): * gstate.c: (do_Cairo_set_operator), (do_Cairo_set_fill_rule), (do_Cairo_set_line_cap), (do_Cairo_set_line_join), (do_Cairo_set_dash), (do_Cairo_set_miter_limit), (do_Cairo_default_matrix), (do_Cairo_transform_point), (do_Cairo_transform_distance), (do_Cairo_inverse_transform_point), (do_Cairo_inverse_transform_distance), (do_Cairo_init_clip), (do_Cairo_clip), (do_Cairo_current_operator), (do_Cairo_current_rgb_color), (do_Cairo_current_alpha), (do_Cairo_current_tolerance), (do_Cairo_current_point), (do_Cairo_current_fill_rule), (do_Cairo_current_line_width), (do_Cairo_current_line_cap), (do_Cairo_current_line_join), (do_Cairo_current_miter_limit): * init.c: (make_typedef), (init_types), (EnumIntPart), (IntToEnum), (nickle_init): * text.c: (do_Cairo_select_font), (do_Cairo_text_extents), (do_Cairo_select_ft_font): Add a bunch more bindings. Still more to do, especially the path walkers. Switch from int constants to enums for enumerated types. * gtk.c: (motion_notify_event), (button_press_event), (button_release_event), (cairo_5c_window_new): * surface.c: (do_Cairo_new): Add mouse input support. * examples/animate.5c: * examples/cairo.5c: * examples/draw.5c: * examples/graph.5c: * examples/pie.5c: * examples/rottext.5c: * examples/sin.5c: * examples/test.5c: Change examples to use cairo.5c file with autoimport @ text @d1 1 a1 1 /* $Id: text.c,v 1.2 2004/12/14 08:34:27 keithp Exp $ d52 39 d102 17 @ 1.2 log @2004-12-14 Keith Packard * .cvsignore: * Makefile.am: * cairo-5c.h: * configure.in: * draw.c: (do_Cairo_fill), (do_Cairo_stroke): * gtk.c: (configure_event), (expose_event), (cairo_5c_window_new), (repaint_x), (gtk_repaint_timeout), (gtk_thread_main), (start_x), (dirty_x): * init.c: (nickle_init): * surface.c: (get_cairo_5c), (free_cairo_5c), (dirty_cairo_5c), (do_Cairo_new): * text.c: (do_Cairo_show_text): Replace lame Xlib-based output with more capable gtk+ based output, including backing storage and resize handling. Input still isn't hooked up. * gstate.c: (do_Cairo_current_matrix), (do_Cairo_set_matrix): Add current_matrix and set_matrix functions; these only do affine matrices. * examples/animate.5c: * examples/pie.5c: * examples/rottext.5c: * examples/sin.5c: * examples/test.5c: Update examples to use installed library @ text @d1 1 a1 1 /* $Id: text.c,v 1.1.1.1 2004/12/11 06:26:52 keithp Exp $ d43 2 a44 2 cairo_font_slant_t slant = IntPart (sv, "invalid slant"); cairo_font_weight_t weight = IntPart (wv, "invalid weight"); d100 1 a100 1 ret = NewStruct (TypeCanon (typeTextExtents)->structs.structs, False); d110 7 @ 1.1 log @Initial revision @ text @d1 1 a1 1 /* $Id: $ d71 1 a71 1 c5c->dirty = True; @ 1.1.1.1 log @Add cairo-5c to repository @ text @@