PocketMatrix forums

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

Drawing Text

Hello All,

What's the best way to draw text to the screen in Pocket Frog? I really don't want to be loading fonts and all that mess. I figure I could use GDI, but I know that Pocket Frog has to have something better.

The sample program "supersample" shows drawing text to the screen by using "display->DrawVGAText", but this requires a FNT file of 4k size. I have yet to figure out how to create these FNT files. These obviously are not standard Window's fonts because they are much too small (4k).

I really like the "bubble-text" used in birdsoft's latest PF port ("TriPeaks-Hand"). Does anyone know how they did this?

Help Please...
:(
I use a little font class I wrote that accepts a bitmap for the letters, auto slices it from the gap between letters and then accepts a string and renders each letter at a time. This has been ok for what I need, and if you are wanting to use odd fonts - it's as easy as just building a bitmap in photoshop using any font you want.
The DrawVGAText function is the one I added while I was maintaining PF... it's basically a conversion of an old PowerBasic function I used to use all the time eons ago. I think it's a good choice if a fixed-width font works for you, and it's a very simple piece of code that you can do some decent little tricks with (i.e., gradients, scaling by factors of 2, etc.) if you don't mind modifying it.

The format it uses is a standard VGA font file (hence the function name!). I'm not even sure *I* remember the exact file layout after all these years, but it shouldn't be too hard to find on the net.

Trying to recollect now though, I think the characters are 8x16 and it's basically 16 bytes per character (which works out to the 4096 byte size of the file, so I think I got it right). It's a simple bitmap format (i.e., if the first row of a character should have the first and last pixels turned on, the value for that row would be 129). I believe the entire file encompases the ASCII table, so in other words the first 16 bytes of the file are for ASCII character 0, and the capital letter A would be encoded in the 1040th-1056th bytes. Pretty straight-forward.

I don't remember if they are included in the PF distro I last did or not, but I provided something like 100 VGA fonts to choose from. If they aren't included, let me know and I'll dig them up for you. One of them will probably be to your liking, and if not then an editor should be a pretty trivial piece of work. It probably wouldn't even be a big deal to use something like Photoshop to create the correct sequence of characters sized to fit in 8x16 gridz, and then create the VGA font file from that, so you could in effect use any TrueType font you wanted.

The performance of DrawVGAText by the way is better than it probably should be :). My game Invasion: Trivia uses it quite a bit and I am able to maintain 30FPS without any problem. So, if you didn't even use it as much as that game does (which is a good guess I think) then performance isn't a real concern.

But in the end it's a fixed-width VGA font, so it's not going to be as fancy as other options. But it is there, and it is easy to use, which was my point in adding it in the first place, since there really wasn't anything else available at the time built-in, as I recall.
Thanks for the thorough explanation about the FNT format...that was very helpful. I would like to get those 100 VGA fonts that you talked about. That would save me quite a bit of work if I don't have to create these fonts from scratch. Is there a place that I can download these?

Thanks...
:)
PointOfLight · 09 Jun 2004, 16:12 UTC
If you haven't come across any VGA fonts yet, send me an email at registerstuff @ csdatasol.net and I will send you some.
dxmonger · 30 Jun 2004, 15:13 UTC — GAPI and text (PocketFrog?)
Gurus

I'm hoping that someone here can help me. I have been toying with an app that uses GAPI. I want to have a region of the screen (a rectangle/window) that contains scrolling text. I don't need to use fancy/bitmapped fonts. Standard system text will do fine.

The C++ GAPI code is stable and basically works as-is. I really need something simple and (if possible) an example.

I see there are various packages out there that may answer some of this (GAPIDraw, Pocketfrog, ...) but these may be overkill. I just want a plain ole window with a scrollbar to post text to... Is there a way to do this? Perhaps display a MFC dialog box over the top of the GAPI app (and have everything still update as expected)?

Ideas? Examples?
It's not quite as simple as you would like however you can use GDI fonts with GAPI applications like PocketFrog (documented by me in my articles).
In the text strings you can use things like /n/r to format text to wrap but most people design their own systems to display help files etc. see
http://www.sundialsoft.freeserve.co.uk/pocket_frog_Ch3.htm re: GDI fonts.



How you approach this depends on how much text you have and how fast you want it to run.

There's GDI font source here which may help:- http://www.sundialsoft.freeserve.co.uk/pfkeyboard.htm