[cairo-commit] cairo-ocaml/src ml_cairo_wrappers.h, 1.5, 1.6 ml_cairo_ft.c, NONE, 1.1 ml_cairo.h, 1.5, 1.6 cairo_ft.mli, NONE, 1.1 cairo_ft.ml, NONE, 1.1 Makefile, 1.6, 1.7 .depend_c, 1.1.1.1, 1.2

Olivier Andrieu commit at pdx.freedesktop.org
Mon Nov 1 07:50:30 PST 2004


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/src
In directory gabe:/tmp/cvs-serv22155/src

Modified Files:
	ml_cairo_wrappers.h ml_cairo.h Makefile .depend_c 
Added Files:
	ml_cairo_ft.c cairo_ft.mli cairo_ft.ml 
Log Message:
minimal	support for freetype/fontconfig font backend


Index: ml_cairo_wrappers.h
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_wrappers.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ml_cairo_wrappers.h	18 Oct 2004 00:27:34 -0000	1.5
+++ ml_cairo_wrappers.h	1 Nov 2004 15:50:28 -0000	1.6
@@ -28,6 +28,8 @@
 #endif
 #define Double_array_length(v) (Wosize_val(v) / Double_wosize)
 
+#define Option_val(v,conv,def) (Is_long(v) ? def : conv(Field((v),0)))
+
 #define Ignore(x)
 #define Unit(x) ((x), Val_unit)
 

--- NEW FILE: ml_cairo_ft.c ---
#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/fail.h>
#include <caml/custom.h>
#include <caml/callback.h>

#include "ml_cairo_wrappers.h"

#include <cairo.h>
#include "ml_cairo.h"
#include "ml_cairo_status.h"

static void
ml_raise_FT_Error (FT_Error err)
{
  static value *caml_exn;
  if (err == FT_Err_Ok)
    return;

  if (caml_exn == NULL)
    {
      caml_exn = caml_named_value ("FT_exn");
      if (caml_exn == NULL)
	failwith ("freetype error");
    }

  raise_with_arg (*caml_exn, Val_int (err));
}

#define FT_Library_val(v) (FT_Library)Pointer_val(v)

CAMLprim value
ml_FT_Init_FreeType (value unit)
{
  FT_Library lib;
  ml_raise_FT_Error (FT_Init_FreeType (&lib));
  return Val_ptr (lib);
}

CAMLprim value
ml_FT_Done_FreeType (value lib)
{
  ml_raise_FT_Error (FT_Done_FreeType (FT_Library_val (lib)));
  return Val_unit;
}

#define FT_Face_val(v) (FT_Face)Pointer_val(v)

CAMLprim value
ml_FT_New_Face (value lib, value o_index, value path)
{
  FT_Face face;
  FT_Long index = Option_val(o_index, Long_val, 0);
  ml_raise_FT_Error (FT_New_Face (FT_Library_val (lib),
				  String_val (path),
				  index, &face));
  return Val_ptr (face);
}

CAMLprim value
ml_FT_Done_Face (value face)
{
  ml_raise_FT_Error (FT_Done_Face (FT_Face_val (face)));
  return Val_unit;
}

ML_1 (cairo_ft_font_create_for_ft_face, FT_Face_val, Val_cairo_font_t)

Make_Val_final_pointer (FcPattern, Ignore, FcPatternDestroy, 10)
#define FcPattern_val(v) (FcPattern *)Pointer_val(v)

ML_1 (FcNameParse, String_val, Val_FcPattern)

CAMLprim value
ml_FcNameUnparse (value patt)
{
  FcChar8 *s;
  value r;
  s = FcNameUnparse (FcPattern_val (patt));
  if (s == NULL)
    failwith ("FcNameUnparse");
  r = copy_string (s);
  free (s);
  return r;
}

ML_2 (cairo_ft_font_create, FT_Library_val, FcPattern_val, Val_cairo_font_t)

Index: ml_cairo.h
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ml_cairo.h	28 Oct 2004 13:46:01 -0000	1.5
+++ ml_cairo.h	1 Nov 2004 15:50:28 -0000	1.6
@@ -8,4 +8,5 @@
 #define Val_cairo_format_t(v) Val_int(v)
 
 value Val_cairo_surface_t (cairo_surface_t *);
+value Val_cairo_font_t (cairo_font_t *);
 value Val_cairo_t (cairo_t *);

--- NEW FILE: cairo_ft.mli ---
(** Minimal support for the Fontconfig/Freetype font interface *)

exception FT_Error of int

type ft_library
type ft_face

val init_freetype : unit -> ft_library
external done_freetype : ft_library -> unit = "ml_FT_Done_FreeType"

external new_face : ft_library -> ?index:int -> string -> ft_face
  = "ml_FT_New_Face"
external done_face : ft_face -> unit = "ml_FT_Done_Face"

external font_create_for_ft_face : ft_face -> Cairo.font
  = "ml_cairo_ft_font_create_for_ft_face"

