[cairo-commit] cairo-ocaml/test font.ml,1.3,1.4 Makefile,1.8,1.9

Olivier Andrieu commit at pdx.freedesktop.org
Mon Jul 18 14:10:29 PDT 2005


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/test
In directory gabe:/tmp/cvs-serv5619/test

Modified Files:
	font.ml Makefile 
Log Message:
* src/cairo_ft.ml, src/cairo_ft.mli, src/ml_cairo_ft.c: re-enable
freetype font backend bindings

* test/font.ml: adapt

* src/cairo.mli, src/cairo_png.mli: use `Any surface instead of 'a
surface everywhere


Index: font.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/font.ml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- font.ml	2 Mar 2005 18:52:29 -0000	1.3
+++ font.ml	18 Jul 2005 21:10:27 -0000	1.4
@@ -14,34 +14,32 @@
     if Sys.file_exists font_arg
     then
       let face = Cairo_ft.new_face ft font_arg in
-      let font = Cairo_ft.font_create_for_ft_face face in
+      let font = Cairo_ft.font_face_create_for_ft_face face 0 in
       (font, (fun () -> Cairo_ft.done_face face))
-    else
+    else begin
       let pattern = Cairo_ft.fc_name_parse font_arg in
-      let font = Cairo_ft.font_create ft pattern in
+      let font = Cairo_ft.font_face_create_for_pattern pattern in
       (font, ignore)
+    end
   in
 
-  let cr = Cairo.create () in
-  let file = Cairo_channel.open_out "test_font.png" in
-  Cairo.set_target_png ~cr ~file Cairo.FORMAT_ARGB32 ~width:200 ~height:200 ;
+  let s = Cairo.image_surface_create Cairo.FORMAT_ARGB32 ~width:200 ~height:200 in
+  let cr = Cairo.create s in
 
-  Cairo.set_font ~cr ~font ;
+  Cairo.set_font_face cr font ;
 
-  Cairo.scale_font cr 20. ;
+  Cairo.set_font_size cr 20. ;
   Cairo.move_to cr 10. 10. ;
   Cairo.rotate cr (pi /. 2.) ;
   Cairo.show_text cr "Hello World !" ;
 
-  Cairo.finalise_target ~cr ;
-  Cairo_channel.close file ;
+  Cairo_png.surface_write_to_file s "test_font.png" ;
 
   clean_up () ;
   Cairo_ft.done_freetype ft
 
 let _ =
   if Array.length Sys.argv < 2 then exit 1 ;
-  main Sys.argv.(1)
-
-
-
+  try main Sys.argv.(1)
+  with Cairo.Error s ->
+    Printf.eprintf "Cairo error: '%s'\n%!" (Cairo.string_of_status s)

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/Makefile,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Makefile	22 May 2005 20:03:15 -0000	1.8
+++ Makefile	18 Jul 2005 21:10:27 -0000	1.9
@@ -3,7 +3,7 @@
 
 TARGETS = basket kapow
 ifdef LABLGTKDIR
-TARGETS += text demo spline knockout # font
+TARGETS += text demo spline knockout font
 ifdef GTKCAIRO_CFLAGS
 TARGETS += cube
 endif




More information about the cairo-commit mailing list