<div dir="ltr">I've also used a little bitmap font rendering for my tetris clone. It's very simple and I *think* that the process for using freetype is pretty similar:<div><br></div><div>1. Render all glyphs of the font into a texture.</div>
<div>2. Draw 2D shapes using the texture.</div><div><br></div><div><a href="https://github.com/schell/blocks/blob/master/src/Graphics/TextRenderer.hs#L90">https://github.com/schell/blocks/blob/master/src/Graphics/TextRenderer.hs#L90</a><br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 13, 2013 at 1:01 AM, Tim C. Schroeder <span dir="ltr"><<a href="mailto:tim@blitzcode.net" target="_blank">tim@blitzcode.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'd agree, use GLFW-b. I'm very happy with it!<br>
<br>
As far as the font rendering is concerned, if all you need is a basic bitmap font to get some text on the screen, you might be able to use some code I wrote as a self-contained, drop-in replacement:<br>
<br>
<a href="https://github.com/blitzcode/haskell-gol/blob/master/parallel-glfwb/src/Font.hs" target="_blank">https://github.com/blitzcode/haskell-gol/blob/master/parallel-glfwb/src/Font.hs</a><br>
<br>
(Looking at that code now, might want to bracket inside of withFontTexture. That code was written before Simon Marlow's book taught me about the wonders of Haskell exception handling...)<br>
<br>
I also wrote a Haskell FT2 binding. It's a very nice library with a decent API and few dependencies, so that was quite doable. The problem is that FT2 is really 'just' a glyph rasterizer. All other functionality is either rudimentary (kerning, glyph mapping) or out of the scope of the library (ligatures, glyph substitution, OpenType text layout in general). You'll need another library on top / besides it to get text rendering quality like in native GUI toolkits or a web browser. Obvious choices would be Pango or HarfBuzz, but those are more complicated to write a Haskell binding for (dependencies, C++, etc.).<br>

<br>
A 'just works' solution for platform and giant-GUI-toolkit independent, high-quality text rendering is sorely missing from the Haskell ecosystem, as far as I can tell. Doing an FT2 binding and the OpenGL glyph caching / texture atlas generation etc. is fine, but I'm afraid getting something like HarfBuzz/Pango up and running exceeds my Cabal-fu, for now.<br>

<br>
Cheers,<br>
Tim<br>
<div class="HOEnZb"><div class="h5"><br>
On Dec 12, 2013, at 11:49 PM, Jason Dagit wrote:<br>
<br>
> I started using it after making the following comparison several years ago: <a href="http://blog.codersbase.com/posts/2011-03-17-picking-gui-library.html" target="_blank">http://blog.codersbase.com/posts/2011-03-17-picking-gui-library.html</a><br>

><br>
> Maybe that analysis is useful to you as well? Just so you know, it's probably out of date by now, so you might want to double check some of my claims. For example, the C library for GLFW doesn't use atexit() anymore (which is a good thing).<br>

><br>
> Getting back to your question: As I recall, it's better maintained, lighter weight, and it has better dependencies. With GLFW-b you can use either OpenGL or OpenGLRaw, whereas GLFW depends directly on OpenGL. The main drawback, for me, is that GLFW-b doesn't support fonts.<br>

><br>
> My proposed solution to that was to make a binding to the freetype2 library (you can find my binding on hackage/github). I never really finished that project. The binding should work but it's very low level. A few people have sent me example code they wrote to use it with OpenGL. It's really something I should finish :) The other cool thing about using freetype for fonts is that you can easily make it part of a rendering system that doesn't use any OS rendering libraries (eg., add font support to a ray-tracer).<br>

><br>
> Jason<br>
><br>
><br>
> On Thu, Dec 12, 2013 at 1:45 PM, Vlad Lopatin <<a href="mailto:madjestic13@gmail.com">madjestic13@gmail.com</a>> wrote:<br>
> Thanks, Jason<br>
><br>
> What makes you prefer GLFW-b instead GLFW?<br>
><br>
><br>
> On 12 December 2013 19:15, Jason Dagit <<a href="mailto:dagitj@gmail.com">dagitj@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Thu, Dec 12, 2013 at 3:05 AM, Sven Panne <<a href="mailto:svenpanne@gmail.com">svenpanne@gmail.com</a>> wrote:<br>
> 2013/12/12 Vlad Lopatin <<a href="mailto:madjestic13@gmail.com">madjestic13@gmail.com</a>>:<br>
> > I keep reading (wiki) that GLUT is a legacy package and some libraries (e.g.<br>
> > GLFW) are meant to replace it.  I also see that some of the GLUT<br>
> > functionality is based on fixed pipeline.  What is the current status of<br>
> > Haskell GLUT?  Is it 'to stay' or something that is going to be deprecated<br>
> > at some point?  Should one try replacing it with GLFW(-b) in a project, if<br>
> > fixed pipeline is not expected to be used?<br>
><br>
> I think this really depends on your needs: GLUT was designed as a<br>
> simple cross-platform API for OpenGL demos and tutorials, perhaps even<br>
> some programs of medium complexity.<br>
><br>
> I prefer GLFW-b for cross platform programs for the simple reason that on windows GLUT requires you to install a DLL and make sure it's in the path.<br>
><br>
> I prefer GLFW-b more generally because it's more modern, fully open source, and under active development. The license for GLUT is open in practice but it's not a clean open source license. I guess most people use freeglut instead.<br>

><br>
> Jason<br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Schell Scivally<br><a href="http://blog.efnx.com" target="_blank">http://blog.efnx.com</a><br><a href="http://github.com/schell" target="_blank">http://github.com/schell</a><br>
<a href="http://twitter.com/schellsan" target="_blank">http://twitter.com/schellsan</a>
</div>