type fc_pattern
external fc_name_parse : string -> fc_pattern = "ml_FcNameParse"
external fc_name_unparse : fc_pattern -> string = "ml_FcNameUnparse"

external font_create : ft_library -> fc_pattern -> Cairo.font
  = "ml_cairo_ft_font_create"

--- NEW FILE: cairo_ft.ml ---

exception FT_Error of int
let _ = Callback.register_exception "FT_exn" (FT_Error 0)

type ft_library
type ft_face

external init_freetype : unit -> ft_library = "ml_FT_Init_FreeType"
external done_freetype : ft_library -> unit = "ml_FT_Done_FreeType"

external new_face  : ft_library -> ?index:int -> string -> ft_face = "ml_FT_New_Face"
external done_face : ft_face -> unit = "ml_FT_Done_Face"

external font_create_for_ft_face : ft_face -> Cairo.font = "ml_cairo_ft_font_create_for_ft_face"

type fc_pattern
external fc_name_parse   : string -> fc_pattern = "ml_FcNameParse"
external fc_name_unparse : fc_pattern -> string = "ml_FcNameUnparse"

external font_create : ft_library -> fc_pattern -> Cairo.font = "ml_cairo_ft_font_create"

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Makefile	18 Oct 2004 00:27:34 -0000	1.6
+++ Makefile	1 Nov 2004 15:50:28 -0000	1.7
@@ -23,9 +23,11 @@
 
 cairo_SRC = cairo_channel.mli cairo.mli cairo.ml \
             cairo_bigarray.mli cairo_bigarray.ml \
+	    cairo_ft.mli cairo_ft.ml \
             ml_cairo_wrappers.c \
 	    ml_cairo_status.c ml_cairo_channel.c \
-            ml_cairo.c ml_cairo_bigarr.c ml_cairo_path.c
+            ml_cairo.c ml_cairo_bigarr.c ml_cairo_path.c \
+	    ml_cairo_ft.c
 
 cairo.cma : $(call mlobjs,$(cairo_SRC))
 	$(OCAMLMKLIB) -o cairo -oc mlcairo $^ $(CAIRO_LIBS)
@@ -73,7 +75,7 @@
           for lib in dll*.so ; do \
             ln -s $(INSTALLDIR)/$$lib $(DESTDIR)$(OCAMLLIB)/stublibs ; done ; fi
 
-DOCFILES = cairo_channel.mli cairo.mli cairo_bigarray.mli
+DOCFILES = cairo_channel.mli cairo.mli cairo_bigarray.mli cairo_ft.mli
 ifdef LABLGTKDIR
 DOCFILES += cairo_lablgtk.mli
 ifdef GTKCAIRO_CFLAGS
@@ -94,6 +96,9 @@
 -include .depend
 include .depend_c
 
+depend : .depend $(wildcard *.h *.c)
+	gcc -MM -isystem $(OCAMLLIB) -isystem $(C_LABLGTKDIR) $(patsubst -I%,-isystem %,$(GDK_CFLAGS)) $(filter %.c,$^) > .depend_c
+
 .PHONY : cairo lablgtk gtkcairo doc
 
 include ../Makefile.rules

Index: .depend_c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/.depend_c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- .depend_c	18 Nov 2003 19:02:26 -0000	1.1.1.1
+++ .depend_c	1 Nov 2004 15:50:28 -0000	1.2
@@ -1,3 +1,13 @@
-ml_cairo.o: ml_cairo_wrappers.h ml_cairo_channel.h ml_cairo_status.h ml_cairo.h
-ml_cairo_channel.o: ml_cairo_wrappers.h caml_io.h ml_cairo_channel.h
-ml_cairo_lablgtk.o: ml_cairo_status.h ml_cairo.h 
+ml_cairo_bigarr.o: ml_cairo_bigarr.c
+ml_cairo.o: ml_cairo.c ml_cairo_wrappers.h ml_cairo_channel.h \
+  ml_cairo_status.h ml_cairo.h
+ml_cairo_channel.o: ml_cairo_channel.c ml_cairo_wrappers.h caml_io.h \
+  ml_cairo_channel.h
+ml_cairo_ft.o: ml_cairo_ft.c ml_cairo_wrappers.h ml_cairo.h \
+  ml_cairo_status.h
+ml_cairo_gtkcairo.o: ml_cairo_gtkcairo.c ml_cairo.h
+ml_cairo_lablgtk.o: ml_cairo_lablgtk.c ml_cairo.h ml_cairo_status.h
+ml_cairo_path.o: ml_cairo_path.c ml_cairo_wrappers.h ml_cairo.h \
+  ml_cairo_status.h
+ml_cairo_status.o: ml_cairo_status.c ml_cairo.h ml_cairo_status.h
+ml_cairo_wrappers.o: ml_cairo_wrappers.c ml_cairo_wrappers.h




More information about the cairo-commit mailing list