Under the Bridge

Code: OpenGL Bitmap Fonts

Today, we draw your attention to some work-in-progress code that could be of use if you’re interested in using fonts in your OpenGL ES application that aren’t available on the iPhone. It’s called OpenGL ES BitmapFont, intuitively enough, and is simple to use

// loading a font

m_pScoreFont = [BMFont alloc];
[m_pScoreFont loadFont:@"font.xml"];
[m_pScoreFont setTexture:[TextureManager loadTexture:@"font_00.png"]];
[m_pScoreFont setRotation:-90.0f];
[m_pScoreFont setScaling:0.005f];

// printing some text

[m_pScoreFont print:@"SCORE: 0" posX:0 posY:0.8f];

but getting the texture to load requires the use of the Windows Bitmap Font Generator application from AngelCode.com. Still, hey, it’s a start!
[UPDATE: Now links to the 0.2 release with no known issues!]

6
  • Pingback: Code: OpenGL Bitmap Fonts » iPhone Tricks

  • faisal

    create me a ship of titanic

  • http://ecloud.org Shawn Rutledge

    So where’s the code? The link doesn’t work.

  • http://www.alexcurylo.com/ Alex

    There you go Shawn, now links to the 0.2 release.

  • Pete DeLaurentis

    Hi Alex,

    Can you post a new link to your code? I’ve tried clicking on everything on this page, but most of the links go to random strange places. I’m using BMFont to generate my font textures, and this looks like a good fit.

    Thanks,
    Pete

  • http://www.alexcurylo.com Alex

    Hmmm, yes, it appears to have quite thoroughly disappeared now, at least at the moment — unfortunately, that actually wasn’t my code, and I didn’t think highly enough of it to keep any copies around apparently.

    You might try this FTGLES port,

    http://jlongster.com/blog/2010/02/08/fonts-ugh/

    … but seriously, at this point I’d really recommend going with whatever font support is built into cocos2d these days.