Rendering TTF fonts in Haskell and OpenGL

In C and in Java, I can use truetype fonts in Haskell using select libraries, and I'd like to be able to do the same in Haskell. Are there any portable libraries out there for loading fonts into OpenGL geometry for Haskell? I can use the vector fonts from GLUT is absolutely neccessary, but I'd like something that looks a little more professional. Are there any suggestions? -- Jeff -- 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

On Feb 17, 2008, at 19:13 , Jefferson Heard wrote:
In C and in Java, I can use truetype fonts in Haskell using select libraries, and I'd like to be able to do the same in Haskell. Are there any portable libraries out there for loading fonts into OpenGL geometry for Haskell? I can use the vector fonts from GLUT is absolutely neccessary, but I'd like something that looks a little more professional. Are there any suggestions?
Can't speak to OpenGL per se, but have a look at: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-ttf-0.4.0 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/X11-xft-0.2 -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Feb 18, 2008 12:20 AM, Brandon S. Allbery KF8NH
On Feb 17, 2008, at 19:13 , Jefferson Heard wrote:
In C and in Java, I can use truetype fonts in Haskell using select libraries, and I'd like to be able to do the same in Haskell. Are there any portable libraries out there for loading fonts into OpenGL geometry for Haskell? I can use the vector fonts from GLUT is absolutely neccessary, but I'd like something that looks a little more professional. Are there any suggestions?
Can't speak to OpenGL per se, but have a look at: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-ttf-0.4.0 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/X11-xft-0.2
I have an immature, but precise and picky implementation that renders text in a ttf font to an OpenGL texture (using SDL-ttf) here: http://svn.luqui.org/svn/misc/luke/work/code/haskell/frp/Fregl/Draw.hs (It may have some dependencies in the same directory). Text support is way at the bottom. Good Luck, Luke

Thanks. that's certainly a thought... doesn't make the text 3d,
though, does it? I'd ideally like to have something that turns the
text into geometry, but this'll do in a pinch...
On Sun, Feb 17, 2008 at 8:26 PM, Luke Palmer
On Feb 18, 2008 12:20 AM, Brandon S. Allbery KF8NH
wrote: On Feb 17, 2008, at 19:13 , Jefferson Heard wrote:
In C and in Java, I can use truetype fonts in Haskell using select libraries, and I'd like to be able to do the same in Haskell. Are there any portable libraries out there for loading fonts into OpenGL geometry for Haskell? I can use the vector fonts from GLUT is absolutely neccessary, but I'd like something that looks a little more professional. Are there any suggestions?
Can't speak to OpenGL per se, but have a look at: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-ttf-0.4.0 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/X11-xft-0.2
I have an immature, but precise and picky implementation that renders text in a ttf font to an OpenGL texture (using SDL-ttf) here: http://svn.luqui.org/svn/misc/luke/work/code/haskell/frp/Fregl/Draw.hs (It may have some dependencies in the same directory). Text support is way at the bottom.
Good Luck,
Luke
-- 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

At Mon, 18 Feb 2008 01:26:17 +0000, Luke Palmer wrote:
I have an immature, but precise and picky implementation that renders text in a ttf font to an OpenGL texture (using SDL-ttf) here: http://svn.luqui.org/svn/misc/luke/work/code/haskell/frp/Fregl/Draw.hs (It may have some dependencies in the same directory). Text support is way at the bottom.
Along the same lines, I have an imcomplete, but direct binding to freetype and an incomplete binding to GLX which can be used to draw text to opengl textures: http://n-heptane.com/nhlab/repos/haskell-freetype/ http://n-heptane.com/nhlab/repos/haskell-glx/ This file contains an example of drawing text using GLX+FreeType: http://n-heptane.com/nhlab/repos/haskell-freetype/FreeTypeTest.hs This code has not been touched in a few years, so it probably needs some updates to work with ghc 6.8. Also, I believe the X11 package now has builtin support for ClientMessage, so that module can go away. j.

