[cairo-commit] cairo-ocaml/test font.ml,NONE,1.1 Makefile,1.4,1.5
Olivier Andrieu
commit at pdx.freedesktop.org
Mon Nov 1 07:50:30 PST 2004
Committed by: oandrieu
Update of /cvs/cairo/cairo-ocaml/test
In directory gabe:/tmp/cvs-serv22155/test
Modified Files:
Makefile
Added Files:
font.ml
Log Message:
minimal support for freetype/fontconfig font backend
--- NEW FILE: font.ml ---
let out_file name =
let oc = open_out name in
let channel = Cairo_channel.of_out_channel oc in
close_out oc ;
channel
let pi = 4. *. atan 1.
let main font_arg =
let ft = Cairo_ft.init_freetype () in
let font, clean_up =
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
(font, (fun () -> Cairo_ft.done_face face))
else
let pattern = Cairo_ft.fc_name_parse font_arg in
let font = Cairo_ft.font_create ft pattern in
(font, ignore)
in
let cr = Cairo.create () in
let file = out_file "test_font.png" in
Cairo.set_target_png ~cr ~file Cairo.FORMAT_ARGB32 ~width:200 ~height:200 ;
Cairo.set_font ~cr ~font ;
Cairo.scale_font 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 ;
clean_up () ;
Cairo_ft.done_freetype ft
let _ =
if Array.length Sys.argv < 2 then exit 1 ;
main Sys.argv.(1)
Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile 24 Mar 2004 10:39:24 -0000 1.4
+++ Makefile 1 Nov 2004 15:50:28 -0000 1.5
@@ -2,7 +2,7 @@
include ../config.make
ifdef LABLGTKDIR
-TARGETS += text demo spline basket knockout
+TARGETS += text demo spline basket knockout font
ifdef GTKCAIRO_CFLAGS
TARGETS += cube
endif
@@ -10,6 +10,9 @@
all : $(TARGETS)
+font : font.ml
+ $(OCAMLOPT) -o $@ -I ../src cairo.cmxa $^
+
text : text.ml
$(OCAMLOPT) -w s -o $@ -I ../src -I $(LABLGTKDIR) lablgtk.cmxa cairo.cmxa cairo_lablgtk.cmxa gtkInit.cmx $^
More information about the cairo-commit
mailing list