forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Font creation tool
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Tue Jul 12, 2005 4:45 am    Post subject: Font creation tool Reply with quote

I just got involved with PSP development, and I wrote a tool to create some subpixel anti-aliased fonts. I've got a rough UI that can generate bmps, pngs, or raw data in cpp files. Would this tool be useful for anyone? If so I'll clean it up and publish the source.
Back to top
View user's profile Send private message
apache37



Joined: 04 Jun 2004
Posts: 76

PostPosted: Tue Jul 12, 2005 7:15 am    Post subject: Reply with quote

ok I'm interested :p
Back to top
View user's profile Send private message
neofar



Joined: 21 Jan 2004
Posts: 47
Location: Spain

PostPosted: Tue Jul 12, 2005 7:52 am    Post subject: Reply with quote

Very very interesting, I'm waiting for you all my life!!!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ector



Joined: 12 May 2005
Posts: 195

PostPosted: Tue Jul 12, 2005 7:54 am    Post subject: Reply with quote

Yeah, that would go excellently with my PSP texture format converter that I released yesterday ( download is here: http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip ) to be able to draw fonts with hardware very quickly, especially if you can make your tool output entirely white pngs with the actual font shapes in the alpha channel, this enables drawing of antialiased text very quickly in any color on any background. My program supports generating palettes even on images with alpha channel, so the fonts could be stored with 4bpp and still look really good.
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Tue Jul 12, 2005 8:44 am    Post subject: Reply with quote

ector: How convenient that your program is also in .Net :-)

I can generate alpha masks, solid bitmaps, etc. What sort of format do you have for input in terms of alpha masks etc.? Currently, the code takes a font description, and outputs 256 seperate images, or a .cpp file in raw representation. I can modify my code so it can be interfaced/integrated with yours, sounds like your tool would be useful.

I'm not sure how well alpha channel would work with subpixel rendered fonts however... To do subpixel rendered fonts with bitmaps, I think you basically have to use a solid background (unless someone has a better idea). I could do alpha channels with normal antialiasing quite easily however.
Back to top
View user's profile Send private message
ector



Joined: 12 May 2005
Posts: 195

PostPosted: Tue Jul 12, 2005 11:53 am    Post subject: Reply with quote

Ah. Well for fast text rendering the common method is to stuff the entire alphabet into a single texture, ideally only containing an alpha channel. This way you can draw text super quickly by just drawing an array of textured quads. Of course when originally generating the font texture you also store a list of coordinates of where all the characters are.

My program will accept most common image formats, including .PNG which has alpha channel support so if you can write .PNG files with alpha, it's perfect. It could also easily be made to read any custom format you come up with.

No I'm not sure either how well this would go with subpixel fonts, but for regular antialiased fonts this is a really fast method that works on any background.
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Jul 14, 2005 7:15 am    Post subject: Reply with quote

I've got the font program working, so I'll post the source and bits when I get home from work. It currently outputs a single large texture as a png, with the characters arranged 16 by 16. It outputs an alpha channel if required, so it should allow you to draw antialiased fonts that look really nice.

What I'd like to do next is change the program so that the characters do not have to be a fixed size. I'd also have to output a file with tex coords, but this would allow variable sized fonts that would look really nice.

So i'd like to write a small library to draw text with these fonts. The basic idea is that it would provide a simple DrawText function, something akin to the Win32 DrawText. The programmer would provide the address of the font info (which would include tex coords and bitmap data), a rectangle to draw the text to, and flags describing alignment and such.

So I haven't looked at Gu all that much yet, but would a function like this also require some sort of info about the render state, or could it just call the appropriate Gu functions to add the font quads to the render list?
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Jul 14, 2005 11:08 am    Post subject: Reply with quote

Consider sfont instead of reinventing the wheel.
Back to top
View user's profile Send private message
MrSiir[S]



Joined: 14 Sep 2004
Posts: 32

PostPosted: Thu Jul 14, 2005 11:24 am    Post subject: Reply with quote

jimparis wrote:
Consider sfont instead of reinventing the wheel.
sfont is SDL based lib. I think that a text tool specifies for PSP this very well
_________________
Sorry for my poor english!
Back to top
View user's profile Send private message Send e-mail
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Jul 14, 2005 5:07 pm    Post subject: Reply with quote

