freetype

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

Moderators: cheriff, TyRaNiD

Post Reply
Alberto
Posts: 51
Joined: Mon Feb 12, 2007 8:16 pm
Location: Sofia

freetype

Post by Alberto »

Hi guys,

I would like to have a look at this library for a project I am currently on, but I see it's not that easy... :-(

Could ayone point me to some tutorial and/or code snippet just to start out with something? Like just rendering a word on the PSP screen using a TTF (or similar) font.

TIA
A.
BenHur
Posts: 28
Joined: Sat Oct 20, 2007 5:26 pm

Post by BenHur »

Why not use an existing and proven solution:
pgeFont by InsertWittyName does it nicely and you don't have to worry about the details (get it e.g. from here). The source code is included, so you could also learn from that.

BTW: If you want to display text using the PSP's internal fonts use intraFont.

Cheers, BenHur
carl0sgs
Posts: 33
Joined: Thu Dec 10, 2009 3:51 am
Contact:

Post by carl0sgs »

Hi alberto

using freetype lib is really easy to use with a lib called "fontloader"
but freetype is really slow
the fastest is intrafont (psp's internal fonts), wich is also easy to use

sample fontloader use:

Code: Select all

        initGraphics();



        // Create a (graphics lib) image 'myImage', 250x100

        Image* myImage = createImage(250, 100);

        

        // Load a font

        Font* myFont = Font_Load("REN_STIM.TTF");



	// Set the size of 'myFont' to 60 (pixels)

        Font_SetSize(myFont, 60);

        

        // Print "1st Font" to 'myImage' using 'myFont' at x = 0, y = 50, colored red

        Font_Print_Image(myFont, 0, 50, "1st Font", GU_RGBA(255, 0, 0, 50), myImage);
regards,
carlos
Alberto
Posts: 51
Joined: Mon Feb 12, 2007 8:16 pm
Location: Sofia

Post by Alberto »

Hi.

Thanks both to BenHur and Carl0sgs. I'll try both solutions, but will probably go for the intrafont one.

I just definitely need to use a TTF font, so if intrafont allows me to, I'll go for it.

Be prepared to further questions...

actually, I do everything with a framebuffer graphic library I made (don't ask why: GU and GE look still very obscure to me...). Since it works pretty good for my needs, I'll keep on using it.
The thing is I need to know some includes to be specified, and eventually the libs to be linked, as per the example of carl0sgs...
can you shed some light on this, please?

Thank you again for the suggestions.

Cheers, A.
Alberto
Posts: 51
Joined: Mon Feb 12, 2007 8:16 pm
Location: Sofia

freetype

Post by Alberto »

ok guys,

thanks for the tips. I took a look at the pgefont library, and was able to find out what I needed to get started: load library, load face, load 255 glyphs...

Now, I have some questions:

1. is it true that I have to instantiate a face for every size I need, and then have all the glyphs "rendered" before I can use them? (looks kinda yesss, then it's goddamn sloooow)
It takes roughly 2 seconds for each face/size with -O3 optimizations turned on; and I need normal/bold/italic/bold-italic at once... that makes 8 seconds... (all I get is a "bitmap" with something I took for an alpha-map (u8's) of the pixels to be rendered; or at least assuming this works very good for me).
Ok, this happens once at the program start, but there might be situations where I won't know all the fonts/sizes needed

2. is there any option to have the gluphs rendered with no anti-aliasing (like in Winsoz "smooth characters on screen" unchecked). Maybe this will a) speed things up a bit, and 2) make font more readable, especially at low sizes (8 or 10 points)

Thanks for any hints ;-)

P.S.
I wasn't able to look at the intrafont thing... can you post a link or somethinf for the wrapper lib? Thanks.

Cheers, A.
BenHur
Posts: 28
Joined: Sat Oct 20, 2007 5:26 pm

Re: freetype

Post by BenHur »

Alberto wrote:I wasn't able to look at the intrafont thing... can you post a link or somethinf for the wrapper lib?
The intraFont archive (link provided above) contains 2 samples - just study them.
(Hint: intraFont uses a lot of stuff from pgeFont and its usage is very similar. And remember: intraFont does NOT render truetype fonts, but the PSPs internal *.pgf fonts, which you get to see in the XMB, dialogs, etc.)

Cheers, BenHur
Alberto
Posts: 51
Joined: Mon Feb 12, 2007 8:16 pm
Location: Sofia

Re: freetype

Post by Alberto »

Ben,
BenHur wrote:And remember: intraFont does NOT render truetype fonts, but the PSPs internal *.pgf fonts, which you get to see in the XMB, dialogs, etc.)
uh... sorry, I didn't read carefully... thought that the fontloader thing referred to the intrafont stuff. So, I think I found everything out and nothing faster exists... :-(

Thanks anyway for your help.

Cheers, A.
Post Reply