[cairo-commit]
cairo-ocaml/src cairo.ml, 1.17, 1.18 cairo.mli, 1.19,
1.20 cairo_ft.ml, 1.5, 1.6 cairo_ft.mli, 1.5,
1.6 cairo_lablgtk.ml, 1.3, 1.4 cairo_lablgtk.mli, 1.5,
1.6 ml_cairo.c, 1.23, 1.24 ml_cairo.h, 1.11,
1.12 ml_cairo_font.c, 1.1, 1.2 ml_cairo_ft.c, 1.7,
1.8 ml_cairo_lablgtk.c, 1.12, 1.13 ml_cairo_status.c, 1.7,
1.8 ml_cairo_surface.c, 1.3, 1.4
Olivier Andrieu
commit at pdx.freedesktop.org
Wed Aug 10 16:45:17 PDT 2005
Committed by: oandrieu
Update of /cvs/cairo/cairo-ocaml/src
In directory gabe:/tmp/cvs-serv32274/src
Modified Files:
cairo.ml cairo.mli cairo_ft.ml cairo_ft.mli cairo_lablgtk.ml
cairo_lablgtk.mli ml_cairo.c ml_cairo.h ml_cairo_font.c
ml_cairo_ft.c ml_cairo_lablgtk.c ml_cairo_status.c
ml_cairo_surface.c
Log Message:
* src/* : adapt to cairo-0.6.0
* Makefile, config.make.in, configure.ac:
specify version number in the configure.ac file
Index: cairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.ml,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cairo.ml 18 Jul 2005 21:10:27 -0000 1.17
+++ cairo.ml 10 Aug 2005 23:45:15 -0000 1.18
@@ -22,6 +22,10 @@
| SURFACE_FINISHED
| SURFACE_TYPE_MISMATCH
| PATTERN_TYPE_MISMATCH
+ | INVALID_CONTENT
+ | INVALID_FORMAT
+ | INVALID_VISUAL
+ | FILE_NOT_FOUND
exception Error of status
let init = Callback.register_exception "cairo_status_exn" (Error NULL_POINTER)
@@ -149,17 +153,104 @@
font_height : float;
max_x_advance : float;
max_y_advance : float }
-type font_weight =
- FONT_WEIGHT_NORMAL
- | FONT_WEIGHT_BOLD
type font_slant =
FONT_SLANT_NORMAL
| FONT_SLANT_ITALIC
| FONT_SLANT_OBLIQUE
+type font_weight =
+ FONT_WEIGHT_NORMAL
+ | FONT_WEIGHT_BOLD
+type antialias =
+ ANTIALIAS_DEFAULT
+ | ANTIALIAS_NONE
+ | ANTIALIAS_GRAY
+ | ANTIALIAS_SUBPIXEL
+type subpixel_order =
+ SUBPIXEL_ORDER_DEFAULT
+ | SUBPIXEL_ORDER_RGB
+ | SUBPIXEL_ORDER_BGR
+ | SUBPIXEL_ORDER_VRGB
+ | SUBPIXEL_ORDER_VBGR
+type hint_style =
+ HINT_STYLE_DEFAULT
+ | HINT_STYLE_NONE
+ | HINT_STYLE_SLIGHT
+ | HINT_STYLE_MEDIUM
+ | HINT_STYLE_FULL
+type hint_metrics =
+ HINT_METRICS_DEFAULT
+ | HINT_METRICS_OFF
+ | HINT_METRICS_ON
+
+module Font_Options = struct
+ type t
+ external create : unit -> t = "ml_cairo_font_options_create"
+ external merge : t -> t -> unit = "ml_cairo_font_options_merge"
+ external get_antialias : t -> antialias = "ml_cairo_font_options_get_antialias"
+ external set_antialias : t -> antialias -> unit = "ml_cairo_font_options_set_antialias"
+ external get_subpixel_order : t -> subpixel_order = "ml_cairo_font_options_get_subpixel_order"
+ external set_subpixel_order : t -> subpixel_order -> unit = "ml_cairo_font_options_set_subpixel_order"
+ external get_hint_style : t -> hint_style = "ml_cairo_font_options_get_hint_style"
+ external set_hint_style : t -> hint_style -> unit = "ml_cairo_font_options_set_hint_style"
+ external get_hint_metrics : t -> hint_metrics = "ml_cairo_font_options_get_hint_metrics"
+ external set_hint_metrics : t -> hint_metrics -> unit = "ml_cairo_font_options_set_hint_metrics"
+ type all =
+ [ `ANTIALIAS_DEFAULT
+ | `ANTIALIAS_GRAY
+ | `ANTIALIAS_NONE
+ | `ANTIALIAS_SUBPIXEL
+ | `HINT_METRICS_DEFAULT
+ | `HINT_METRICS_OFF
+ | `HINT_METRICS_ON
+ | `HINT_STYLE_DEFAULT
+ | `HINT_STYLE_FULL
+ | `HINT_STYLE_MEDIUM
+ | `HINT_STYLE_NONE
+ | `HINT_STYLE_SLIGHT
+ | `SUBPIXEL_ORDER_BGR
+ | `SUBPIXEL_ORDER_DEFAULT
+ | `SUBPIXEL_ORDER_RGB
+ | `SUBPIXEL_ORDER_VBGR
+ | `SUBPIXEL_ORDER_VRGB ]
+ let make l =
+ let o = create () in
+ List.iter (function
+ | `ANTIALIAS_DEFAULT -> set_antialias o ANTIALIAS_DEFAULT
+ | `ANTIALIAS_NONE -> set_antialias o ANTIALIAS_NONE
+ | `ANTIALIAS_GRAY -> set_antialias o ANTIALIAS_GRAY
+ | `ANTIALIAS_SUBPIXEL -> set_antialias o ANTIALIAS_SUBPIXEL
+ | `SUBPIXEL_ORDER_DEFAULT -> set_subpixel_order o SUBPIXEL_ORDER_DEFAULT
+ | `SUBPIXEL_ORDER_RGB -> set_subpixel_order o SUBPIXEL_ORDER_RGB
+ | `SUBPIXEL_ORDER_BGR -> set_subpixel_order o SUBPIXEL_ORDER_BGR
+ | `SUBPIXEL_ORDER_VRGB -> set_subpixel_order o SUBPIXEL_ORDER_VRGB
+ | `SUBPIXEL_ORDER_VBGR -> set_subpixel_order o SUBPIXEL_ORDER_VBGR
+ | `HINT_STYLE_DEFAULT -> set_hint_style o HINT_STYLE_DEFAULT
+ | `HINT_STYLE_NONE -> set_hint_style o HINT_STYLE_NONE
+ | `HINT_STYLE_SLIGHT -> set_hint_style o HINT_STYLE_SLIGHT
+ | `HINT_STYLE_MEDIUM -> set_hint_style o HINT_STYLE_MEDIUM
+ | `HINT_STYLE_FULL -> set_hint_style o HINT_STYLE_FULL
+ | `HINT_METRICS_DEFAULT -> set_hint_metrics o HINT_METRICS_DEFAULT
+ | `HINT_METRICS_OFF -> set_hint_metrics o HINT_METRICS_OFF
+ | `HINT_METRICS_ON -> set_hint_metrics o HINT_METRICS_ON)
+ l ;
+ o
+end
+
external select_font_face : t -> string -> font_slant -> font_weight -> unit = "ml_cairo_select_font_face"
external set_font_size : t -> float -> unit = "ml_cairo_set_font_size"
external set_font_matrix : t -> matrix -> unit = "ml_cairo_set_font_matrix"
external get_font_matrix : t -> matrix = "ml_cairo_get_font_matrix"
+external set_font_options : t -> Font_Options.t -> unit = "ml_cairo_set_font_matrix"
+external _get_font_options : t -> Font_Options.t -> unit = "ml_cairo_get_font_options"
+let merge_font_options cr o' =
+ let o = Font_Options.create () in
+ _get_font_options cr o ;
+ Font_Options.merge o o' ;
+ set_font_options cr o
+let get_font_options cr =
+ let o = Font_Options.create () in
+ _get_font_options cr o ;
+ o
external show_text : t -> string -> unit = "ml_cairo_show_text"
external show_glyphs : t -> glyph array -> unit = "ml_cairo_show_glyphs"
external get_font_face : t -> [`Any] font_face = "ml_cairo_get_font_face"
@@ -170,6 +261,15 @@
external text_path : t -> string -> unit = "ml_cairo_text_path"
external glyph_path : t -> glyph array -> unit = "ml_cairo_glyph_path"
+(* scaled fonts *)
+module Scaled_Font = struct
+type -'a t
+
+external create : ([>`Any] as 'a) font_face -> matrix -> matrix -> Font_Options.t -> 'a t = "ml_cairo_scaled_font_create"
+external font_extents : [> `Any] t -> font_extents = "ml_cairo_scaled_font_extents"
+external glyph_extents : [> `Any] t -> glyph array -> text_extents = "ml_cairo_scaled_font_glyph_extents"
+end
+
external get_operator : t -> operator = "ml_cairo_get_operator"
external get_source : t -> [`Any] pattern = "ml_cairo_get_source"
external get_tolerance : t -> float = "ml_cairo_get_tolerance"
@@ -199,7 +299,11 @@
| `CURVE_TO (p1, p2, p3) -> curve_to_point cr p1 p2 p3
external status : t -> status = "ml_cairo_status"
+external surface_status : [> `Any] surface -> status = "ml_cairo_surface_status"
external pattern_status : [> `Any] pattern -> status = "ml_cairo_pattern_status"
+external font_face_status : [> `Any] font_face -> status = "ml_cairo_font_face_status"
+external scaled_font_status : [> `Any] Scaled_Font.t -> status = "ml_cairo_scaled_font_status"
+external font_options_status : Font_Options.t -> status = "ml_cairo_font_options_status"
external string_of_status : status -> string = "ml_cairo_status_to_string"
@@ -214,6 +318,12 @@
external surface_finish : [> `Any] surface -> unit = "ml_cairo_surface_finish"
+external _surface_get_font_options : [> `Any] surface -> Font_Options.t -> unit = "ml_cairo_surface_get_font_options"
+let surface_get_font_options s =
+ let o = Font_Options.create () in
+ _surface_get_font_options s o ;
+ o
+
external surface_set_device_offset : [> `Any] surface -> float -> float -> unit = "ml_cairo_surface_set_device_offset"
@@ -289,14 +399,3 @@
external transform_distance : matrix -> point -> point = "ml_cairo_matrix_transform_distance"
external transform_point : matrix -> point -> point = "ml_cairo_matrix_transform_point"
end
-
-
-
-(* fonts *)
-module Scaled_Font = struct
-type -'a t
-
-external create : ([>`Any] as 'a) font_face -> matrix -> matrix -> 'a t = "ml_cairo_scaled_font_create"
-external font_extents : [> `Any] t -> font_extents = "ml_cairo_scaled_font_extents"
-external glyph_extents : [> `Any] t -> glyph array -> text_extents = "ml_cairo_scaled_font_glyph_extents"
-end
Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cairo.mli 18 Jul 2005 21:10:27 -0000 1.19
+++ cairo.mli 10 Aug 2005 23:45:15 -0000 1.20
@@ -26,6 +26,10 @@
| SURFACE_FINISHED
| SURFACE_TYPE_MISMATCH
| PATTERN_TYPE_MISMATCH
+ | INVALID_CONTENT
+ | INVALID_FORMAT
+ | INVALID_VISUAL
+ | FILE_NOT_FOUND
exception Error of status
val init : unit
@@ -50,10 +54,12 @@
external restore : t -> unit = "ml_cairo_restore"
external status : t -> status = "ml_cairo_status"
+external surface_status : [> `Any] surface -> status = "ml_cairo_surface_status"
external pattern_status : [> `Any] pattern -> status = "ml_cairo_pattern_status"
+external font_face_status : [> `Any] font_face -> status = "ml_cairo_font_face_status"
external string_of_status : status -> string = "ml_cairo_status_to_string"
-(** {4 Renderer state} *)
+(** {3 Renderer state} *)
type operator =
OPERATOR_CLEAR
@@ -101,7 +107,7 @@
external set_dash : t -> float array -> float -> unit = "ml_cairo_set_dash"
external set_miter_limit : t -> float -> unit = "ml_cairo_set_miter_limit"
-(** {4 Transformations} *)
+(** {3 Transformations} *)
external translate : t -> tx:float -> ty:float -> unit = "ml_cairo_translate"
external scale : t -> sx:float -> sy:float -> unit = "ml_cairo_scale"
@@ -115,7 +121,7 @@
external device_to_user : t -> point -> point = "ml_cairo_device_to_user"
external device_to_user_distance : t -> point -> point = "ml_cairo_device_to_user_distance"
-(** {4 Paths} *)
+(** {3 Paths} *)
external new_path : t -> unit = "ml_cairo_new_path"
external move_to : t -> x:float -> y:float -> unit = "ml_cairo_move_to"
@@ -172,18 +178,80 @@
max_x_advance : float;
max_y_advance : float;
}
-type font_weight =
- | FONT_WEIGHT_NORMAL
- | FONT_WEIGHT_BOLD
type font_slant =
| FONT_SLANT_NORMAL
| FONT_SLANT_ITALIC
| FONT_SLANT_OBLIQUE
+type font_weight =
+ | FONT_WEIGHT_NORMAL
+ | FONT_WEIGHT_BOLD
+
+type antialias =
+ ANTIALIAS_DEFAULT
+ | ANTIALIAS_NONE
+ | ANTIALIAS_GRAY
+ | ANTIALIAS_SUBPIXEL
+type subpixel_order =
+ SUBPIXEL_ORDER_DEFAULT
+ | SUBPIXEL_ORDER_RGB
+ | SUBPIXEL_ORDER_BGR
+ | SUBPIXEL_ORDER_VRGB
+ | SUBPIXEL_ORDER_VBGR
+type hint_style =
+ HINT_STYLE_DEFAULT
+ | HINT_STYLE_NONE
+ | HINT_STYLE_SLIGHT
+ | HINT_STYLE_MEDIUM
+ | HINT_STYLE_FULL
+type hint_metrics =
+ HINT_METRICS_DEFAULT
+ | HINT_METRICS_OFF
+ | HINT_METRICS_ON
+
+(** {4 Font options} *)
+
+(** Font options functions *)
+module Font_Options : sig
+ type t
+ external create : unit -> t = "ml_cairo_font_options_create"
+ external merge : t -> t -> unit = "ml_cairo_font_options_merge"
+ external get_antialias : t -> antialias = "ml_cairo_font_options_get_antialias"
+ external set_antialias : t -> antialias -> unit = "ml_cairo_font_options_set_antialias"
+ external get_subpixel_order : t -> subpixel_order = "ml_cairo_font_options_get_subpixel_order"
+ external set_subpixel_order : t -> subpixel_order -> unit = "ml_cairo_font_options_set_subpixel_order"
+ external get_hint_style : t -> hint_style = "ml_cairo_font_options_get_hint_style"
+ external set_hint_style : t -> hint_style -> unit = "ml_cairo_font_options_set_hint_style"
+ external get_hint_metrics : t -> hint_metrics = "ml_cairo_font_options_get_hint_metrics"
+ external set_hint_metrics : t -> hint_metrics -> unit = "ml_cairo_font_options_set_hint_metrics"
+
+ type all = [
+ `ANTIALIAS_DEFAULT
+ | `ANTIALIAS_GRAY
+ | `ANTIALIAS_NONE
+ | `ANTIALIAS_SUBPIXEL
+ | `HINT_METRICS_DEFAULT
+ | `HINT_METRICS_OFF
+ | `HINT_METRICS_ON
+ | `HINT_STYLE_DEFAULT
+ | `HINT_STYLE_FULL
+ | `HINT_STYLE_MEDIUM
+ | `HINT_STYLE_NONE
+ | `HINT_STYLE_SLIGHT
+ | `SUBPIXEL_ORDER_BGR
+ | `SUBPIXEL_ORDER_DEFAULT
+ | `SUBPIXEL_ORDER_RGB
+ | `SUBPIXEL_ORDER_VBGR
+ | `SUBPIXEL_ORDER_VRGB ]
+ val make : [< all] list -> t
+end
external select_font_face : t -> string -> font_slant -> font_weight -> unit = "ml_cairo_select_font_face"
external set_font_size : t -> float -> unit = "ml_cairo_set_font_size"
external set_font_matrix : t -> matrix -> unit = "ml_cairo_set_font_matrix"
external get_font_matrix : t -> matrix = "ml_cairo_get_font_matrix"
+external set_font_options : t -> Font_Options.t -> unit = "ml_cairo_set_font_matrix"
+val merge_font_options : t -> Font_Options.t -> unit
+val get_font_options : t -> Font_Options.t
external show_text : t -> string -> unit = "ml_cairo_show_text"
external show_glyphs : t -> glyph array -> unit = "ml_cairo_show_glyphs"
external get_font_face : t -> [`Any] font_face = "ml_cairo_get_font_face"
@@ -194,7 +262,18 @@
external text_path : t -> string -> unit = "ml_cairo_text_path"
external glyph_path : t -> glyph array -> unit = "ml_cairo_glyph_path"
-(** {4 Renderer state querying} *)
+(** {4 Scaled Fonts API} *)
+
+(** Scaled fonts functions *)
+module Scaled_Font : sig
+type -'a t
+
+external create : ([>`Any] as 'a) font_face -> matrix -> matrix -> Font_Options.t -> 'a t = "ml_cairo_scaled_font_create"
+external font_extents : [> `Any] t -> font_extents = "ml_cairo_scaled_font_extents"
+external glyph_extents : [>`Any] t -> glyph array -> text_extents = "ml_cairo_scaled_font_glyph_extents"
+end
+
+(** {3 Renderer state querying} *)
external get_operator : t -> operator = "ml_cairo_get_operator"
external get_source : t -> [`Any] pattern = "ml_cairo_get_source"
@@ -247,7 +326,7 @@
external image_surface_get_width : [>`Image] surface -> int = "ml_cairo_image_surface_get_width"
external image_surface_get_height : [>`Image] surface -> int = "ml_cairo_image_surface_get_height"
-(** {4 Patterns} *)
+(** {3 Patterns} *)
type solid_pattern = [`Any|`Solid] pattern
type surface_pattern = [`Any|`Surface] pattern
@@ -305,14 +384,3 @@
external transform_distance : matrix -> point -> point = "ml_cairo_matrix_transform_distance"
external transform_point : matrix -> point -> point = "ml_cairo_matrix_transform_point"
end
-
-(** {3 Scaled Fonts API} *)
-
-(** Scaled fonts functions *)
-module Scaled_Font : sig
-type -'a t
-
-external create : ([>`Any] as 'a) font_face -> matrix -> matrix -> 'a t = "ml_cairo_scaled_font_create"
-external font_extents : [> `Any] t -> font_extents = "ml_cairo_scaled_font_extents"
-external glyph_extents : [>`Any] t -> glyph array -> text_extents = "ml_cairo_scaled_font_glyph_extents"
-end
Index: cairo_ft.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ft.ml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo_ft.ml 18 Jul 2005 21:10:27 -0000 1.5
+++ cairo_ft.ml 10 Aug 2005 23:45:15 -0000 1.6
@@ -19,7 +19,7 @@
external done_face : ft_face -> unit = "ml_FT_Done_Face"
type fc_pattern
-external fc_name_parse : string -> fc_pattern = "ml_FcNameParse"
+external fc_name_parse : ?options:Cairo.Font_Options.t -> string -> fc_pattern = "ml_FcNameParse"
external fc_name_unparse : fc_pattern -> string = "ml_FcNameUnparse"
type font_face = [`Any|`FT] Cairo.font_face
Index: cairo_ft.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_ft.mli,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo_ft.mli 18 Jul 2005 21:10:27 -0000 1.5
+++ cairo_ft.mli 10 Aug 2005 23:45:15 -0000 1.6
@@ -21,8 +21,12 @@
external done_face : ft_face -> unit = "ml_FT_Done_Face"
type fc_pattern
-external fc_name_parse : string -> fc_pattern = "ml_FcNameParse"
-(** this is a hack: this actually calls FcNameParse, FcConfigSubstitute,
+external fc_name_parse :
+ ?options:Cairo.Font_Options.t ->
+ string -> fc_pattern = "ml_FcNameParse"
+(** this is a hack: this actually calls
+ FcNameParse, FcConfigSubstitute,
+ cairo_ft_font_options_substitute,
FcDefaultSubstitute and FcFontMatch *)
external fc_name_unparse : fc_pattern -> string = "ml_FcNameUnparse"
Index: cairo_lablgtk.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_lablgtk.ml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo_lablgtk.ml 22 May 2005 20:03:15 -0000 1.3
+++ cairo_lablgtk.ml 10 Aug 2005 23:45:15 -0000 1.4
@@ -13,3 +13,7 @@
external surface_create : [> `drawable] Gobject.obj -> surface = "ml_cairo_xlib_surface_create"
external surface_set_size : [> `Xlib] Cairo.surface -> int -> int -> unit = "ml_cairo_xlib_surface_set_size"
+external surface_set_drawable :
+ [> `Xlib] Cairo.surface ->
+ [> `drawable] Gobject.obj ->
+ int -> int -> unit = "ml_cairo_xlib_surface_set_drawable"
Index: cairo_lablgtk.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_lablgtk.mli,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo_lablgtk.mli 22 May 2005 20:03:15 -0000 1.5
+++ cairo_lablgtk.mli 10 Aug 2005 23:45:15 -0000 1.6
@@ -15,3 +15,7 @@
external surface_create : [> `drawable] Gobject.obj -> surface = "ml_cairo_xlib_surface_create"
external surface_set_size : [> `Xlib] Cairo.surface -> int -> int -> unit = "ml_cairo_xlib_surface_set_size"
+external surface_set_drawable :
+ [> `Xlib] Cairo.surface ->
+ [> `drawable] Gobject.obj ->
+ int -> int -> unit = "ml_cairo_xlib_surface_set_drawable"
Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ml_cairo.c 18 Jul 2005 19:11:05 -0000 1.23
+++ ml_cairo.c 10 Aug 2005 23:45:15 -0000 1.24
@@ -313,6 +313,9 @@
#endif
}
+wML_1_cairo (set_font_options, cairo_font_options_t_val)
+wML_1_cairo (get_font_options, cairo_font_options_t_val)
+
wML_1_cairo(show_text, String_val)
cairo_glyph_t *
Index: ml_cairo.h
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ml_cairo.h 18 Jul 2005 19:11:05 -0000 1.11
+++ ml_cairo.h 10 Aug 2005 23:45:15 -0000 1.12
@@ -43,6 +43,9 @@
#define cairo_scaled_font_t_val(v) wPointer_val(cairo_scaled_font_t, v)
value Val_cairo_scaled_font_t (cairo_scaled_font_t *);
+#define cairo_font_options_t_val(v) wPointer_val(cairo_font_options_t, v)
+value Val_cairo_font_options_t (cairo_font_options_t *);
+
/* cairo_matrix */
#ifdef ARCH_ALIGN_DOUBLE
void ml_convert_cairo_matrix_in (value, cairo_matrix_t *);
@@ -63,7 +66,11 @@
void ml_cairo_treat_status (cairo_status_t) Noreturn;
#define cairo_treat_status(s) if (s != CAIRO_STATUS_SUCCESS) ml_cairo_treat_status (s)
#define check_cairo_status(cr) cairo_treat_status (cairo_status (cairo_t_val (cr)))
+#define check_surface_status(cr) cairo_treat_status (cairo_surface_status (cairo_surface_t_val (cr)))
#define check_pattern_status(cr) cairo_treat_status (cairo_pattern_status (cairo_pattern_t_val (cr)))
+#define check_font_face_status(cr) cairo_treat_status (cairo_font_face_status (cairo_font_face_t_val (cr)))
+#define check_scaled_font_status(cr) cairo_treat_status (cairo_scaled_font_status (cairo_scaled_font_t_val (cr)))
+#define check_font_options_status(cr) cairo_treat_status (cairo_font_options_status (cairo_font_options_t_val (cr)))
#define report_null_pointer() ml_cairo_treat_status (CAIRO_STATUS_NULL_POINTER)
/* stream callbacks */
Index: ml_cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_font.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_font.c 22 May 2005 20:03:15 -0000 1.1
+++ ml_cairo_font.c 10 Aug 2005 23:45:15 -0000 1.2
@@ -12,24 +12,49 @@
wMake_Val_final_pointer(cairo_scaled_font_t, cairo_scaled_font_destroy, 0)
+wMake_Val_final_pointer(cairo_font_options_t, cairo_font_options_destroy, 0)
+/* XXX: could be using cairo_font_options_equal and cairo_font_options_hash here ... */
+
/* font_face_reference */
/* font_face_destroy */
/* font_face_get_user_data */
/* font_face_set_user_data */
CAMLprim value
-ml_cairo_scaled_font_create (value f, value fmat, value ctm)
+ml_cairo_font_options_create (value unit)
+{
+ cairo_font_options_t *o = cairo_font_options_create();
+ cairo_treat_status (cairo_font_options_status (o));
+ return Val_cairo_font_options_t (o);
+}
+
+wML_2(cairo_font_options_merge, cairo_font_options_t_val, cairo_font_options_t_val, Unit)
+wML_2(cairo_font_options_set_antialias, cairo_font_options_t_val, Long_val, Unit)
+wML_1(cairo_font_options_get_antialias, cairo_font_options_t_val, Val_long)
+wML_2(cairo_font_options_set_subpixel_order, cairo_font_options_t_val, Long_val, Unit)
+wML_1(cairo_font_options_get_subpixel_order, cairo_font_options_t_val, Val_long)
+wML_2(cairo_font_options_set_hint_style, cairo_font_options_t_val, Long_val, Unit)
+wML_1(cairo_font_options_get_hint_style, cairo_font_options_t_val, Val_long)
+wML_2(cairo_font_options_set_hint_metrics, cairo_font_options_t_val, Long_val, Unit)
+wML_1(cairo_font_options_get_hint_metrics, cairo_font_options_t_val, Val_long)
+
+
+CAMLprim value
+ml_cairo_scaled_font_create (value f, value fmat, value ctm, value fo)
{
cairo_scaled_font_t *sf;
#ifndef ARCH_ALIGN_DOUBLE
sf = cairo_scaled_font_create (cairo_font_face_t_val (f),
cairo_matrix_t_val (fmat),
- cairo_matrix_t_val (ctm));
+ cairo_matrix_t_val (ctm),
+ cairo_font_options_t_val (fo));
#else
cairo_matrix_t c_fmat, c_ctm;
ml_convert_cairo_matrix_in (fmat, &c_fmat);
ml_convert_cairo_matrix_in (ctm, &c_ctm);
- sf = cairo_scaled_font_create (cairo_font_face_t_val (f), &c_fmat, &c_ctm);
+ sf = cairo_scaled_font_create (cairo_font_face_t_val (f),
+ &c_fmat, &c_ctm,
+ cairo_font_options_t_val (fo));
#endif
return Val_cairo_scaled_font_t (sf);
}
@@ -40,10 +65,9 @@
CAMLprim value
ml_cairo_scaled_font_extents (value sf)
{
- cairo_status_t status;
cairo_font_extents_t e;
- status = cairo_scaled_font_extents (cairo_scaled_font_t_val (sf), &e);
- cairo_treat_status (status);
+ cairo_scaled_font_extents (cairo_scaled_font_t_val (sf), &e);
+ cairo_treat_status (cairo_scaled_font_status (cairo_scaled_font_t_val (sf)));
return Val_cairo_font_extents (&e);
}
Index: ml_cairo_ft.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_ft.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ml_cairo_ft.c 18 Jul 2005 21:10:27 -0000 1.7
+++ ml_cairo_ft.c 10 Aug 2005 23:45:15 -0000 1.8
@@ -82,12 +82,16 @@
#define UString_val(v) ((unsigned char *) (v))
CAMLprim value
-ml_FcNameParse (value s)
+ml_FcNameParse (value fo, value s)
{
FcPattern *p1, *p2;
FcResult res;
p1 = FcNameParse (UString_val(s));
FcConfigSubstitute (NULL, p1, FcMatchPattern);
+ if (Is_block (fo))
+ {
+ cairo_ft_font_options_substitute (cairo_font_options_t_val (Field (fo, 0)), p1);
+ }
FcDefaultSubstitute (p1);
p2 = FcFontMatch (NULL, p1, &res);
FcPatternDestroy (p1);
Index: ml_cairo_lablgtk.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_lablgtk.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- ml_cairo_lablgtk.c 26 May 2005 23:56:10 -0000 1.12
+++ ml_cairo_lablgtk.c 10 Aug 2005 23:45:15 -0000 1.13
@@ -78,47 +78,71 @@
#if CAIRO_HAS_XLIB_SURFACE
-CAMLprim value
-ml_cairo_xlib_surface_create (value d)
+/* copied from pycairo, who got it from GTK+ */
+static cairo_surface_t *
+ml_gdk_cairo_surface_create (GdkDrawable *target)
{
- cairo_surface_t *surface;
- gint width, height;
- GdkDrawable *drawable = GdkDrawable_val(d);
- GdkVisual *visual = gdk_drawable_get_visual (drawable);
-
- gdk_drawable_get_size (drawable, &width, &height);
+ int width, height;
+ int x_off=0, y_off=0;
+ cairo_surface_t *surface;
+ GdkDrawable *drawable = target;
+ GdkVisual *visual;
- if (visual)
- surface = cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable),
- GDK_DRAWABLE_XID (drawable),
- GDK_VISUAL_XVISUAL (visual),
- width, height);
- else if (gdk_drawable_get_depth (drawable) == 1)
- surface =
- cairo_xlib_surface_create_for_bitmap (GDK_PIXMAP_XDISPLAY (drawable),
- GDK_PIXMAP_XID (drawable),
- width, height);
- else {
- g_warning ("Using Cairo rendering requires the drawable argument to\n"
- "have a specified colormap. All windows have a colormap,\n"
- "however, pixmaps only have colormap by default if they\n"
- "were created with a non-NULL window argument. Otherwise\n"
- "a colormap must be set on them with "
- "gdk_drawable_set_colormap");
- surface = NULL;
- }
+ if (GDK_IS_WINDOW(target)) {
+ /* query the window's backbuffer if it has one */
+ GdkWindow *window = GDK_WINDOW(target);
+ gdk_window_get_internal_paint_info (window,
+ &drawable, &x_off, &y_off);
+ }
+ visual = gdk_drawable_get_visual (drawable);
+ gdk_drawable_get_size (drawable, &width, &height);
- if (surface != NULL)
- ml_cairo_surface_set_image_data (surface, d);
+ if (visual) {
+ surface = cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable),
+ GDK_DRAWABLE_XID (drawable),
+ GDK_VISUAL_XVISUAL (visual),
+ width, height);
+ } else if (gdk_drawable_get_depth (drawable) == 1) {
+ surface = cairo_xlib_surface_create_for_bitmap
+ (GDK_PIXMAP_XDISPLAY (drawable),
+ GDK_PIXMAP_XID (drawable),
+ GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (drawable)),
+ width, height);
+ } else {
+ g_warning ("Using Cairo rendering requires the drawable argument to\n"
+ "have a specified colormap. All windows have a colormap,\n"
+ "however, pixmaps only have colormap by default if they\n"
+ "were created with a non-NULL window argument. Otherwise\n"
+ "a colormap must be set on them with "
+ "gdk_drawable_set_colormap");
+ return NULL;
+ }
+ cairo_surface_set_device_offset (surface, -x_off, -y_off);
+ return surface;
+}
- return Val_cairo_surface_t (surface);
+CAMLprim value
+ml_cairo_xlib_surface_create (value d)
+{
+ return Val_cairo_surface_t (ml_gdk_cairo_surface_create (GdkDrawable_val(d)));
}
ML_3 (cairo_xlib_surface_set_size, cairo_surface_t_val, Int_val, Int_val, Unit)
+CAMLprim value
+ml_cairo_xlib_surface_set_drawable (value s, value d, value w, value h)
+{
+ cairo_xlib_surface_set_drawable (cairo_surface_t_val (s),
+ GDK_DRAWABLE_XID (GdkDrawable_val (d)),
+ Int_val (w),
+ Int_val (h));
+ return Val_unit;
+}
+
#else
Cairo_Unsupported(cairo_xlib_surface_create, "Xlib backend not supported");
Cairo_Unsupported(cairo_xlib_surface_set_size, "Xlib backend not supported");
+Cairo_Unsupported(cairo_xlib_surface_set_drawable, "Xlib backend not supported");
#endif /* CAIRO_HAS_XLIB_SURFACE */
Index: ml_cairo_status.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_status.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ml_cairo_status.c 18 Jul 2005 19:11:05 -0000 1.7
+++ ml_cairo_status.c 10 Aug 2005 23:45:15 -0000 1.8
@@ -9,7 +9,11 @@
#include "ml_cairo.h"
wML_1 (cairo_status, cairo_t_val, Val_int)
+wML_1 (cairo_surface_status, cairo_surface_t_val, Val_int)
wML_1 (cairo_pattern_status, cairo_pattern_t_val, Val_int)
+wML_1 (cairo_font_face_status, cairo_font_face_t_val, Val_int)
+wML_1 (cairo_scaled_font_status, cairo_scaled_font_t_val, Val_int)
+wML_1 (cairo_font_options_status, cairo_font_options_t_val, Val_int)
wML_1 (cairo_status_to_string, Int_val, caml_copy_string)
Index: ml_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_surface.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ml_cairo_surface.c 18 Jul 2005 19:11:05 -0000 1.3
+++ ml_cairo_surface.c 10 Aug 2005 23:45:15 -0000 1.4
@@ -32,9 +32,8 @@
CAMLprim value
ml_cairo_surface_finish (value surf)
{
- cairo_status_t s;
- s = cairo_surface_finish (cairo_surface_t_val (surf));
- cairo_treat_status (s);
+ cairo_surface_finish (cairo_surface_t_val (surf));
+ check_surface_status (surf);
return Val_unit;
}
@@ -86,4 +85,6 @@
/* surface_get_user_data */
+wML_2(cairo_surface_get_font_options, cairo_surface_t_val, cairo_font_options_t_val, Unit)
+
wML_3(cairo_surface_set_device_offset, cairo_surface_t_val, Double_val, Double_val, Unit)
More information about the cairo-commit
mailing list