Oh, and I should say the function I want to implement is

getFontBBox :: Font -> String -> IO [Float]

I do know how to marhsal/unmarshal the String.  Just not the CFloat array to Haskell [Float]

On Fri, Jun 20, 2008 at 2:25 PM, Jefferson Heard <jefferson.r.heard@gmail.com> wrote:
Well, Achim you were almost exactly correct.  I have a functional function interface in about half an hour's worth of work.  I have one question, which is how to create a Ptr to four CFloats on the fly, pass them to the bounding box functions, and then come back out with a [Float]

My prototype looks like this:
foreign import ccall unsafe "ftglGetFontBBox" fgetFontBBox :: Font -> CString -> Ptr CFloat -> IO ()

the ptr to cfloat should be a float[4], which is modified inside the original C function.


On Fri, Jun 20, 2008 at 1:16 AM, Achim Schneider <barsoap@web.de> wrote:
"Jefferson Heard" <jefferson.r.heard@gmail.com> wrote:

> I've been looking for awhile now for a simple way to get truetype
> fonts into my visualizations so I can abandon the hideous GLUT fonts
> and make things that look like they were developed in the 1990s
> instead of back in the days of TRON.  I found FTGL, but I'm mostly a
> Haskell developer these days, and resent having to go back to C just
> to write a simple application.
>
> So I was wondering if anyone had ever wrapped the FTGL library in
> Haskel FFI or whether those out there who are experts on the FFI
> think at first glance it should be readily wrappable by a rank
> amateur at FFI such as myself.
>
> http://ftgl.sourceforge.net/docs/html/
>
Using the FFI is generally straight forward, as long as you can live
with using the IO monad and the C code uses objects (well,
pointers to structs passed as first argument, where's the
difference...).

Things only depend on the purity of the C code and how high-level you
want your interface to be. In this case, I estimate half an hour if
you're a fast typist. That includes the time needed to read the FFI
docs.

--
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



--
I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow.

-- Jessica Edwards



--
I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow.

-- Jessica Edwards