sfont doesnt seem to do subpixel rendered fonts... That was the original reason for making the tool. Having the ability to make other types of fonts was a trivial extra feature...

And the code to draw the fonts will also be quite small...
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Jul 14, 2005 5:32 pm    Post subject: Reply with quote

If anyone is interested, here's the tool I wrote to create pngs from fonts.

http://tim.strafenet.com/files/font2png.zip
Back to top
View user's profile Send private message
neofar



Joined: 21 Jan 2004
Posts: 47
Location: Spain

PostPosted: Thu Jul 14, 2005 5:40 pm    Post subject: Reply with quote

umm... interesting your first beta preview release....
but >> http://www.lmnopc.com/bitmapfontbuilder/
you need more features if want to be the best
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Jul 14, 2005 5:45 pm    Post subject: Reply with quote

Nope, I have no intentions of having the best font tool around. I couldn't find any tool to easily create subpixel rendered fonts, and since it's only a few lines of code in C#, I wrote my own.

It's not a beta, preview, or anything... It's just a little tool I wrote that I thought I'd give to anyone who found it useful.
Back to top
View user's profile Send private message
neofar



Joined: 21 Jan 2004
Posts: 47
Location: Spain

PostPosted: Thu Jul 14, 2005 6:10 pm    Post subject: Reply with quote

If I select
Code:
antiAlias = subpixel
alpha = true


The bitmap is transparent... but antialiasing in fonts is calculated over then real background color (int my case black) ... this could be calculate over the alpha channel

One adiction... can you render a outlined font? ...... and more difficult.... cand you render a outlined font with a antialiasing border only in the outter side?

if you have this ..... and then add a GUI .... it's very probably to be the best tool .... in a few liners as you say
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Jul 14, 2005 6:31 pm    Post subject: Reply with quote

If I understand your comment correctly, I don't think using an alpha channel with subpixel antialias would work very well with a rasterized font.

Say you've got three subpixel rendered pixels at the right side of a font. You might have a black pixel, a red pixel, then a transparent pixel. The red pixel is partly transparent, with an alpha of 50%. When that gets blended onto a blue background, you end up changing the amount of red in the final pixel, which messes up the subpixel rendering.


As for an outlined font, I'm not sure what you mean.


I also just realized something I should probably change... what the alpha parameter actually does is makes the background transparent, which wasn't my original intention. The alpha channel is output in the final image regardless of the alpha setting...
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Thu Jul 14, 2005 6:33 pm    Post subject: Reply with quote

What about using the sceLibFont functions? Has anyone an idea how to use it and is it guaranteed to find the same font with the same character size on Flash in version 1.0, 1.5 and later?
Back to top
View user's profile Send private message
neofar



Joined: 21 Jan 2004
Posts: 47
Location: Spain

PostPosted: Thu Jul 14, 2005 7:09 pm    Post subject: Reply with quote



(a) Is the image when I select Alpha and antialias, as you can see the borders are merged tod the background color (black) instead the real bg color (alpha)

(b) outline font

(c) Outline with antialias... in the zoom image you can see a exagerated antialias effect, but only renderer in the outter side of the font
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ironbird



Joined: 02 Jul 2005
Posts: 6

PostPosted: Fri Jul 15, 2005 10:09 am    Post subject: What about 16bit Char Set(ex. Unicode)? Reply with quote

Your tool can manage 16bit char Set( Unicode, Chinese, japanese)??

Where is 16bit Font Tool for PSP?
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Sat Jul 16, 2005 2:15 am    Post subject: Reply with quote

I could make it support 16-bit charsets, but the problem is that you'd have to define what ranges it should generate characters for... since you wouldn't want 65k font glyphs.

If you tell me how you want it to work, I can add support for 16-bit charsets for you.
Back to top
View user's profile Send private message
ironbird



Joined: 02 Jul 2005
Posts: 6

PostPosted: Sun Jul 17, 2005 12:57 am    Post subject: Reply with quote

I think..

To selecting the bits range is more usefull, because some languages have other bit ranges.
And it is very possible for you to modify the tool.

