PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

iPhone - Loading fonts

Hi! I've found out that there's a font in my game that doesn't display correctly on iPhone (although it is rendered fine in PC using OpenGL).

I'm attaching two images with the output of the PC version and the iPhone's simulator (the latter reproduces the exact same output I'm getting on my iPod Touch). I'm also attaching the font file used.

Notice that I'm using another font file during the game (which I'm also attaching to this post) and it's working fine, so maybe there's a missing flag or something?

Thanks in advance for your reply,

--Nacho
Attachments:
iPhone-Font.rar (622 KB)
iPhone-CorrectFont.rar (6 KB)
Hi Nacho,

The white squares are drawn when no texture is bound, or texturing is disabled (thus rendering colored quads). Use ClassEDisplay :: SetShading with E3D_TEXTURE to fix it.
Hi edge,

Thanks for your reply. I placed a call to ClassEDisplay::SetShading right before loading the texture, but the problem persists. I'm sure I'm missing a flag or something for the iPhone version since, as I've said in the original post, the PC version that makes use of OpenGL displays the font correctly.

--Nacho

Update: I'm uploading an Xcode project that shows my current situation by printing the string "HELLO WORLD!". If you compile it right away, it will output garbage (notice that it uses the same troublesome font from my project).

Now, if you replace the string "Fuente.png" by "Fuente2.png" (Fuente2.png is the font I'm using during my game loop, which works fine) on line 109 you'll get a correctly displayed string.
Attachments:
FontTest.zip (96 KB)
Hi Nacho,

When your font doesn't work, try to display the entire font on the screen with BltFast. See if you can find any errors.

Another thing you can try is to padd the font image with extra pixels (on the right side), so the width is divisible by 2 or 4.
Hi edge,

I've resized the image in order to make its width divisible by 2. I've also tried to blit the image but I'm getting a big white rectangle, is it possible that there might be an issue with the png loader?

Thanks for your support.

--Nacho
Hi Nacho,

The font may not load because the texture size is too big for OpenGL ES.

We recommend making a multiline font image, just like font_outline_multirow.png delivered in the media folder of the SDK. Before BuildFont you also need to call SetFontSheetLayout and specify the number of rows you've created in the image.
Hi edge,

Thanks for your reply. The multiline image did the trick, so everything's working fine now :)

Once again, thanks for your support,

--Nacho