Font creation tool

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

Moderators: cheriff, TyRaNiD

Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Font creation tool

Post by Tim »

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.
apache37
Posts: 76
Joined: Fri Jun 04, 2004 3:13 pm

Post by apache37 »

ok I'm interested :p
User avatar
neofar
Posts: 47
Joined: Wed Jan 21, 2004 2:40 am
Location: Spain
Contact:

Post by neofar »

Very very interesting, I'm waiting for you all my life!!!
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

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.
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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.
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

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.
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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?
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Consider sfont instead of reinventing the wheel.
MrSiir[S]
Posts: 32
Joined: Tue Sep 14, 2004 11:08 am

Post by MrSiir[S] »

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!
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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...
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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

http://tim.strafenet.com/files/font2png.zip
User avatar
neofar
Posts: 47
Joined: Wed Jan 21, 2004 2:40 am
Location: Spain
Contact:

Post by neofar »

umm... interesting your first beta preview release....
but >> http://www.lmnopc.com/bitmapfontbuilder/
you need more features if want to be the best
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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.
User avatar
neofar
Posts: 47
Joined: Wed Jan 21, 2004 2:40 am
Location: Spain
Contact:

Post by neofar »

If I select

Code: Select all

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
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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...
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

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?
User avatar
neofar
Posts: 47
Joined: Wed Jan 21, 2004 2:40 am
Location: Spain
Contact:

Post by neofar »

Image

(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
ironbird
Posts: 6
Joined: Sat Jul 02, 2005 11:59 am

What about 16bit Char Set(ex. Unicode)?

Post by ironbird »

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

Where is 16bit Font Tool for PSP?
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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.
ironbird
Posts: 6
Joined: Sat Jul 02, 2005 11:59 am

Post by ironbird »

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".
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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.
ironbird
Posts: 6
Joined: Sat Jul 02, 2005 11:59 am

Post by ironbird »

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. ~~
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

I'll add unicode support and put a new version up later today
Snatcher
Posts: 9
Joined: Tue Jul 19, 2005 2:31 am

Post by Snatcher »

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

Thanks for your work.
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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.
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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
Snatcher
Posts: 9
Joined: Tue Jul 19, 2005 2:31 am

Post by Snatcher »

Thanks man!

I'll test it out immediately, and tell you when get results.
Snatcher
Posts: 9
Joined: Tue Jul 19, 2005 2:31 am

Post by Snatcher »

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.
Tim
Posts: 38
Joined: Tue Jul 12, 2005 4:40 am

Post by Tim »

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.
Snatcher
Posts: 9
Joined: Tue Jul 19, 2005 2:31 am

Post by Snatcher »

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.
Post Reply