[cairo-commit] cairo-ocaml/src ml_cairo_ft.c, 1.4, 1.5 ml_cairo.c,
1.19, 1.20 cairo_ft.mli, 1.3, 1.4 cairo_ft.ml, 1.3,
1.4 cairo.mli, 1.14, 1.15 cairo.ml, 1.12, 1.13
Olivier Andrieu
commit at pdx.freedesktop.org
Tue Mar 8 16:40:24 PST 2005
Committed by: oandrieu
Update of /cvs/cairo/cairo-ocaml/src
In directory gabe:/tmp/cvs-serv19834/src
Modified Files:
ml_cairo_ft.c ml_cairo.c cairo_ft.mli cairo_ft.ml cairo.mli
cairo.ml
Log Message:
fixes, API changes in the font part
Index: ml_cairo_ft.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_ft.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ml_cairo_ft.c 2 Mar 2005 18:52:29 -0000 1.4
+++ ml_cairo_ft.c 9 Mar 2005 00:40:22 -0000 1.5
@@ -100,9 +100,20 @@
}
/* 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)
+ML_2 (cairo_ft_font_create, FcPattern_val, cairo_matrix_t_val, Val_cairo_font_t)
+ML_3 (cairo_ft_font_create_for_ft_face, FT_Face_val, Int_val, cairo_matrix_t_val, Val_cairo_font_t)
+ML_1 (cairo_ft_font_lock_face, cairo_font_t_val, Val_ptr)
+ML_1 (cairo_ft_font_unlock_face, cairo_font_t_val, Unit)
+CAMLprim value
+ml_cairo_ft_font_get_pattern (value font)
+{
+ FcPattern *p;
+ p = cairo_ft_font_get_pattern (cairo_font_t_val (font));
+ if (p == NULL)
+ failwith ("cairo_ft_font_get_pattern: NULL pointer");
+ FcPatternReference (p);
+ return Val_FcPattern (p);
+}
#else
@@ -114,6 +125,8 @@
Unsupported (ml_FcNameUnparse)
Unsupported (ml_cairo_ft_font_create)
Unsupported (ml_cairo_ft_font_create_for_ft_face)
-Unsupported (ml_cairo_ft_font_pattern)
+Unsupported (ml_cairo_ft_font_lock_face)
+Unsupported (ml_cairo_ft_font_unlock_face)
+Unsupported (ml_cairo_ft_font_get_pattern)
#endif /* CAIRO_HAS_FT_FONT */
Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ml_cairo.c 2 Mar 2005 18:52:29 -0000 1.19
+++ ml_cairo.c 9 Mar 2005 00:40:22 -0000 1.20
@@ -711,6 +711,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);
}
@@ -777,8 +778,29 @@
/* 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)
+CAMLprim value
+ml_cairo_font_extents (value font, value matrix)
+{
+ cairo_font_extents_t e;
+ cairo_status_t status;
+ status = cairo_font_extents (cairo_font_t_val (font), cairo_matrix_t_val (matrix), &e);
+ cairo_treat_status (status);
+ return Val_cairo_font_extents_t (&e);
+}
+
+CAMLprim value
+ml_cairo_font_glyph_extents (value v_font, value v_matrix, value v_glyphs)
+{
+ size_t num_glyphs = Wosize_val (v_glyphs);
+ cairo_text_extents_t c_extents;
+ cairo_glyph_t c_glyphs[num_glyphs];
+ unsigned int i;
+ for (i = 0; i < num_glyphs; i++)
+ cairo_glyph_t_val (&c_glyphs[i], Field (v_glyphs, i));
+ cairo_font_glyph_extents (cairo_font_t_val (v_font), cairo_matrix_t_val (v_matrix),
+ c_glyphs, num_glyphs, &c_extents);
+ return Val_cairo_text_extents_t (&c_extents);
+}
CAMLprim value
ml_cairo_show_surface (value v_cr, value v_surface, value v_width,
Index: cairo_ft.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ft.mli,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo_ft.mli 2 Mar 2005 18:52:29 -0000 1.3
+++ cairo_ft.mli 9 Mar 2005 00:40:22 -0000 1.4
@@ -28,4 +28,9 @@
= "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"
+
+
+external font_lock_face : Cairo.font -> ft_face = "ml_cairo_ft_font_lock_face"
+external font_unlock_face : Cairo.font -> unit = "ml_cairo_ft_font_unlock_face"
+
+external font_get_pattern : Cairo.font -> fc_pattern = "ml_cairo_ft_font_get_pattern"
Index: cairo_ft.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ft.ml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo_ft.ml 2 Mar 2005 18:52:29 -0000 1.3
+++ cairo_ft.ml 9 Mar 2005 00:40:22 -0000 1.4
@@ -24,4 +24,7 @@
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"
+external font_lock_face : Cairo.font -> ft_face = "ml_cairo_ft_font_lock_face"
+external font_unlock_face : Cairo.font -> unit = "ml_cairo_ft_font_unlock_face"
+
+external font_get_pattern : Cairo.font -> fc_pattern = "ml_cairo_ft_font_get_pattern"
Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cairo.mli 2 Mar 2005 18:52:29 -0000 1.14
+++ cairo.mli 9 Mar 2005 00:40:22 -0000 1.15
@@ -332,7 +332,7 @@
format:format -> width:int -> height:int -> surface
= "ml_cairo_image_surface_create"
external image_surface_create_for_data : image -> surface
- = "ml_image_surface_create_for_data"
+ = "ml_cairo_image_surface_create_for_data"
(** {4 PS surface} *)
@@ -391,8 +391,7 @@
Mostly unusable ATM. It needs other libraries (freetype2/fontconfig).
*)
-external font_set_transform : font:font -> matrix:matrix -> unit
- = "ml_cairo_font_set_transform"
-external font_current_transform : font:font -> matrix:matrix -> unit
- = "ml_cairo_font_current_transform"
-
+external font_extents : font -> matrix -> font_extents
+ = "ml_cairo_font_extents"
+external font_glyph_extents : font -> matrix -> glyph array -> text_extents
+ = "ml_cairo_font_glyph_extents"
Index: cairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.ml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo.ml 2 Mar 2005 18:52:29 -0000 1.12
+++ cairo.ml 9 Mar 2005 00:40:22 -0000 1.13
@@ -29,7 +29,6 @@
type matrix
type pattern
external create : unit -> t = "ml_cairo_create"
-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"
@@ -192,11 +191,8 @@
external glyph_extents : t -> glyph array -> text_extents = "ml_cairo_glyph_extents"
external text_path : t -> utf8:string -> unit = "ml_cairo_text_path"
external glyph_path : t -> glyph array -> unit = "ml_cairo_glyph_path"
-external font_destroy : font:font -> unit = "ml_cairo_font_destroy"
-external font_set_transform :
- font:font -> matrix:matrix -> unit = "ml_cairo_font_set_transform"
-external font_current_transform :
- font:font -> matrix:matrix -> unit = "ml_cairo_font_current_transform"
+external font_extents : font -> matrix -> font_extents = "ml_cairo_font_extents"
+external font_glyph_extents : font -> matrix -> glyph array -> text_extents = "ml_cairo_font_glyph_extents"
external show_surface :
cr:t -> surface:surface -> width:int -> height:int ->
unit = "ml_cairo_show_surface"
@@ -225,8 +221,6 @@
external surface_create_similar :
other:surface -> format:format -> width:int -> height:int ->
surface = "ml_cairo_surface_create_similar"
-external surface_destroy :
- surface:surface -> unit = "ml_cairo_surface_destroy"
external surface_set_repeat :
surface:surface -> repeat:bool -> unit = "ml_cairo_surface_set_repeat"
external surface_set_matrix :
@@ -268,7 +262,7 @@
format:format -> width:int -> height:int ->
surface = "ml_cairo_image_surface_create"
external image_surface_create_for_data :
- image -> surface = "ml_image_surface_create_for_data"
+ image -> surface = "ml_cairo_image_surface_create_for_data"
external ps_surface_create :
file:Cairo_channel.t -> width_inches:float -> height_inches:float ->
x_pixels_per_inch:float -> y_pixels_per_inch:float ->
@@ -282,7 +276,6 @@
surface = "ml_cairo_png_surface_create"
external matrix_create : unit -> matrix = "ml_cairo_matrix_create"
-external matrix_destroy : matrix:matrix -> unit = "ml_cairo_matrix_destroy"
external matrix_copy :
matrix:matrix -> other:matrix -> unit = "ml_cairo_matrix_copy"
external matrix_set_identity :
More information about the cairo-commit
mailing list