Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


how to use a font ( portable ) ???

This topic is 5545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I am building a GUI system just now in openGL, and something that is really important for my app is that a lot of text is going to be displayed / manipulated. There will be a complex 3D model in the center representing data, and smaller windows surrounding it for data manipulation. I also don''t want to get tied down to windows or anything, I''m developing everything myself. OK, but now I''m not sure how to proceed for my font resource. The TTF spec from microsoft looks really scary, but I do want to be using fonts that already exist for now. I presume that the TTF format itself is ok to use, just like MD2? ie. Microsoft don''t ''own'' it? And is TTF the right way to go? I''d like to know how you guys deal with text in this situation. I don''t need much, just upper and lower case, and only a few fonts. Bold and italics would be useful. But again, I don''t want windows to be loading it for me etc, I need portability. Thanks in advance for any help here.

Share this post

Link to post
Share on other sites
If I were to write something like this, I'd use whatever platform specific API was avialable, and #ifdef to decide which one to compile. Write a class for each platform that exposes the same functions - "link-time polymorphism" as it's called.

I have a threading API like this:
//The header is the same for all platforms,
struct Thread
//and then a different implementation for each platform
#ifdef _MSC_VER
//Win32 Code
#elif __linux__
//linux pthread code
#elif __QNX__
//QNX pthread code

[edited by - Magmai Kai Holmlor on August 18, 2003 10:18:11 PM]

Share this post

Link to post
Share on other sites
thanks there, good idea. I like the name Link-time-polymorphism

Has anyone here done a TTF loader before? I''m not asking for code, I''m just checking I''ve got the right idea to write my own one. And besides the MSoft spec, are there any other resources about this anyone knows about? I have been * ahem * using teh goOogle!1!!1 * ahem * for a couple of hours now, with little luck.

Share this post

Link to post
Share on other sites
bitmap fonts is one way. store all the fonts you need in one or two textures. load them, and then proceed to divide up the texture into each character

Share this post

Link to post
Share on other sites
There are font libraries like freetype2 that are platform independent font rasterization systems that you can use to create the pixels for each glyph in the font. On Windows you can use GetGlyphOutline(), in Freetype2 you can use FT_Load_Char() plus associated functions.

You should check out the FTGL library which is a (not light-weight) wrapper for using freetype2 with OpenGL.

You can read about legal/patent issues on the freetype website:


I'm not sure about the legal situation. MS liscensed the rights to the TTF hinting system from Apple and then improved it and called it something else (I forget what). Freetype2 has a build in hinting system that you cannot legally enable in the USA.

I wrote my own font system that uses Windows and Freetype2. I would have liked to have stuck to just FT2, but Windows GetGlyphOutline() fonts look better than FT2 fonts (with hinting disabled) at small sizes (6-13ish pixels high).

Edit - If you application is pretty text intensive and you are rendering the text every frame rather than buffering it, you will want to use VBOs or cached strings to render the text rather than using immediate mode. Here is a good thread with lots of text rendering wisdom in it from people who have designed text rendering systems / libraries:


[edited by - Z01 on August 19, 2003 1:51:22 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!