I also have made haskell bindings to FreeType, including support for
extracting glyph outlines.
I haven't had time to publish it yet. Hopefully I'll get around to it soon.
On Mon, Feb 18, 2008 at 5:07 AM, Jeremy Shaw
At Mon, 18 Feb 2008 01:26:17 +0000,
Luke Palmer wrote:
I have an immature, but precise and picky implementation that renders text in a ttf font to an OpenGL texture (using SDL-ttf) here: http://svn.luqui.org/svn/misc/luke/work/code/haskell/frp/Fregl/Draw.hs (It may have some dependencies in the same directory). Text support is way at the bottom.
Along the same lines, I have an imcomplete, but direct binding to freetype and an incomplete binding to GLX which can be used to draw text to opengl textures:
http://n-heptane.com/nhlab/repos/haskell-freetype/ http://n-heptane.com/nhlab/repos/haskell-glx/
This file contains an example of drawing text using GLX+FreeType:
http://n-heptane.com/nhlab/repos/haskell-freetype/FreeTypeTest.hs
This code has not been touched in a few years, so it probably needs some updates to work with ghc 6.8. Also, I believe the X11 package now has builtin support for ClientMessage, so that module can go away.
j.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[cc-ed to hopengl list; are there many haskell opengl users
not on that list, btw?]
a standard package for easy-to-use, high-quality, portable
font support would make a great addition to haskell's
otherwise nice opengl bindings!
is there a reason for going directly to freetype? from the
old opengl font survey at
http://www.opengl.org/resources/features/fontsurvey/
i got the impression that accessing freetype2 via ftgl
might make things slightly easier, while also offering
more options (geometry instead of texture fonts), or
did I misread?
http://ftgl.wiki.sourceforge.net/
the source doesn't seem to have changed since the
end of 2004, which might imply some issues with
newer compilers, etc?
has anyone tried to bind to ftgl? any comments on
that route?
and to what extent to the haskell gui libs with opengl
support allow their fonts to be used for text geometry
or textures in opengl?
claus
----- Original Message -----
From: "Bit Connor"
I also have made haskell bindings to FreeType, including support for extracting glyph outlines.
I haven't had time to publish it yet. Hopefully I'll get around to it soon.
On Mon, Feb 18, 2008 at 5:07 AM, Jeremy Shaw
wrote: At Mon, 18 Feb 2008 01:26:17 +0000,
Luke Palmer wrote:
I have an immature, but precise and picky implementation that renders text in a ttf font to an OpenGL texture (using SDL-ttf) here: http://svn.luqui.org/svn/misc/luke/work/code/haskell/frp/Fregl/Draw.hs (It may have some dependencies in the same directory). Text support is way at the bottom.
Along the same lines, I have an imcomplete, but direct binding to freetype and an incomplete binding to GLX which can be used to draw text to opengl textures:
http://n-heptane.com/nhlab/repos/haskell-freetype/ http://n-heptane.com/nhlab/repos/haskell-glx/
This file contains an example of drawing text using GLX+FreeType:
http://n-heptane.com/nhlab/repos/haskell-freetype/FreeTypeTest.hs
This code has not been touched in a few years, so it probably needs some updates to work with ghc 6.8. Also, I believe the X11 package now has builtin support for ClientMessage, so that module can go away.
j.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

At Fri, 22 Feb 2008 15:13:46 -0000, Claus Reinke wrote:
i got the impression that accessing freetype2 via ftgl might make things slightly easier, while also offering more options (geometry instead of texture fonts), or did I misread?
It appears to be written in C++, which makes it hard to bind to from Haskell. I did not see any C bindings for it (though, I probably did not look too hard). So, given the choice of writing a C binding for it so I could call it from Haskell, or just reimplementing it in Haskell, I opted for the latter -- and got neither done :) j.

bit:
I also have made haskell bindings to FreeType, including support for extracting glyph outlines.
I haven't had time to publish it yet. Hopefully I'll get around to it soon.
Do you need a place to host the repository? code.haskell.org is available if you want to host there. Just visit community.haskell.org and request an account. -- Don
participants (7)
-
Bit Connor
-
Brandon S. Allbery KF8NH
-
Claus Reinke
-
Don Stewart
-
Jefferson Heard
-
Jeremy Shaw
-
Luke Palmer