Low-level font rendering

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
uberjack
Posts: 34
Joined: Tue Jul 17, 2007 9:09 am
Location: California, USA
Contact:

Low-level font rendering

Post by uberjack »

Hi,

What's the best way to implement font rendering on PSP? I've seen programs write directly to uncached VRAM, as well as using swizzled textures. I personally prefer to use sceGuDrawArray(GU_POINTS), but I haven't seen anyone else do it this way.

If you've tested various different methods, it'd be great to get a pros/cons type of comparison. For example, I'm sure writing to VRAM directly is fast, but will it bring up uncached memory access issues, when mixed with other code?

Also, if textures are used, is it still possible to control the color of the font?

Thanks

P.S. I'm not really interested in existing libraries for font rendering, as I know there are several
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

in my personal experience the best way to do so is to load an "alphabet texture" and then render chars as textured sprites. You could even create a list for each char. So it will be faster if you swizzle your texture once loaded and for all. Oh and if you do so you can invalidate cache only at the end of the entire rendering process. A different story has to be told if you would like to render trueType...
PS: my chars are grayscale+alpha. ....try playing with sceGuColor and similar functions
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Right now, I like using the built-in fonts via intraFont. That works rather well.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

There are several options available, you'll have to decide on the best method to suit your own needs.

In my pgeFont implementation I load a TTF font and generate a 4-bit swizzled texture from that, which can be stored in either VRAM or RAM.

As jean mentioned, these are displayed by using a list for the characters and their position on the texture - after that they're just drawn using modulate, sceGuColor() to set the color and render as GU_SPRITES.

The benefits of this are that the memory footprint is small, only ~32kb for a 256x256 texture and that it is very very fast.

The downside is that the size of the font is set at load/creation. However because the memory footprint is so small you can always load the font multiple times at multiple sizes.

Hope this helps.
User avatar
uberjack
Posts: 34
Joined: Tue Jul 17, 2007 9:09 am
Location: California, USA
Contact:

Post by uberjack »

Thanks for the responses, everyone.
Sounds like swizzled textures present the best approach.
Post Reply