Fonts (text in general)

Hi, everyone,

Correct me if I’m wrong, but there doesn’t seem to be a
standard way to write text to an SDL_Surface. Is this
true?

If there’s a standard way to do this, which part of the
FM should I read? Otherwise, how are people doing this?

I am considering writing a library to take bitmap font
descriptions in XML and render text on an SDL surface,
but I don’t want to reinvent any wheels.

– Joe Knapka

SDL_Console has bitmapped font support.

Also check the ‘libraries’ section on the SDL site for SDL_ttf.–
Brian

On Sat, 29 Jan 2000, Joe Knapka wrote:

Hi, everyone,

Correct me if I’m wrong, but there doesn’t seem to be a
standard way to write text to an SDL_Surface. Is this
true?

If there’s a standard way to do this, which part of the
FM should I read? Otherwise, how are people doing this?

I am considering writing a library to take bitmap font
descriptions in XML and render text on an SDL surface,
but I don’t want to reinvent any wheels.

– Joe Knapka

Joe Knapka wrote:

Hi, everyone,

Correct me if I’m wrong, but there doesn’t seem to be a
standard way to write text to an SDL_Surface. Is this
true?

I expect people are transparent-blitting bitmap font images.–
Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

hayward at slothmud.org wrote:

SDL_Console has bitmapped font support.

Also check the ‘libraries’ section on the SDL site for SDL_ttf.

One annoying thing I noticed about SDL_Console’s text support is its use
of descenders. A ‘p’, ‘y’ or other character that happens to have a bit
of it sticking below the text baseline has the descender on the
baseline, not below it. This is annoying and kinda ugly. Not even the
old 8x8 fonts that are used by the old IBM BIOS for CGA graphics mode
text were like that. Shouldn’t be too difficult to rectify if I
understand how fonts are used there, though. Could probably be
corrected by editing the fonts with some good paint program and
displacing the rest of the font by the height of the descenders;
probably no code modifications are needed.–

| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |

College of Engineering, University of the Philippines, Diliman

nod, I use SDL_ttf myself.

Doesn’t SDL_Console just take whatever bitmapped font you give it?
In which case, the descenders not being belew just means your bitmapped
font wasn’t rendered right?–
Brian

One annoying thing I noticed about SDL_Console’s text support is its use
of descenders. A ‘p’, ‘y’ or other character that happens to have a bit
of it sticking below the text baseline has the descender on the
baseline, not below it. This is annoying and kinda ugly. Not even the
old 8x8 fonts that are used by the old IBM BIOS for CGA graphics mode
text were like that. Shouldn’t be too difficult to rectify if I
understand how fonts are used there, though. Could probably be
corrected by editing the fonts with some good paint program and
displacing the rest of the font by the height of the descenders;
probably no code modifications are needed.

Dido Sevilla wrote:

hayward at slothmud.org wrote:

SDL_Console has bitmapped font support.

Also check the ‘libraries’ section on the SDL site for SDL_ttf.

One annoying thing I noticed about SDL_Console’s text support is its use
of descenders. A ‘p’, ‘y’ or other character that happens to have a bit
of it sticking below the text baseline has the descender on the
baseline, not below it. This is annoying and kinda ugly. Not even the
old 8x8 fonts that are used by the old IBM BIOS for CGA graphics mode
text were like that. Shouldn’t be too difficult to rectify if I
understand how fonts are used there, though. Could probably be
corrected by editing the fonts with some good paint program and
displacing the rest of the font by the height of the descenders;
probably no code modifications are needed.

I created some better font images suitable for a console. For a limited
time, you can get the BMP and PNGs here:

http://www.antimeta.com/tmp/

SMALL 8x16 is lucidatypewriter bold 16 in the GIMP
12x24 is 14x28 scaled down a bit
MEDIUM 14x28 is lucidatypewriter bold 24 in the GIMP
LARGE 16x32 is 14x28 scaled up a bit–
Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

hayward at slothmud.org wrote:

Do you retain the copyright to those fonts?

Are they free for use in commercial and non-commercial games?

Good question.

I created them patiently using the text tool in the GIMP, hand-aligning
the anti-aliased lines of text. I used ASCII characters only (i.e., not
ISO 8859-1 etc.).

I used “lucidatypewriter bold” because it is twice as high as wide and I
like its clean look. That font must come from XFree86. I am not sure
about its licensing restrictions.

I am happy to place my font images in the public domain, but I am not
sure if I have such permission. Does anyone know the licensing
restrictions on fonts from XFree86, or where I can find such
information?

If I am free to give such permission, I’ll make a separate page for
these fonts and make them available. I’m also working on my own console,
BTW.–
Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

