 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Alberto
Joined: 12 Feb 2007 Posts: 57 Location: Sofia
|
Posted: Thu Feb 04, 2010 5:22 am Post subject: freetype |
|
|
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. |
|
| Back to top |
|
 |
BenHur
Joined: 20 Oct 2007 Posts: 30
|
Posted: Fri Feb 05, 2010 12:42 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
carl0sgs
Joined: 10 Dec 2009 Posts: 41
|
Posted: Fri Feb 05, 2010 2:17 am Post subject: |
|
|
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: | 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 |
|
| Back to top |
|
 |
Alberto
Joined: 12 Feb 2007 Posts: 57 Location: Sofia
|
Posted: Fri Feb 05, 2010 4:09 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Alberto
Joined: 12 Feb 2007 Posts: 57 Location: Sofia
|
Posted: Tue Feb 09, 2010 5:37 am Post subject: freetype |
|
|
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. |
|
| Back to top |
|
 |
BenHur
Joined: 20 Oct 2007 Posts: 30
|
Posted: Tue Feb 09, 2010 6:54 am Post subject: Re: freetype |
|
|
| 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 |
|
| Back to top |
|
 |
Alberto
Joined: 12 Feb 2007 Posts: 57 Location: Sofia
|
Posted: Tue Feb 09, 2010 7:31 am Post subject: Re: freetype |
|
|
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. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|