PDA

View Full Version : An easy and portable FreeType font library?



neo187
11-21-2011, 06:41 AM
Hi all

I am a beginner to OpenGL, for this school project I am working on I'd like to be able to draw text using FreeFonts.... I checked Nehe's tutorial as well as some other libraries he recommends like the FreeType project or OGLFT but they all seem to require installation of different components on the machine before being able to be used in the project. I need to keep my project completely independed, it comes with its own copies of all the GL files and libs, because the project needs to be compiled and run on a virgin machine by the professor...

Having said this, is there any library that can just be linked to the project and packed with it, that allows to read and draw a .tff font, also packed in the project? Worst comes to worst I could even use Nehe's Bitmap Fonts (http://nehe.gamedev.net/tutorial/bitmap_fonts/17002/) technique but it seems like it relies on a Font inside the Windows system files.... I could definitely go for a Bitmap Font reader as long as I can read it from the project's directory....

Thank you for your help!

tksuoran
11-21-2011, 07:06 AM
http://code.google.com/p/freetype-gl/

Edit: And then there is also http://nothings.org/stb/stb_truetype.h

neo187
11-21-2011, 07:44 AM
Thank you. I can't seem to find anywhere to download the first one... the second one seems quite nice and compact... would you have a rough usage example?

tksuoran
11-21-2011, 08:58 AM
To download freetype-gl, you could get some Subversion client and follow instructions on http://code.google.com/p/freetype-gl/source/checkout

For stb_truetype.h, read the source. It has couple of simple examples in it, although GL parts are minimal. Search for my_stbtt_initfont, my_stbtt_print, and "Complete program".