gtk2, cairo, pango

"Hendrik Boom [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
I'm now working on converting some Pango demo code from C to ocaml.

I managed to get ocaml to find pango.  It seems to reside in lablgtk2, 
and the order of parameters on the command line seems to be crucial.

This worked:
    ocamlfind ocamlopt -o ow ow.ml -package lablgtk2,cairo2 -linkpkg
This didn't:
    ocamlfind ocamlopt -o ow -package lablgtk2,cairo2 -linkpkg  ow.ml

Now I have a new problem:

ocamlfind ocamlopt -o ow ow.ml -package lablgtk2,cairo2 -linkpkg
File "ow.ml", line 27, characters 48-50:
Error: This expression has type Cairo.context
       but an expression was expected of type
         Pango.context = [ `pangocontext ] Gobject.obj
Makefile:5: recipe for target 'ow' failed
make: *** [ow] Error 2

It appears that in ocaml, a Cairo.context cannot be used as a 
Pango.context.  THey have different types.
But in the C code, both (of course) hae the same type, Gobject.
After all, gtk's object system erases all tpe distinctions (which makes 
gtk hard to use in C, its native language).

But in the C code, it appears that the same pointer can be used for 
*both* Cairo.context and Pango.context.  There's never a need to obtain 
one from the other.  Evidently, Pango can work with Cairo's contect 
object.

OCaml makes this impossible.  Is there a way to obtain one from the 
other?  The does appear to be a way of obtaining a Pango context from 
gtk, but I do sometimes wannt to use Cairo outside of gtk (such as to 
produce a pdf.)

The only mention I could find of Pango in the Cairo source is a 
comment that I should be using it instead of cairo's toy text tool.

-- hendrik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.