I have only been using OF for 3 weeks now, and I love it. The only thing that is missing (in my opinion), is good text support. OF can render left-aligned text, but at smaller font sizes the kerning is of low quality. I would love to be able to render good quality, line-wrapped text to a pixmap and then treat it as any other ofImage.
I have been trying for 2 days to figure out how to do it, but my knowledge of OpenGL and OF is too limited to get anything going. So I turned to the internet and found the FTGL library. It seems to be able to do much of what I want and it would be great to write a class that extends ofImage and can draw my text.
Has anyone of you ever tried adding it to an OF project? If so, could you tell me how you did that? At the moment I run into basic stuff like getting it compiled under GNU GCC in Code::Blocks.
I would appreciate any help or thoughts on FTGL or rendering formatted text to textures.
Have you been able to integrate FTGL yet? I was about to look into the possiblity of doing this myself.
no, I have not been able to, due to lack of knowledge. I have been trying to get QuesoGLC working instead. I got as far as compiling it, adding it to my project and calling it, but it keeps complaining about ‘fontconfig cannot load default config file’, which must be a setup issue that I have so far not been able to resolve.
I got quite fed up with it and decided to drop it for now, until QuesoGLC v0.8 ships without the bloody fontconfig code. I also came across this-page with a working demo written in the D-language (first time I heard about it), which should not be that hard to translate to C++. But I am scared to do it, hehe.
Finally, this-page contains awesome stuff on font rendering in general, but I think the code will be hard to implement in OpenGL, and probably too slow.
Improved text rendering would be a very welcome addition to OpenFrameworks. Too bad I am not experienced enough to add it myself at the moment. But I am learning every day.
I’ve been looking for some nicer text for a project I’m working on and had a look into FTGL (thanks for the tip:-). I have it working on Windows and Mac (I haven’t tried it in Linux yet). Let me know which platform you are on and I can post some code/instructions on how to link to the headers and where to put the library/dll.
great work! I would love to try out your code. I am using the Code::Blocks compiler (for Windows obviously) and have access to an Apple with X-code. Any information on how to get things rolling would be much appreciated.
I myself have succeeded in compiling another library, called QuesoGLC, under Code::Blocks, but ran into problems with the fontconfig library. I decided to wait for an QuesoGLC release that does not use fontconfig. But I’d prefer using FTGL.
Sorry for the delay in putting this up. I tried out QuesoGLC too (on mac only) - fontconfig was quite easy to compile in OSX - not sure about PC. Conversely FTGL was easier on PC than Mac (lot’s of the headers in OSX needed mucking around with, as the #defines were not working correctly - on PC they worked fine).
I’m kind of new to all this myself, so it’s been a lot of guesswork and it’s certainly not at an ‘addon’ stage - just the library working and accessible via oF
There are two downloads:
FTGLExampleXP.zip (is a conversion of an FTGLDemo application to oF)
FTGL.zip (headers and compiled FTGL library)
You’ll need to put the FTGL folder (with headers and library) into your libs folder (on my setup this is: of_preRelease_v0.06_win32_cb_FAT/libs).
I compiled FTGL as a DLL (you’ll find it in the bin folder of FTGLExampleXP)…
Let me know how you go.
and for mac:
FTGLExampleOSX.zip (is a conversion of an FTGLDemo application to oF)
FTGL.zip (hacked(!) headers and compiled FTGL library)
Awesome stuff, Matt, it worked!
I can compile it into my project now and have been able to render text to a layout with justified text. Kerning is much better than OF’s own classes. It still uses 1 ‘pre-rendered texture’ per glyph, I think, because all t’s and i’ look the same throughout. Text rendering isn’t optimal, but still I am quite happy with it.
Thanks a lot for the hard work, I hope others will be able to use FTGL now, too.
could you post a screenshot of your work?
i am not completely happy with the rendering quality of oFs internal font-renderer and it would be interesting to see how significant the improvements with flgt are.
On the left you can see FTGL rendered text (left aligned using DinPro Regular font at 18px). On the right the ofxTrueTypeFont version, using my own class for text wrapping.
Note how the lowercase ‘q’ and ‘p’ align much better in the FTGL version. Text looks sharper, too. Hinting seems better, too. Look at the lowercase ‘s’ for example. And it has UTF8 support.
PS: sorry for the big image, but you need it to be able to make a comparison. Oh, and here is another one, using a smaller fontsize (12) and a bolder version of the DinPro.
this. looks. great!
many thanks to you and to gameover for making it work!
Does anyone suffer an LNK error like this? :
Error 52 error LNK2019: unresolved external symbol “__declspec(dllimport) public: __thiscall FTPolygonFont::FTPolygonFont(char const *)” (__imp_??0FTPolygonFont@@QAE@PBD@Z) referenced in function “public: virtual void __thiscall testApp::setup(void)” (?setup@testApp@@UAEXXZ) testApp.obj fontsExample
I copied the FTGL folder including headers and dll to libs/ folder. Then, I edit the additional include directory in project setting (VS2008). Finally, copy the dll file to my bin folder. but it does not make it.
- I tried to change project setting => c/++ => Language / Treat the wchar … to “No (/Zc:wchar_t-)”. but it did not work.
Hi, as I needed some advanced text rendering my self I’m working on a addon which integrates pango into openFrameworks:
See this post as well:
Quite an impressive feat to get Pango up and running, Roxlu. If only I had enough experience to do the same Guess I have to rely on guys like you for the foreseeable future. Keep up the good work.
Great work on this, I needed a little bit more control than what’s available using ofTrueTypeFont, and FTGL is exactly what I needed.
I compiled a version of the lib for Visual C++. youminkim, I think using this might solve your issue as gameover’s version looks like it’s for Code::Blocks.
Hey great to see this being used! @youminkim: apologies for not seeing your question - for some reason I don’t seem to be getting notifications for quite a few of my posts (???) and thanks to you, elie for compiling in VS2008. Look forward to checking out Pango too…