I expect people are transparent-blitting bitmap font images.

Quit spying on me! :wink:

-bill!

I wrote:

If I am free to give such permission, I’ll make a separate page for
these fonts and make them available. I’m also working on my own console,
BTW.

The more I think about it, the more I assume that if I produce an image
in the GIMP from scratch, it must be an original work.

I’ve made the images available, with further info, at:

http://www.antimeta.com/projects/font/

PS: I have one or two more non-anti-aliased fonts I captured from
XEmacs. Any interest in those?

PPS: Just dumping a 256-character set here to see how it shows:

!"#$%&’()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_
`abcdefghijklmnopqrstuvwxyz{|}~

???
???
???–
Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

“Marc A. Lepage” wrote:

Joe Knapka wrote:

Hi, everyone,

Correct me if I’m wrong, but there doesn’t seem to be a
standard way to write text to an SDL_Surface. Is this
true?

I expect people are transparent-blitting bitmap font images.

OK, this implies that everyone is inventing their own ad-hoc
fonts and schemes for mapping ASCII or Unicode to character
bitmaps, true? Or is there a standard bitmapped font format
that makes this trivial to do?

– Joe Knapka> –

Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

Joe Knapka wrote:

“Marc A. Lepage” wrote:

Joe Knapka wrote:

Hi, everyone,

Correct me if I’m wrong, but there doesn’t seem to be a
standard way to write text to an SDL_Surface. Is this
true?

I expect people are transparent-blitting bitmap font images.

OK, this implies that everyone is inventing their own ad-hoc
fonts and schemes for mapping ASCII or Unicode to character
bitmaps, true? Or is there a standard bitmapped font format
that makes this trivial to do?

ASCII, ISO 8859-1, and UNICODE are fixed standards.

If I understand you, you mean how the characters are layed out in the
image?

I am using lines of 32 characters in my images. This makes the images
easier to deal with (size-wise) than one single long line. Calculations
are still easy (divide by 32 for character width, divide by number of
lines for character height).

It seems to align naturally with the ASCII set itself (consider upper
and lower case letters). And, it has the advantage that you can see line
spacing directly in your image.–
Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

“Marc A. Lepage” wrote:

Joe Knapka wrote:

“Marc A. Lepage” wrote:

Joe Knapka wrote:

Hi, everyone,

Correct me if I’m wrong, but there doesn’t seem to be a
standard way to write text to an SDL_Surface. Is this
true?

I expect people are transparent-blitting bitmap font images.

OK, this implies that everyone is inventing their own ad-hoc
fonts and schemes for mapping ASCII or Unicode to character
bitmaps, true? Or is there a standard bitmapped font format
that makes this trivial to do?

ASCII, ISO 8859-1, and UNICODE are fixed standards.

If I understand you, you mean how the characters are layed out in the
image?

Right. I mean, seems to me you’d like to be able to so something like:

SDL_Surface* font_bitmap = LoadImage(blah blah blah);
SDL_Surface* rendered_text = DrawText(“Hello, world”,font_bitmap);

and then rendered_text will be a surface containing the text, with
transparent background, which you can blit onto your screen. The
question is, how does DrawText() extract the individual character
bitmaps from the font bitmap? Seems like it would be highly desirable
to build a library that allowed a font bitmap to be described in a
standard way so that this would be easy to do.

What I am contemplating is a library that would take a font
bitmap and some XML like:

<FONT_DESCRIPTION bmapfile=“myfont.bmp”>





and do the rendering task, supplying SDL_Surfaces that could be
blitted wherever you want. Additionally, I was going to optionally
allow the character bitmaps to be embedded in the XML as text,
rather than requiring a separate bitmap file:

-----
–**-
-
-****
-
-

In this case, the entire font could just be encoded in the
executable as a string, parsed and rendered during app initialization,
and used. (Incidentally, I know the font sizes in my examples
are really teeny tiny; it’s just an example. The library could
do scaling as well, though it’s not yet obvious to me how to do it
in a nice way.)

Does this look like a useful thing?

– Joe Knapka

I am using lines of 32 characters in my images. This makes the images
easier to deal with (size-wise) than one single long line. Calculations
are still easy (divide by 32 for character width, divide by number of
lines for character height).

It seems to align naturally with the ASCII set itself (consider upper
and lower case letters). And, it has the advantage that you can see line
spacing directly in your image.


Marc A. Lepage
http://www.antimeta.com/
Minion open source game, RTS game programming, etc.

bitmaps from the font bitmap? Seems like it would be highly desirable
to build a library that allowed a font bitmap to be described in a
standard way so that this would be easy to do.

It’s easy if you use fixed-size fonts like SDL_Console.–
Brian