Help putting in fonts

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

Moderators: cheriff, TyRaNiD

Post Reply
skinticket
Posts: 2
Joined: Wed Mar 22, 2006 10:56 am

Help putting in fonts

Post by skinticket »

well, to tell you the truth, i have no idea how to do that, but i really want to add it in for a program i am making. Can anyone help me with adding fonts in and how to do it? preferably a pixel font. THanks a lot
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

McZonk has added a new font sample not too long ago
update your pspsdk and study the sample under dir

pspsdk/src/samples/gu/text

its pretty self explanatory and you can swap
the included font with your own
the sample shows simple ways to display your font,
change the color of font, change block width of font,
change opacity of font (transparency/alpha if its unclear)
even add a nice little drop shadow :)

enjoy
10011011 00101010 11010111 10001001 10111010
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

The text sample in sdk is pretty nice for a basic pixel font output. I worked on a bitmap font engine myself for PMPMod and my first attempt was pretty much like the sample, but it has a huge dropdown on performance if you make more use of the font than just to display some fps stats or alike.
That's because for every frame, every single char has to be blitted as textured quad. Say you have a string that is made up of 300 chars, then you'll make the GU render 300 alphablended, textured quads every frame, which is already as much precessing as a simple 3D Object would use (In my case, I also wanted to draw a border around the font and therefore first tried to draw the string 8 times around the original string in black, which would end up drawing 9*300 = 2700 quads every frame - unbareable, esp for the speed critical PMPMod).
So I gathered some information on more efficient ways of font-rendering, and after freetype was out of the question for the overkill-complexity, I tried to write a caching-system for the strings, based on how freetype and alike render their glyphs.
It's basically not more than just drawing your text to a offscren texture, saving the rendered string to a buffer and then just render one quad with the offscreen texture every time the string in the buffer is to be drawn.
Well, it's little bit more complicated if you want to minimize on memory usage (by using 4bit textures for the font like me), because then no rendertotexture will work. But I finally managed to get it working and it's pretty fast now, yet the source is very uncleaned. However, I also have a little Windows Tool for converting TTF fonts to my format (a header with a 256x256x4bit texture following).

I'll release the sources when I release the next version of PMPMod with subtitle support.
It's pretty easy to use and you'll just need to use my valloc routines for allocating frame and drawbuffers for the cache to work correctly then.
skinticket
Posts: 2
Joined: Wed Mar 22, 2006 10:56 am

Post by skinticket »

Edit: Ok nvm i got it, now what is a RAW font. i thought it was with .png and now its .raw?
TheMan
Posts: 10
Joined: Tue Jan 03, 2006 9:29 am

Post by TheMan »

skinticket wrote:Edit: Ok nvm i got it, now what is a RAW font. i thought it was with .png and now its .raw?
i was having the same problem. im not sure what a .raw file is, could anyone explain it to me? is it like an image? also, anyone know some good code that would allow simple png fonts to be used?
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

.raw means RAW data, that is, not a predefined format. It can for example contain the image data without any header, but it can also contain more things.
Maybe the format he's using for images is documented, else you'll have to look at the source to find it ;-)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Post Reply