diff options
author | Olivier Andrieu <oandrieu@gmail.com> | 2005-03-09 00:40:22 +0000 |
---|---|---|
committer | Hezekiah M. Carty <hcarty@atmos.umd.edu> | 2009-06-18 13:57:45 -0400 |
commit | d7b446db0432c300202b6f550427000188e06e8d (patch) | |
tree | c2d571f2d0136bd37372a238773c597e1b73ea9f | |
parent | acda403089399d62cc8172b29287cc55e8ad4181 (diff) |
fixes, API changes in the font partcairo-ocaml-0.4
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/cairo.ml | 13 | ||||
-rw-r--r-- | src/cairo.mli | 11 | ||||
-rw-r--r-- | src/cairo_ft.ml | 5 | ||||
-rw-r--r-- | src/cairo_ft.mli | 7 | ||||
-rw-r--r-- | src/ml_cairo.c | 26 | ||||
-rw-r--r-- | src/ml_cairo_ft.c | 21 |
7 files changed, 66 insertions, 24 deletions
@@ -1,3 +1,10 @@ +2005-03-08 Olivier Andrieu <oliv__a@users.sourceforge.net> + + * src/ml_cairo_ft.c, src/cairo_ft.ml, src/cairo_ft.mli: + * src/ml_cairo.c, src/cairo.ml, src/cairo.mli: adjust to API changes + + * src/ml_cairo.c (cairo_current_font): adjust reference counting + 2005-03-01 Olivier Andrieu <oliv__a@users.sourceforge.net> * src/ml_svg_cairo.c, src/svg_cairo.ml, src/svg_cairo.mli : add diff --git a/src/cairo.ml b/src/cairo.ml index 249c84e..1dab66e 100644 --- a/src/cairo.ml +++ b/src/cairo.ml @@ -29,7 +29,6 @@ type surface 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 text_extents : t -> utf8:string -> text_extents = "ml_cairo_text_extent 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_for_image : 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 @@ external image_surface_create : 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 @@ external png_surface_create : 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 : diff --git a/src/cairo.mli b/src/cairo.mli index 179c17c..61ec876 100644 --- a/src/cairo.mli +++ b/src/cairo.mli @@ -332,7 +332,7 @@ external image_surface_create : 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 @@ external matrix_transform_point : matrix:matrix -> point -> unit 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" diff --git a/src/cairo_ft.ml b/src/cairo_ft.ml index e235cab..7c53fc3 100644 --- a/src/cairo_ft.ml +++ b/src/cairo_ft.ml @@ -24,4 +24,7 @@ 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" +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" diff --git a/src/cairo_ft.mli b/src/cairo_ft.mli index 2abeaff..e298366 100644 --- a/src/cairo_ft.mli +++ b/src/cairo_ft.mli @@ -28,4 +28,9 @@ 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" diff --git a/src/ml_cairo.c b/src/ml_cairo.c index f6de3f4..7ff7769 100644 --- a/src/ml_cairo.c +++ b/src/ml_cairo.c @@ -711,6 +711,7 @@ ml_cairo_current_font (value cr) { 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_cairo_glyph_path (value v_ct, value v_glyphs) /* 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, diff --git a/src/ml_cairo_ft.c b/src/ml_cairo_ft.c index 9469aa2..294d3c3 100644 --- a/src/ml_cairo_ft.c +++ b/src/ml_cairo_ft.c @@ -100,9 +100,20 @@ ml_FcNameUnparse (value patt) } /* 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_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) +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 */ |