I have one more favor..
Would you mind changing the output of the tool into "*.c"file(bitmap font) in order to be utilized at PSP programing like the well-known "Hellopsp".
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Sun Jul 17, 2005 5:54 am    Post subject: Reply with quote

Sure, I can make the tool output to a .c file. As for the 16-bit charsets... Could you give an example of how you would specify the subset of the charset? If you can give me an example, i'll modify the tool tonight and post a new version on my site tommorow.
Back to top
View user's profile Send private message
ironbird



Joined: 02 Jul 2005
Posts: 6

PostPosted: Mon Jul 18, 2005 9:49 pm    Post subject: Reply with quote

I had run the tool that you made. It was very gool tool for just english user.

At your tool, the options for png generation are saved in "font.ini", isn't it?

I hope 2 more options in the file.
One is that user chooses output file type, specially "*.c" file with array variable.

The other is more important for me.. :)
Bits range appointment. I hope.... Not only Ascii code but also Unicode font coulde be used. So, if bit range are specified (for examples 0xA100 0xCFFF), the tool could make the output file for a Unicode font, Japanese font and so on. :-)

Good luck to you and me. ~~
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Tue Jul 19, 2005 2:21 am    Post subject: Reply with quote

I'll add unicode support and put a new version up later today
Back to top
View user's profile Send private message
Snatcher



Joined: 19 Jul 2005
Posts: 9

PostPosted: Thu Jul 21, 2005 1:59 am    Post subject: Reply with quote

Any news? I'd be highly interested in the Unicode/SJIS support, and C output parts...

Thanks for your work.
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Jul 21, 2005 6:02 am    Post subject: Reply with quote

As an update, I still plan to add unicode and C output to the font program. (C output was actually originally in the program but I took it out since I figured people would prefer to use libpng or something). I haven't had time yet since i've been working something like 14 hrs a day the past few days at my real job, and my roommate stole my video card :-)

I'll add unicode in the next day or so when I get the time.

For unicode, currently the plan is to add three parameters to the ini:

Columns=integer

[Unicode]
CharsetStart=hexnum
CharsetEnd=hexnum

I'm not sure if I need to add any other parameters for character encoding information, but I'll figure it out as soon as I look at the unicode support in .Net. Since it will no longer be an even 16x16, the columns parameter lets you control whether the fonts are arranged in a single column or if you have some sort of square configuration (which might be useful if you were using libpng and using some texture mapping I'd think)

If anyone has any other suggestions on features/parameters for font generation, let me know.
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Fri Jul 22, 2005 5:12 pm    Post subject: Reply with quote

I added unicode support. Let me know how it works for you, or if you have any trouble.

http://tim.strafenet.com/files/font2png.zip
Back to top
View user's profile Send private message
Snatcher



Joined: 19 Jul 2005
Posts: 9

PostPosted: Sat Jul 23, 2005 1:57 am    Post subject: Reply with quote

Thanks man!

I'll test it out immediately, and tell you when get results.
Back to top
View user's profile Send private message
Snatcher



Joined: 19 Jul 2005
Posts: 9

PostPosted: Sat Jul 23, 2005 2:54 am    Post subject: Reply with quote

I works really well, but now I have to figure out all the infrastucture to use it.. and what ranges I will be needing. I've been using so far a C array with my japanese fnt, but it has proved to be way too small for my application.

Thanks, I'll keep on reading and testing.
Back to top
View user's profile Send private message
Tim



Joined: 12 Jul 2005
Posts: 38

PostPosted: Sat Jul 23, 2005 7:35 am    Post subject: Reply with quote

Oh yeah, I was going to add C array support, but I forgot. Is that a useful feature to anyone, or is it just easier to use one of the tools already out there? Maybe it'd be better to have a seperate tool that'd have more control over the conversion from png to C array.

I'll add C array support if someone wants it, but it seems like a better solution to use libpng.
Back to top
View user's profile Send private message
Snatcher



Joined: 19 Jul 2005
Posts: 9

PostPosted: Sat Jul 23, 2005 8:57 am    Post subject: Reply with quote

In my current situation it would be useful, since I have no png support implemented neither I have ever worked with such a setup (or seen an example on the PSP using this method). But maybe it is best of I learn to use fonts that way.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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