PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Font support ?

I know that earlier versions had a built in font. While I have been using GDI fonts these are just too slow for use in the main game loop.

I suggest that interested parties discuss the requirement with a view to either sharing the work to implement an add-on or even better having font support included within PocketFrog.

In PocketGL the simple letters as a bitmap approach is taken one step further by including character width information. This gives a slightly better look than a simple fixed font though is still restricted in size. While it is possible to code access to TTF font data this would be much more work & would be slower again.

I will look at the method used in GapiDraw to see if it's easy enough to follow.

What does the FP community think ?
BurningSheep · 16 Oct 2002, 11:55 UTC
I still use the Bitmap Builder by LMNOpc, it has some options to save font width as well.

http://www.lmnopc.com/bitmapfontbuilder/

But what I would like to see is a font class where you give the name of the windows font when you create the class. And it will render all chars to a bitmap as well as saving the width of every char at creation.

Quite simple to implement in PF really... but never got around to actually do it.
Conan · 16 Oct 2002, 12:37 UTC — thanks for the link
I am going to have a good look at this font builder. (It may be the same or similar to the PocketGL font)

Do you already have a working function to utilise these fonts? If so is it clean enough to share?
If not I will write my own at the weekend.

I agree that supporting TTF would be the best approach but it's more work than I can handle at the moment.
BurningSheep · 16 Oct 2002, 12:55 UTC
I have a font class that takes a bitmap in this format, it's not finished. At the moment it doesn't take character width into account, and you can't format strings like with printf yet, like this:

Code:

printf("Coord: (%i, %i)", x, y);

So you have to write your string to a buffer before calling the write function.

those are the features I wanted to add first, generating the bitmap instead of reading it from a file is less important to me. But any work on this stuff will have to wait for a couple of weeks :)

You can download the class here:
http://vulcanus.its.tudelft.nl/robert/p ... tClass.zip
Conan · 16 Oct 2002, 13:15 UTC — font class
Many thanks, I will have a look.

The PocketGL font system is not the same as this one. The only point I pocked up was that with the width you can add up the total width to allow centering but otherwise it's not useful.

As the font builder supports 2 sizes of fonts it's enough for me to be getting on with.
I won't add support for fonts to PocketFrog myself. I feel they are not needed for most games and it is almost impossible to provide an API/implementation that fits all needs.

I have no problem though having people contribute such functionality. It might even be added to the PocketFrog distribution (with your consent, of course).

There is a lot of other stuff that I want to add before fonts, so you guys go ahead and work on it.
BurningSheep · 02 Nov 2002, 03:02 UTC
I started on a new font class, no more loading from bitmaps, but rather generate the fontmap using gdi. Which gives the same rendering speed as using bitmaps but no more hassle with making bitmap fonts yourself and saving some space as well ;)

anyways, it's still a wip, but here is a sample of the code and what it generates now:

Code:

void MyGame::GameLoop()
{
// Get display
DisplayDevice* display = GetDisplay();

// Init some fonts
static Font headerFont( display, "Comic Sans MS", 14, RGB(200, 40, 0) );
static Font normalFont( display, "Trebuchet MS", 10 );

// Clear screen
display->Clear(Color(20, 20, 80));

// Write some stuff
headerFont.Write( display, 10, 10, "Pangram font test" );
normalFont.Write( display, 10, 34, "Mix Zapf with Veljovic and get " );
normalFont.Write( display, 10, 34+normalFont.GetHeight(), "quirky Beziers." );

// Write formatted text
normalFont.Writef( display, 10, 79, "Form%.2fed str%ings work %i ;)", 4.77, 1, 2 );

// Writing chunks of texts using a rect
RECT rect = { 10, 79 + normalFont.GetHeight() * 2, display->GetWidth() - 10, display->GetHeight() };
normalFont.Write( display, rect, "Moi, je veux quinze clubs a golf et du whisky pur.\n\nAn inspired calligrapher can create pages of beauty using stick ink, quill, brush, pick-axe, buzz saw, or even strawberry jam." );

// Update screen
display->Update();
}


Image

Some other things I'm going to implement is support for bold, italic and underlined fonts; and text alignment (left, right, center).
But if you guys have ideas for other features to be implemented, let me know :)
cool - where can we get a copy??
>> if you guys have ideas for other features to be implemented, let me know

How about GapiDraw support? :D

/Johan
sbl wrote:
How about GapiDraw support? :D
/Johan


I was under the impression that GapiDraw already had fonts?
It does, but only bitmapped.. Bitmapped is good for many things, but for ease of use this looks like a killer...
BurningSheep · 05 Nov 2002, 23:36 UTC
sbl wrote:
>> if you guys have ideas for other features to be implemented, let me know

How about GapiDraw support? :D

/Johan

hehe, should be relatively easy, the code is pretty much independent from pocketfrog except for the blitting. I'm planning to add some stuff somewhere this week and will look at a gapidraw version as well while I'm at it =]
BurningSheep · 08 Nov 2002, 18:02 UTC
draklava wrote:
cool - where can we get a copy??


I've uploaded the class, haven't added aligment yet and the font loading can probably be made a bit faster. It takes between 1.5 seconds to load a single font, writing text should be just as fast as any bitmapped font class.

Anyways, here are the files so you can play with it yourselves. Also a quick and dirty port to gapidraw, seems to be working fine. In both the zips is also an example of how to use it:

PocketFrog Font Class
GapiDraw Font Class
Thanks Rob! I'm new here and to pocketfrog
and this will help alot.

A quick heads up. Your .h file GetHeight() has
a typo in the comment that refers to 'width'

Looks nice and striaght forward. Good work.

~Chris
BurningSheep":3vwrctmm]
[quote="sbl wrote:

>> if you guys have ideas for other features to be implemented, let me know

How about GapiDraw support? :D

/Johan

hehe, should be relatively easy, the code is pretty much independent from pocketfrog except for the blitting. I'm planning to add some stuff somewhere this week and will look at a gapidraw version as well while I'm at it =]




hello robert


can this font class show the DBCS word like chinese or Japanese???

plz help me
I know we're talking about TTF support, and I like BurningSheep's approach (that was one of those "duh, why didn't I think of that" moments!)... If you don't need TTF support, take a look at the VGA font extension I posted a few days ago. It's certainly not the best by a long shot, but it might help anyone that's interested out anyway,
BurningSheep · 23 Jan 2003, 20:11 UTC
jack wrote:
hello robert


can this font class show the DBCS word like chinese or Japanese???

plz help me


Yes, it's possible but you will have to edit the code yourself though. One problem with DBCS in this case is that it's 16-bit charset.
I'm using the extended ASCII charset wich contains 256 chars (of which i don't even load the first 32 chars), this already takes well over one second to load, so you can imagine how long it will take to load a 16-bit charset.
So I think your best bet is to use a bitmap font the way fzammetti is suggesting, unless you find a way to speed-up my font loading code. I know there is room for improving the speed, but back then I couldn't really figure it out from MSDN. And I haven't looked at it since.

To convert a ttf font to a bitmap font you could use my code on your PC to generate that bitmap. You'd only have to adjust the code to use the correct fontset, but the code runs just fine on Windows 2k/xp/etc.
This is assuming there isn't already a ttf->bmp converter for DBCS out there somewhere, in that case it's probably easiest to just use that.