[cairo-commit] cairo-ocaml/src ml_cairo_status.c, 1.3,
1.4 ml_cairo_lablgtk.c, 1.8, 1.9 ml_cairo_gtkcairo.c, 1.1.1.1,
1.2 ml_cairo_ft.c, 1.1, 1.2 ml_cairo.h, 1.6, 1.7 ml_cairo.c,
1.15, 1.16 cairo_ft.mli, 1.1, 1.2 cairo_ft.ml, 1.1,
1.2 cairo_channel.mli, 1.2, 1.3 cairo_channel.ml, NONE,
1.1 cairo.mli, 1.12, 1.13 cairo.ml, 1.10, 1.11
Olivier Andrieu
commit at pdx.freedesktop.org
Tue Jan 25 16:54:18 PST 2005
Committed by: oandrieu
Update of /cvs/cairo/cairo-ocaml/src
In directory gabe:/tmp/cvs-serv28123/src
Modified Files:
ml_cairo_status.c ml_cairo_lablgtk.c ml_cairo_gtkcairo.c
ml_cairo_ft.c ml_cairo.h ml_cairo.c cairo_ft.mli cairo_ft.ml
cairo_channel.mli cairo.mli cairo.ml
Added Files:
cairo_channel.ml
Log Message:
* add PDF backend
* sync with Cairo snapshot 0.3.0
Index: ml_cairo_status.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_status.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ml_cairo_status.c 28 Oct 2004 13:46:00 -0000 1.3
+++ ml_cairo_status.c 26 Jan 2005 00:54:15 -0000 1.4
@@ -6,45 +6,20 @@
#include "ml_cairo_status.h"
void
-cairo_treat_status (cairo_status_t s)
+cairo_treat_status (cairo_status_t status)
{
static value *cairo_exn;
- int status;
-
- switch (s)
- {
- case CAIRO_STATUS_SUCCESS:
- return;
- case CAIRO_STATUS_NO_MEMORY:
- raise_out_of_memory ();
- case CAIRO_STATUS_INVALID_RESTORE:
- status = 0;
- break;
- case CAIRO_STATUS_INVALID_POP_GROUP:
- status = 1;
- break;
- case CAIRO_STATUS_NO_CURRENT_POINT:
- status = 2;
- break;
- case CAIRO_STATUS_INVALID_MATRIX:
- status = 3;
- break;
- case CAIRO_STATUS_NO_TARGET_SURFACE:
- status = 4;
- break;
- case CAIRO_STATUS_NULL_POINTER:
- status = 5;
- break;
- }
- if (cairo_exn == NULL)
+ if (status != CAIRO_STATUS_SUCCESS)
{
- cairo_exn = caml_named_value ("cairo_status_exn");
if (cairo_exn == NULL)
- failwith ("cairo exception");
+ {
+ cairo_exn = caml_named_value ("cairo_status_exn");
+ if (cairo_exn == NULL)
+ failwith ("cairo exception");
+ }
+ raise_with_arg (*cairo_exn, Val_int (status - 1));
}
-
- raise_with_arg (*cairo_exn, Val_int (status));
}
void
@@ -52,10 +27,5 @@
{
struct ml_cairo *ml_c = Data_custom_val (cr);
if (!ml_c->suspend_exn)
- {
- cairo_status_t status;
- status = cairo_status (ml_c->cr);
- if (status != CAIRO_STATUS_SUCCESS)
- cairo_treat_status (status);
- }
+ cairo_treat_status (cairo_status (ml_c->cr));
}
Index: ml_cairo_lablgtk.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_lablgtk.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ml_cairo_lablgtk.c 27 Feb 2004 23:05:28 -0000 1.8
+++ ml_cairo_lablgtk.c 26 Jan 2005 00:54:15 -0000 1.9
@@ -2,6 +2,9 @@
#include <gdk/gdkx.h>
#include <cairo.h>
+#ifdef CAIRO_HAS_XLIB_SURFACE
+# include <cairo-xlib.h>
+#endif
#include <caml/mlvalues.h>
#include <caml/alloc.h>
Index: ml_cairo_gtkcairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_gtkcairo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- ml_cairo_gtkcairo.c 18 Nov 2003 19:02:25 -0000 1.1.1.1
+++ ml_cairo_gtkcairo.c 26 Jan 2005 00:54:15 -0000 1.2
@@ -8,19 +8,19 @@
#include "ml_cairo.h"
CAMLprim value
-ml_cairo_gtkcairo_init(value unit)
+ml_cairo_gtkcairo_init (value unit)
{
- GType t = gtk_cairo_get_type();
- return Val_GType(t);
+ GType t = gtk_cairo_get_type ();
+ return Val_GType (t);
}
#define GtkCairo_val(v) check_cast(GTK_CAIRO, v)
CAMLprim value
-ml_cairo_gtkcairo_get_cairo(value w)
+ml_cairo_gtkcairo_get_cairo (value w)
{
- GtkCairo *c = GtkCairo_val(w);
- cairo_t *cr = gtk_cairo_get_cairo(c);
- cairo_reference(cr);
- return Val_cairo_t(cr);
+ GtkCairo *c = GtkCairo_val (w);
+ cairo_t *cr = gtk_cairo_get_cairo (c);
+ cairo_reference (cr);
+ return Val_cairo_t (cr);
}
Index: ml_cairo_ft.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_ft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_ft.c 1 Nov 2004 15:50:28 -0000 1.1
+++ ml_cairo_ft.c 26 Jan 2005 00:54:15 -0000 1.2
@@ -8,9 +8,16 @@
#include "ml_cairo_wrappers.h"
#include <cairo.h>
+#ifdef CAIRO_HAS_FT_FONT
+# include <cairo-ft.h>
+#endif
+
#include "ml_cairo.h"
#include "ml_cairo_status.h"
+#ifdef CAIRO_HAS_FT_FONT
+
+/* minimal Freetype interface */
static void
ml_raise_FT_Error (FT_Error err)
{
@@ -65,8 +72,7 @@
return Val_unit;
}
-ML_1 (cairo_ft_font_create_for_ft_face, FT_Face_val, Val_cairo_font_t)
-
+/* minimal Fontconfig interface */
Make_Val_final_pointer (FcPattern, Ignore, FcPatternDestroy, 10)
#define FcPattern_val(v) (FcPattern *)Pointer_val(v)
@@ -85,4 +91,21 @@
return r;
}
+/* cairo Fontconfig/Freetype font backend */
ML_2 (cairo_ft_font_create, FT_Library_val, FcPattern_val, Val_cairo_font_t)
+ML_1 (cairo_ft_font_create_for_ft_face, FT_Face_val, Val_cairo_font_t)
+ML_1 (cairo_ft_font_pattern, cairo_font_t_val, Val_FcPattern)
+
+#else
+
+Unsupported (ml_FT_Init_FreeType)
+Unsupported (ml_FT_Done_FreeType)
+Unsupported (ml_FT_New_Face)
+Unsupported (ml_FT_Done_Face)
+Unsupported (ml_FcNameParse)
+Unsupported (ml_FcNameUnparse)
+Unsupported (ml_cairo_ft_font_create)
+Unsupported (ml_cairo_ft_font_create_for_ft_face)
+Unsupported (ml_cairo_ft_font_pattern)
+
+#endif /* CAIRO_HAS_FT_FONT */
Index: ml_cairo.h
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ml_cairo.h 1 Nov 2004 15:50:28 -0000 1.6
+++ ml_cairo.h 26 Jan 2005 00:54:15 -0000 1.7
@@ -3,10 +3,16 @@
int suspend_exn;
};
#define cairo_t_val(v) (((struct ml_cairo *) Data_custom_val(v))->cr)
+value Val_cairo_t (cairo_t *);
#define cairo_format_t_val(v) ((cairo_format_t) Int_val(v))
#define Val_cairo_format_t(v) Val_int(v)
+#define cairo_surface_t_val(v) ((cairo_surface_t *)Pointer_val(v))
value Val_cairo_surface_t (cairo_surface_t *);
+
+#define cairo_font_t_val(v) ((cairo_font_t *)Pointer_val(v))
value Val_cairo_font_t (cairo_font_t *);
-value Val_cairo_t (cairo_t *);
+
+#define cairo_matrix_t_val(v) ((cairo_matrix_t *)Pointer_val(v))
+value Val_cairo_matrix_t (cairo_matrix_t *);
Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ml_cairo.c 8 Nov 2004 21:05:09 -0000 1.15
+++ ml_cairo.c 26 Jan 2005 00:54:15 -0000 1.16
@@ -7,6 +7,17 @@
#include "ml_cairo_wrappers.h"
#include <cairo.h>
+/* import file-based backends */
+#ifdef CAIRO_HAS_PS_SURFACE
+# include <cairo-ps.h>
+#endif
+#ifdef CAIRO_HAS_PDF_SURFACE
+# include <cairo-pdf.h>
+#endif
+#ifdef CAIRO_HAS_PNG_SURFACE
+# include <cairo-png.h>
+#endif
+
#include "ml_cairo_channel.h"
#include "ml_cairo_status.h"
#include "ml_cairo.h"
@@ -39,10 +50,8 @@
}
Make_Val_final_pointer(cairo_surface_t, Ignore, cairo_surface_destroy, 20)
-#define cairo_surface_t_val(v) ((cairo_surface_t *)Pointer_val(v))
Make_Val_final_pointer(cairo_matrix_t, Ignore, cairo_matrix_destroy, 100)
-#define cairo_matrix_t_val(v) ((cairo_matrix_t *)Pointer_val(v))
Make_Val_final_pointer(cairo_pattern_t, Ignore, cairo_pattern_destroy, 20)
#define cairo_pattern_t_val(v) ((cairo_pattern_t *)Pointer_val(v))
@@ -73,7 +82,7 @@
ML_0(cairo_create, Val_cairo_t)
-ML_1(cairo_destroy, cairo_t_val, Unit)
+/* ML_1(cairo_destroy, cairo_t_val, Unit) */
CAMLprim value
ml_cairo_save (value v_cr)
@@ -132,6 +141,25 @@
#endif /* CAIRO_HAS_PS_SURFACE */
ML_bc6(cairo_set_target_ps)
+#ifdef CAIRO_HAS_PDF_SURFACE
+CAMLprim value
+ml_cairo_set_target_pdf (value v_cr, value v_file, value v_width_inches,
+ value v_height_inches, value v_x_pixels_per_inch,
+ value v_y_pixels_per_inch)
+{
+ cairo_set_target_pdf (cairo_t_val (v_cr), FILE_val (v_file),
+ Double_val (v_width_inches),
+ Double_val (v_height_inches),
+ Double_val (v_x_pixels_per_inch),
+ Double_val (v_y_pixels_per_inch));
+ check_cairo_status (v_cr);
+ return Val_unit;
+}
+#else
+Unsupported(ml_cairo_set_target_pdf)
+#endif /* CAIRO_HAS_PDF_SURFACE */
+ML_bc6(cairo_set_target_pdf)
+
#ifdef CAIRO_HAS_PNG_SURFACE
CAMLprim value
ml_cairo_set_target_png (value v_cr, value v_file, value v_format,
@@ -168,17 +196,17 @@
}
CAMLprim value
-ml_cairo_set_alpha (value v_cr, value v_alpha)
+ml_cairo_set_pattern (value v_cr, value v_pattern)
{
- cairo_set_alpha (cairo_t_val (v_cr), Double_val (v_alpha));
+ cairo_set_pattern (cairo_t_val (v_cr), cairo_pattern_t_val (v_pattern));
check_cairo_status (v_cr);
return Val_unit;
}
CAMLprim value
-ml_cairo_set_pattern (value v_cr, value v_pattern)
+ml_cairo_set_alpha (value v_cr, value v_alpha)
{
- cairo_set_pattern (cairo_t_val (v_cr), cairo_pattern_t_val (v_pattern));
+ cairo_set_alpha (cairo_t_val (v_cr), Double_val (v_alpha));
check_cairo_status (v_cr);
return Val_unit;
}
@@ -366,7 +394,6 @@
return Val_unit;
}
-
CAMLprim value
ml_cairo_new_path (value v_cr)
{
@@ -515,7 +542,7 @@
c_ret =
cairo_in_stroke (cairo_t_val (v_cr), Double_val (v_x), Double_val (v_y));
check_cairo_status (v_cr);
- return Val_int (c_ret);
+ return Val_bool (c_ret);
}
CAMLprim value
@@ -525,7 +552,7 @@
c_ret =
cairo_in_fill (cairo_t_val (v_cr), Double_val (v_x), Double_val (v_y));
check_cairo_status (v_cr);
- return Val_int (c_ret);
+ return Val_bool (c_ret);
}
CAMLprim value
@@ -565,28 +592,27 @@
}
CAMLprim value
-ml_cairo_clip (value v_cr)
+ml_cairo_init_clip (value v_cr)
{
- cairo_clip (cairo_t_val (v_cr));
+ cairo_init_clip (cairo_t_val (v_cr));
check_cairo_status (v_cr);
return Val_unit;
}
CAMLprim value
-ml_cairo_init_clip (value v_cr)
+ml_cairo_clip (value v_cr)
{
- cairo_init_clip (cairo_t_val (v_cr));
+ cairo_clip (cairo_t_val (v_cr));
check_cairo_status (v_cr);
return Val_unit;
}
Make_Val_final_pointer(cairo_font_t, Ignore, cairo_font_destroy, 20)
-#define cairo_font_t_val(v) ((cairo_font_t *)Pointer_val(v))
static void
cairo_glyph_t_val (cairo_glyph_t * _s, value _v)
{
- _s->index = Int_val (Field (_v, 0));
+ _s->index = Long_val (Field (_v, 0));
_s->x = Double_val (Field (_v, 1));
_s->y = Double_val (Field (_v, 2));
}
@@ -677,6 +703,7 @@
{
cairo_font_t *f = cairo_current_font (cairo_t_val (cr));
check_cairo_status (cr);
+ cairo_font_reference (f);
return Val_cairo_font_t (f);
}
@@ -741,7 +768,7 @@
return Val_unit;
}
-ML_1(cairo_font_destroy, cairo_font_t_val, Unit)
+/* ML_1(cairo_font_destroy, cairo_font_t_val, Unit) */
ML_2(cairo_font_set_transform, cairo_font_t_val, cairo_matrix_t_val, Unit)
ML_2(cairo_font_current_transform, cairo_font_t_val, cairo_matrix_t_val, Unit)
@@ -886,7 +913,20 @@
return Val_cairo_surface_t (s);
}
-ML_1(cairo_status, cairo_t_val, Val_cairo_status_t)
+CAMLprim value
+ml_cairo_status (value v_cr)
+{
+ value v;
+ int status = cairo_status (cairo_t_val (v_cr));
+ if (status == CAIRO_STATUS_SUCCESS)
+ v = Val_unit;
+ else
+ {
+ v = alloc_small (1, 0);
+ Field (v, 0) = Val_int (status - 1);
+ }
+ return v;
+}
ML_1(cairo_status_string, cairo_t_val, copy_string)
CAMLprim value
@@ -902,7 +942,7 @@
}
ML_4(cairo_surface_create_similar, cairo_surface_t_val, cairo_format_t_val, Int_val, Int_val, Val_cairo_surface_t)
-ML_1(cairo_surface_destroy, cairo_surface_t_val, Unit)
+/* ML_1(cairo_surface_destroy, cairo_surface_t_val, Unit) */
ML_2(cairo_surface_set_repeat, cairo_surface_t_val, Int_val, Val_cairo_status_t)
ML_2(cairo_surface_set_matrix, cairo_surface_t_val, cairo_matrix_t_val, Val_cairo_status_t)
@@ -912,6 +952,7 @@
#define Val_cairo_filter_t(v) Val_int(v)
ML_2(cairo_surface_set_filter, cairo_surface_t_val, cairo_filter_t_val, Val_cairo_status_t)
+ML_1(cairo_surface_get_filter, cairo_surface_t_val, Val_cairo_filter_t)
ML_3(cairo_image_surface_create, cairo_format_t_val, Int_val, Int_val, Val_cairo_surface_t)
@@ -934,14 +975,37 @@
Unsupported(ml_cairo_ps_surface_create)
#endif /* CAIRO_HAS_PS_SURFACE */
+#ifdef CAIRO_HAS_PDF_SURFACE
+ML_5(cairo_pdf_surface_create, FILE_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_surface_t)
+#else
+Unsupported(ml_cairo_pdf_surface_create)
+#endif /* CAIRO_HAS_PDF_SURFACE */
+
#ifdef CAIRO_HAS_PNG_SURFACE
ML_4(cairo_png_surface_create, FILE_val, cairo_format_t_val, Double_val, Double_val, Val_cairo_surface_t)
#else
Unsupported(ml_cairo_png_surface_create)
#endif /* CAIRO_HAS_PNG_SURFACE */
+ML_1 (cairo_pattern_create_for_surface, cairo_surface_t_val, Val_cairo_pattern_t)
+ML_4 (cairo_pattern_create_linear, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
+ML_6 (cairo_pattern_create_radial, Double_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
+ML_bc6 (cairo_pattern_create_radial)
+ML_6 (cairo_pattern_add_color_stop, cairo_pattern_t_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_status_t)
+ML_bc6 (cairo_pattern_add_color_stop)
+ML_2 (cairo_pattern_set_matrix, cairo_pattern_t_val, cairo_matrix_t_val, Val_cairo_status_t)
+ML_2 (cairo_pattern_get_matrix, cairo_pattern_t_val, cairo_matrix_t_val, Val_cairo_status_t)
+
+#define cairo_extend_t_val(v) ((cairo_extend_t) Int_val(v))
+#define Val_cairo_extend_t(v) Val_int(v)
+
+ML_2 (cairo_pattern_set_extend, cairo_pattern_t_val, cairo_extend_t_val, Val_cairo_status_t)
+ML_1 (cairo_pattern_get_extend, cairo_pattern_t_val, Val_cairo_extend_t)
+ML_2 (cairo_pattern_set_filter, cairo_pattern_t_val, cairo_filter_t_val, Val_cairo_status_t)
+ML_1 (cairo_pattern_get_filter, cairo_pattern_t_val, Val_cairo_filter_t)
+
ML_0(cairo_matrix_create, Val_cairo_matrix_t)
-ML_1(cairo_matrix_destroy, cairo_matrix_t_val, Unit)
+/* ML_1(cairo_matrix_destroy, cairo_matrix_t_val, Unit) */
ML_2(cairo_matrix_copy, cairo_matrix_t_val, cairo_matrix_t_val, Val_cairo_status_t)
ML_1(cairo_matrix_set_identity, cairo_matrix_t_val, Val_cairo_status_t)
CAMLprim value
@@ -985,25 +1049,27 @@
CAMLprim value
ml_cairo_matrix_transform_distance (value m, value p)
{
+ cairo_status_t s;
double x, y;
x = Double_field (p, 0);
y = Double_field (p, 1);
- cairo_matrix_transform_distance (cairo_matrix_t_val (m), &x, &y);
+ s = cairo_matrix_transform_distance (cairo_matrix_t_val (m), &x, &y);
Store_double_field (p, 0, x);
Store_double_field (p, 1, y);
- return Val_unit;
+ return Val_cairo_status_t (s);
}
CAMLprim value
ml_cairo_matrix_transform_point (value m, value p)
{
+ cairo_status_t s;
double x, y;
x = Double_field (p, 0);
y = Double_field (p, 1);
- cairo_matrix_transform_point (cairo_matrix_t_val (m), &x, &y);
+ s = cairo_matrix_transform_point (cairo_matrix_t_val (m), &x, &y);
Store_double_field (p, 0, x);
Store_double_field (p, 1, y);
- return Val_unit;
+ return Val_cairo_status_t (s);
}
CAMLprim value
@@ -1021,20 +1087,3 @@
Store_pointer (s, NULL);
return Val_unit;
}
-
-ML_1 (cairo_pattern_create_for_surface, cairo_surface_t_val, Val_cairo_pattern_t)
-ML_4 (cairo_pattern_create_linear, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
-ML_6 (cairo_pattern_create_radial, Double_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
-ML_bc6 (cairo_pattern_create_radial)
-ML_6 (cairo_pattern_add_color_stop, cairo_pattern_t_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_status_t)
-ML_bc6 (cairo_pattern_add_color_stop)
-ML_2(cairo_pattern_set_matrix, cairo_pattern_t_val, cairo_matrix_t_val, Val_cairo_status_t)
-ML_2(cairo_pattern_get_matrix, cairo_pattern_t_val, cairo_matrix_t_val, Val_cairo_status_t)
-
-#define cairo_extend_t_val(v) ((cairo_extend_t) Int_val(v))
-#define Val_cairo_extend_t(v) Val_int(v)
-
-ML_2 (cairo_pattern_set_extend, cairo_pattern_t_val, cairo_extend_t_val, Val_cairo_status_t)
-ML_1 (cairo_pattern_get_extend, cairo_pattern_t_val, Val_cairo_extend_t)
-ML_2 (cairo_pattern_set_filter, cairo_pattern_t_val, cairo_filter_t_val, Val_cairo_status_t)
-ML_1 (cairo_pattern_get_filter, cairo_pattern_t_val, Val_cairo_filter_t)
Index: cairo_ft.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ft.mli,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_ft.mli 1 Nov 2004 15:50:28 -0000 1.1
+++ cairo_ft.mli 26 Jan 2005 00:54:15 -0000 1.2
@@ -12,12 +12,12 @@
= "ml_FT_New_Face"
external done_face : ft_face -> unit = "ml_FT_Done_Face"
-external font_create_for_ft_face : ft_face -> Cairo.font
- = "ml_cairo_ft_font_create_for_ft_face"
-
type fc_pattern
external fc_name_parse : string -> fc_pattern = "ml_FcNameParse"
external fc_name_unparse : fc_pattern -> string = "ml_FcNameUnparse"
external font_create : ft_library -> fc_pattern -> Cairo.font
= "ml_cairo_ft_font_create"
+external font_create_for_ft_face : ft_face -> Cairo.font
+ = "ml_cairo_ft_font_create_for_ft_face"
+external font_pattern : Cairo.font -> fc_pattern = "ml_cairo_ft_font_pattern"
Index: cairo_ft.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ft.ml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo_ft.ml 1 Nov 2004 15:50:28 -0000 1.1
+++ cairo_ft.ml 26 Jan 2005 00:54:15 -0000 1.2
@@ -11,10 +11,10 @@
external new_face : ft_library -> ?index:int -> string -> ft_face = "ml_FT_New_Face"
external done_face : ft_face -> unit = "ml_FT_Done_Face"
-external font_create_for_ft_face : ft_face -> Cairo.font = "ml_cairo_ft_font_create_for_ft_face"
-
type fc_pattern
external fc_name_parse : string -> fc_pattern = "ml_FcNameParse"
external fc_name_unparse : fc_pattern -> string = "ml_FcNameUnparse"
external font_create : ft_library -> fc_pattern -> Cairo.font = "ml_cairo_ft_font_create"
+external font_create_for_ft_face : ft_face -> Cairo.font = "ml_cairo_ft_font_create_for_ft_face"
+external font_pattern : Cairo.font -> fc_pattern = "ml_cairo_ft_font_pattern"
Index: cairo_channel.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_channel.mli,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo_channel.mli 28 Oct 2004 13:46:01 -0000 1.2
+++ cairo_channel.mli 26 Jan 2005 00:54:15 -0000 1.3
@@ -1,6 +1,8 @@
-(** Support module for file-based backends (PostScript and PNG) *)
+(** Support module for file-based backends (PostScript, PDF and PNG) *)
type t
+
+val open_out : string -> t
external of_out_channel : out_channel -> t = "ml_FILE_of_channel"
external of_file_descr : Unix.file_descr -> t = "ml_FILE_of_file_descr"
external close : t -> unit = "ml_fclose"
--- NEW FILE: cairo_channel.ml ---
type t
external of_out_channel : out_channel -> t = "ml_FILE_of_channel"
external of_file_descr : Unix.file_descr -> t = "ml_FILE_of_file_descr"
external close : t -> unit = "ml_fclose"
let open_out fname =
let oc = Pervasives.open_out fname in
let c = of_out_channel oc in
close_out oc ;
c
Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo.mli 1 Nov 2004 15:40:36 -0000 1.12
+++ cairo.mli 26 Jan 2005 00:54:15 -0000 1.13
@@ -4,7 +4,8 @@
(** {3 Error reporting} *)
type status =
- INVALID_RESTORE
+ NO_MEMORY
+ | INVALID_RESTORE
| INVALID_POP_GROUP
| NO_CURRENT_POINT
| INVALID_MATRIX
@@ -34,7 +35,11 @@
val create : unit -> t
external save : cr:t -> unit = "ml_cairo_save"
external restore : cr:t -> unit = "ml_cairo_restore"
-external copy : dest:t -> src:t -> unit = "ml_cairo_copy"
+external _copy : dest:t -> src:t -> unit = "ml_cairo_copy"
+val copy : t -> t
+
+external status : t -> status option = "ml_cairo_status"
+external status_string : t -> string = "ml_cairo_status_string"
external suspend_exn : t -> unit = "ml_cairo_suspend_exn"
(** The functions operating on cairo values normally raise an [Error] exception
@@ -57,6 +62,13 @@
height_inches:float ->
x_pixels_per_inch:float -> y_pixels_per_inch:float -> unit
= "ml_cairo_set_target_ps_bc" "ml_cairo_set_target_ps"
+external set_target_pdf :
+ cr:t ->
+ file:Cairo_channel.t ->
+ width_inches:float ->
+ height_inches:float ->
+ x_pixels_per_inch:float -> y_pixels_per_inch:float -> unit
+ = "ml_cairo_set_target_pdf_bc" "ml_cairo_set_target_pdf"
external set_target_png :
cr:t -> file:Cairo_channel.t -> format -> width:int -> height:int -> unit = "ml_cairo_set_target_png"
external finalise_target : cr:t -> unit = "ml_cairo_finalise_target"
@@ -83,9 +95,9 @@
external set_rgb_color :
cr:t -> red:float -> green:float -> blue:float -> unit
= "ml_cairo_set_rgb_color"
-external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
external set_pattern : cr:t -> pattern:pattern -> unit
= "ml_cairo_set_pattern"
+external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
external set_tolerance : cr:t -> tolerance:float -> unit
= "ml_cairo_set_tolerance"
type fill_rule = FILL_RULE_WINDING | FILL_RULE_EVEN_ODD
@@ -170,16 +182,6 @@
external stroke_extents : cr:t -> float * float * float * float = "ml_cairo_stroke_extents"
external fill_extents : cr:t -> float * float * float * float = "ml_cairo_fill_extents"
-type flat_path = [
- | `MOVE_TO of point
- | `LINE_TO of point
- | `CLOSE ]
-type basic_path = [
- | flat_path
- | `CURVE_TO of point * point * point ]
-external fold_current_path : t -> ('a -> [> basic_path] -> 'a) -> 'a -> 'a = "ml_cairo_current_path"
-external fold_current_path_flat : t -> ('a -> [> flat_path] -> 'a) -> 'a -> 'a = "ml_cairo_current_path_flat"
-
(** {3 Misc stuff I don't know how to categorize} *)
external show_surface :
@@ -239,6 +241,7 @@
external current_operator : cr:t -> operator = "ml_cairo_current_operator"
external current_rgb_color : cr:t -> float * float * float
= "ml_cairo_current_rgb_color"
+external current_pattern : cr:t -> pattern = "ml_cairo_current_pattern"
external current_alpha : cr:t -> float = "ml_cairo_current_alpha"
external current_tolerance : cr:t -> float = "ml_cairo_current_tolerance"
external current_point : cr:t -> point = "ml_cairo_current_point"
@@ -251,7 +254,16 @@
= "ml_cairo_current_matrix"
external current_target_surface : cr:t -> surface
= "ml_cairo_current_target_surface"
-external current_pattern : cr:t -> pattern = "ml_cairo_current_pattern"
+
+type flat_path = [
+ | `MOVE_TO of point
+ | `LINE_TO of point
+ | `CLOSE ]
+type basic_path = [
+ | flat_path
+ | `CURVE_TO of point * point * point ]
+external fold_current_path : t -> ('a -> [> basic_path] -> 'a) -> 'a -> 'a = "ml_cairo_current_path"
+external fold_current_path_flat : t -> ('a -> [> flat_path] -> 'a) -> 'a -> 'a = "ml_cairo_current_path_flat"
(** {3 Surface API} *)
@@ -275,6 +287,8 @@
| FILTER_GAUSSIAN
external surface_set_filter : surface:surface -> filter:filter -> unit
= "ml_cairo_surface_set_filter"
+external surface_get_filter : surface:surface -> filter
+ = "ml_cairo_surface_get_filter"
external surface_finalise : surface -> unit = "ml_cairo_surface_finalise"
(** {4 Pattern functions} *)
@@ -322,6 +336,15 @@
x_pixels_per_inch:float -> y_pixels_per_inch:float -> surface
= "ml_cairo_ps_surface_create"
+(** {4 PDF surface} *)
+
+external pdf_surface_create :
+ file:Cairo_channel.t ->
+ width_inches:float ->
+ height_inches:float ->
+ x_pixels_per_inch:float -> y_pixels_per_inch:float -> surface
+ = "ml_cairo_pdf_surface_create"
+
(** {4 PNG surface} *)
external png_surface_create :
Index: cairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.ml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cairo.ml 1 Nov 2004 15:40:36 -0000 1.10
+++ cairo.ml 26 Jan 2005 00:54:15 -0000 1.11
@@ -1,5 +1,6 @@
type status =
- INVALID_RESTORE
+ NO_MEMORY
+ | INVALID_RESTORE
| INVALID_POP_GROUP
| NO_CURRENT_POINT
| INVALID_MATRIX
@@ -23,7 +24,8 @@
external destroy : cr:t -> unit = "ml_cairo_destroy"
external save : cr:t -> unit = "ml_cairo_save"
external restore : cr:t -> unit = "ml_cairo_restore"
-external copy : dest:t -> src:t -> unit = "ml_cairo_copy"
+external _copy : dest:t -> src:t -> unit = "ml_cairo_copy"
+let copy src = let dest = create () in _copy ~dest ~src ; dest
external set_target_surface :
cr:t -> surface:surface -> unit = "ml_cairo_set_target_surface"
external set_target_image :
@@ -32,6 +34,10 @@
cr:t -> file:Cairo_channel.t -> width_inches:float -> height_inches:float ->
x_pixels_per_inch:float -> y_pixels_per_inch:float ->
unit = "ml_cairo_set_target_ps_bc" "ml_cairo_set_target_ps"
+external set_target_pdf :
+ cr:t -> file:Cairo_channel.t -> width_inches:float -> height_inches:float ->
+ x_pixels_per_inch:float -> y_pixels_per_inch:float ->
+ unit = "ml_cairo_set_target_pdf_bc" "ml_cairo_set_target_pdf"
external set_target_png :
cr:t -> file:Cairo_channel.t -> format -> width:int -> height:int -> unit = "ml_cairo_set_target_png"
@@ -58,9 +64,9 @@
external set_rgb_color :
cr:t -> red:float -> green:float -> blue:float ->
unit = "ml_cairo_set_rgb_color"
-external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
external set_pattern :
cr:t -> pattern:pattern -> unit = "ml_cairo_set_pattern"
+external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
external set_tolerance :
cr:t -> tolerance:float -> unit = "ml_cairo_set_tolerance"
type fill_rule =
@@ -189,6 +195,7 @@
external current_operator : cr:t -> operator = "ml_cairo_current_operator"
external current_rgb_color :
cr:t -> float * float * float = "ml_cairo_current_rgb_color"
+external current_pattern : cr:t -> pattern = "ml_cairo_current_pattern"
external current_alpha : cr:t -> float = "ml_cairo_current_alpha"
external current_tolerance : cr:t -> float = "ml_cairo_current_tolerance"
external current_point : cr:t -> point = "ml_cairo_current_point"
@@ -201,7 +208,10 @@
cr:t -> matrix:matrix -> unit = "ml_cairo_current_matrix"
external current_target_surface :
cr:t -> surface = "ml_cairo_current_target_surface"
-external current_pattern : cr:t -> pattern = "ml_cairo_current_pattern"
+
+external status : t -> status option = "ml_cairo_status"
+external status_string : t -> string = "ml_cairo_status_string"
+
external surface_create_for_image :
image -> surface = "ml_cairo_surface_create_for_image"
external surface_create_similar :
@@ -224,6 +234,7 @@
| FILTER_GAUSSIAN
external surface_set_filter :
surface:surface -> filter:filter -> unit = "ml_cairo_surface_set_filter"
+external surface_get_filter : surface:surface -> filter = "ml_cairo_surface_get_filter"
external pattern_create_for_surface : surface -> pattern = "ml_cairo_pattern_create_for_surface"
external pattern_create_linear : x0:float -> y0:float -> x1:float -> y1:float -> pattern
= "ml_cairo_pattern_create_linear"
@@ -254,6 +265,10 @@
file:Cairo_channel.t -> width_inches:float -> height_inches:float ->
x_pixels_per_inch:float -> y_pixels_per_inch:float ->
surface = "ml_cairo_ps_surface_create"
+external pdf_surface_create :
+ file:Cairo_channel.t -> width_inches:float -> height_inches:float ->
+ x_pixels_per_inch:float -> y_pixels_per_inch:float ->
+ surface = "ml_cairo_pdf_surface_create"
external png_surface_create :
file:Cairo_channel.t -> format -> width:float -> height:float ->
surface = "ml_cairo_png_surface_create"
More information about the cairo-commit
mailing list