[cairo-commit] cairo-ocaml/src ocairo.ml,1.2,1.3 ocairo.mli,1.2,1.3 cairo.ml,1.2,1.3 cairo.mli,1.2,1.3 ml_cairo.c,1.4,1.5 ml_cairo_bigarr.c,1.1.1.1,1.2

Olivier Andrieu commit at pdx.freedesktop.org
Tue Dec 16 17:15:33 PST 2003


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/src
In directory pdx:/tmp/cvs-serv11388/src

Modified Files:
	ocairo.ml ocairo.mli cairo.ml cairo.mli ml_cairo.c 
	ml_cairo_bigarr.c 
Log Message:
text API work

Index: ocairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ocairo.ml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ocairo.ml	18 Nov 2003 19:15:49 -0000	1.2
--- ocairo.ml	17 Dec 2003 01:15:31 -0000	1.3
***************
*** 32,39 ****
  
  type glyph = Cairo.glyph = { index : int; glyph_x : float; glyph_y : float; }
  type font_extents = Cairo.font_extents = {
!   ascent : float;
!   descent : float;
!   height : float;
    max_x_advance : float;
    max_y_advance : float;
--- 32,46 ----
  
  type glyph = Cairo.glyph = { index : int; glyph_x : float; glyph_y : float; }
+ type text_extents = Cairo.text_extents = { 
+     x_bearing   : float ;
+     y_bearing   : float ;
+     text_width  : float ;
+     text_height : float ;
+     x_advance   : float ;
+     y_advance   : float }
  type font_extents = Cairo.font_extents = {
!   ascent        : float;
!   descent       : float;
!   font_height   : float;
    max_x_advance : float;
    max_y_advance : float;
***************
*** 144,149 ****
      method transform_font (mat : matrix) = Cairo.transform_font c mat#get_matrix
      method show_text str = Cairo.show_text c str
!     method show_glyphs gl n = Cairo.show_glyphs c gl n
      method font_extents = Cairo.current_font_extents c
    end
  
--- 151,160 ----
      method transform_font (mat : matrix) = Cairo.transform_font c mat#get_matrix
      method show_text str = Cairo.show_text c str
!     method show_glyphs gl = Cairo.show_glyphs c gl
      method font_extents = Cairo.current_font_extents c
+     method text_extents s = Cairo.text_extents c s
+     method glyph_extents gl = Cairo.glyph_extents c gl
+     method text_path s = Cairo.text_path c s
+     method glyph_path gl = Cairo.glyph_path c gl
    end
  

Index: ocairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ocairo.mli,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ocairo.mli	18 Nov 2003 19:15:49 -0000	1.2
--- ocairo.mli	17 Dec 2003 01:15:31 -0000	1.3
***************
*** 37,45 ****
    | LINE_JOIN_BEVEL
  type glyph = Cairo.glyph = { index : int; glyph_x : float; glyph_y : float; }
! type font_extents =
!   Cairo.font_extents = {
!   ascent : float;
!   descent : float;
!   height : float;
    max_x_advance : float;
    max_y_advance : float;
--- 37,51 ----
    | LINE_JOIN_BEVEL
  type glyph = Cairo.glyph = { index : int; glyph_x : float; glyph_y : float; }
! type text_extents = Cairo.text_extents = { 
!     x_bearing   : float ;
!     y_bearing   : float ;
!     text_width  : float ;
!     text_height : float ;
!     x_advance   : float ;
!     y_advance   : float }
! type font_extents = Cairo.font_extents = {
!   ascent        : float;
!   descent       : float;
!   font_height   : float;
    max_x_advance : float;
    max_y_advance : float;
***************
*** 83,86 ****
--- 89,94 ----
      method font_extents : Cairo.font_extents
      method get_cairo : Cairo.t
+     method glyph_extents : glyph array -> text_extents
+     method glyph_path : glyph array -> unit
      method identity_matrix : unit
      method in_stroke : float -> float -> bool
***************
*** 127,131 ****
      method set_target_surface : surface -> unit
      method set_tolerance : float -> unit
!     method show_glyphs : Cairo.glyph -> int -> unit
      method show_page : unit
      method show_surface : surface -> int -> int -> unit
--- 135,139 ----
      method set_target_surface : surface -> unit
      method set_tolerance : float -> unit
!     method show_glyphs : Cairo.glyph array -> unit
      method show_page : unit
      method show_surface : surface -> int -> int -> unit
***************
*** 133,136 ****
--- 141,146 ----
      method stroke : unit
      method target_surface : surface
+     method text_extents : string -> text_extents
+     method text_path : string -> unit
      method tolerance : float
      method transform_distance : point -> unit

Index: cairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.ml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cairo.ml	18 Nov 2003 19:15:49 -0000	1.2
--- cairo.ml	17 Dec 2003 01:15:31 -0000	1.3
***************
*** 20,24 ****
  type matrix
  external create : unit -> t = "ml_cairo_create"
- external reference : cr:t -> unit = "ml_cairo_reference"
  external destroy : cr:t -> unit = "ml_cairo_destroy"
  external save : cr:t -> unit = "ml_cairo_save"
--- 20,23 ----
***************
*** 130,137 ****
  type font
  type glyph = { index : int; glyph_x : float; glyph_y : float; }
  type font_extents =
    { ascent : float;
      descent : float;
!     height : float;
      max_x_advance : float;
      max_y_advance : float }
--- 129,143 ----
  type font
  type glyph = { index : int; glyph_x : float; glyph_y : float; }
+ type text_extents = 
+   { x_bearing   : float ;
+     y_bearing   : float ;
+     text_width  : float ;
+     text_height : float ;
+     x_advance   : float ;
+     y_advance   : float }
  type font_extents =
    { ascent : float;
      descent : float;
!     font_height : float;
      max_x_advance : float;
      max_y_advance : float }
***************
*** 151,160 ****
  external show_text : ct:t -> utf8:string -> unit = "ml_cairo_show_text"
  external show_glyphs :
!   ct:t -> glyphs:glyph -> num_glyphs:int -> unit = "ml_cairo_show_glyphs"
  external current_font : ct:t -> font = "ml_cairo_current_font"
  external current_font_extents :
    ct:t -> font_extents = "ml_cairo_current_font_extents"
  external set_font : ct:t -> font:font -> unit = "ml_cairo_set_font"
! external font_reference : font:font -> unit = "ml_cairo_font_reference"
  external font_destroy : font:font -> unit = "ml_cairo_font_destroy"
  external font_set_transform :
--- 157,169 ----
  external show_text : ct:t -> utf8:string -> unit = "ml_cairo_show_text"
  external show_glyphs :
!   ct:t -> glyph array -> unit = "ml_cairo_show_glyphs"
  external current_font : ct:t -> font = "ml_cairo_current_font"
  external current_font_extents :
    ct:t -> font_extents = "ml_cairo_current_font_extents"
  external set_font : ct:t -> font:font -> unit = "ml_cairo_set_font"
! external text_extents : t -> utf8:string -> text_extents = "ml_cairo_text_extents"
! 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 :
***************
*** 185,190 ****
    other:surface -> format:format -> width:int -> height:int ->
      surface = "ml_cairo_surface_create_similar"
- external surface_reference :
-   surface:surface -> unit = "ml_cairo_surface_reference"
  external surface_destroy :
    surface:surface -> unit = "ml_cairo_surface_destroy"
--- 194,197 ----

Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cairo.mli	18 Nov 2003 19:15:49 -0000	1.2
--- cairo.mli	17 Dec 2003 01:15:31 -0000	1.3
***************
*** 160,169 ****
  type font
  type glyph = { index : int; glyph_x : float; glyph_y : float; }
  type font_extents = {
!   ascent : float;
!   descent : float;
!   height : float;
!   max_x_advance : float;
!   max_y_advance : float;
  }
  type font_weight = 
--- 160,176 ----
  type font
  type glyph = { index : int; glyph_x : float; glyph_y : float; }
+ type text_extents = { 
+     x_bearing   : float ;
+     y_bearing   : float ;
+     text_width  : float ;
+     text_height : float ;
+     x_advance   : float ;
+     y_advance   : float }
  type font_extents = {
!     ascent        : float;
!     descent       : float;
!     font_height   : float;
!     max_x_advance : float;
!     max_y_advance : float;
  }
  type font_weight = 
***************
*** 182,190 ****
    = "ml_cairo_transform_font"
  external show_text : ct:t -> utf8:string -> unit = "ml_cairo_show_text"
! external show_glyphs : ct:t -> glyphs:glyph -> num_glyphs:int -> unit
    = "ml_cairo_show_glyphs"
  external current_font : ct:t -> font = "ml_cairo_current_font"
  external current_font_extents : ct:t -> font_extents
    = "ml_cairo_current_font_extents"
  
  (** {4 Renderer state querying} *)
--- 189,201 ----
    = "ml_cairo_transform_font"
  external show_text : ct:t -> utf8:string -> unit = "ml_cairo_show_text"
! external show_glyphs : ct:t -> glyph array -> unit
    = "ml_cairo_show_glyphs"
  external current_font : ct:t -> font = "ml_cairo_current_font"
  external current_font_extents : ct:t -> font_extents
    = "ml_cairo_current_font_extents"
+ external text_extents : t -> utf8:string -> text_extents = "ml_cairo_text_extents"
+ 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"
  
  (** {4 Renderer state querying} *)

Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ml_cairo.c	13 Dec 2003 14:10:42 -0000	1.4
--- ml_cairo.c	17 Dec 2003 01:15:31 -0000	1.5
***************
*** 20,30 ****
  ML_0(cairo_create, Val_cairo_t)
  
- CAMLprim value
- ml_cairo_reference(value v_cr)
- {
-   cairo_reference(cairo_t_val(v_cr));
-   check_cairo_status(v_cr);
-   return Val_unit;
- }
  ML_1(cairo_destroy, cairo_t_val, Unit)
  
--- 20,23 ----
***************
*** 601,604 ****
--- 594,611 ----
  }
  
+ static value
+ Val_cairo_text_extents_t(cairo_text_extents_t * _s)
+ {
+   value _v;
+   _v = alloc_small(6 * Double_wosize, Double_array_tag);
+   Store_double_field(_v, 0, _s->x_bearing);
+   Store_double_field(_v, 1, _s->y_bearing);
+   Store_double_field(_v, 2, _s->width);
+   Store_double_field(_v, 3, _s->height);
+   Store_double_field(_v, 4, _s->x_advance);
+   Store_double_field(_v, 5, _s->y_advance);
+   return _v;
+ }
+ 
  static inline cairo_font_weight_t
  cairo_font_weight_t_val(value _v)
***************
*** 654,662 ****
  
  CAMLprim value
! ml_cairo_show_glyphs(value v_ct, value v_glyphs, value v_num_glyphs)
  {
!   cairo_glyph_t c_glyphs;
!   cairo_glyph_t_val(&c_glyphs, v_glyphs);
!   cairo_show_glyphs(cairo_t_val(v_ct), &c_glyphs, Int_val(v_num_glyphs));
    check_cairo_status(v_ct);
    return Val_unit;
--- 661,672 ----
  
  CAMLprim value
! ml_cairo_show_glyphs(value v_ct, value v_glyphs)
  {
!   size_t num_glyphs = Wosize_val(v_glyphs);
!   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_show_glyphs(cairo_t_val(v_ct), c_glyphs, num_glyphs);
    check_cairo_status(v_ct);
    return Val_unit;
***************
*** 688,692 ****
    return Val_unit;
  }
! ML_1(cairo_font_reference, cairo_font_t_val, Unit)
  
  ML_1(cairo_font_destroy, cairo_font_t_val, Unit)
--- 698,745 ----
    return Val_unit;
  }
! 
! CAMLprim value
! ml_cairo_text_extents(value v_ct, value v_utf8)
! {
!   cairo_text_extents_t c_extents;
!   cairo_text_extents(cairo_t_val(v_ct), String_val(v_utf8), &c_extents);
!   check_cairo_status(v_ct);
!   return Val_cairo_text_extents_t(&c_extents);
! }
! 
! CAMLprim value
! ml_cairo_glyph_extents(value v_ct, 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_glyph_extents(cairo_t_val(v_ct), c_glyphs, num_glyphs, &c_extents);
!   check_cairo_status(v_ct);
!   return Val_cairo_text_extents_t(&c_extents);
! }
! 
! CAMLprim value
! ml_cairo_text_path(value v_ct, value v_utf8)
! {
!   cairo_text_path(cairo_t_val(v_ct), String_val(v_utf8));
!   check_cairo_status(v_ct);
!   return Val_unit;
! }
! 
! CAMLprim value
! ml_cairo_glyph_path(value v_ct, value v_glyphs)
! {
!   size_t num_glyphs = Wosize_val(v_glyphs);
!   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_glyph_path(cairo_t_val(v_ct), c_glyphs, num_glyphs);
!   check_cairo_status(v_ct);
!   return Val_unit;
! }
  
  ML_1(cairo_font_destroy, cairo_font_t_val, Unit)
***************
*** 839,843 ****
  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_reference, 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)
--- 892,895 ----

Index: ml_cairo_bigarr.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_bigarr.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ml_cairo_bigarr.c	18 Nov 2003 19:02:25 -0000	1.1.1.1
--- ml_cairo_bigarr.c	17 Dec 2003 01:15:31 -0000	1.2
***************
*** 20,26 ****
    case BIGARRAY_COMPLEX32:
    case BIGARRAY_COMPLEX64:
!     return Val_bool(1);
    default:
!     return Val_bool(0);
    }
  }
--- 20,26 ----
    case BIGARRAY_COMPLEX32:
    case BIGARRAY_COMPLEX64:
!     return Val_true;
    default:
!     return Val_false;
    }
  }





More information about the cairo-commit mailing list