Even easier!
You can use a library that draws the fonts by using primitives. This way, you
won’t even need data files, and you get any color and size you want for free.
You can use the SDL_gfx library for that (which is shipped in a few distros):
http://www.ferzkopp.net/Software/SDL_gfx-2.0/
It has the following function:
int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char *c,
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
(I don’t understand why they didn’t add support for different size – should
be technically trivial.)
If you want, you can also “steal” my code (its GPL) from the SteadyFeet game
(text.h and text.cpp – should be C compatible):
http://rpmcruz.planetaclix.pt/repository/graphical/#steadyfeet
And then use:
int draw_text(const char* text, int x, int y, int size,
int top_red, int top_green, int top_blue,
int bottom_red, int bottom_green, int bottom_blue,
Allignment allignment = LEFT_ALLIGN);
Cheers,
RicardoEm Domingo 04 Dezembro 2005 22:41, o David Olofson escreveu:
On Sunday 04 December 2005 23.09, Simon wrote:
Hi there!
I’m eventually going to use freetype, but for now, I need to have
text on my screen, properly displayed (2D), I don’t care which font.
They can certainly be bitmaps, as long as I don’t need to compile
more than one thing to get fonts in my own program. The reason for
this is I just need quick Input/Output to one of my programs which
needs to be complete for tomorrow. This said, I just cannot go into
compiling FreeType or any such libraries.
The easiest way is probably the de-facto standard “SFont”, which uses
a single bitmap image with spacing information in the top pixel row
to define a font. There are implementations over SDL and/or OpenGL,
including SFont itself and some others that support the same font
format, or extended versions of it;
http://www.linux-games.com/sfont/
http://www.cs.unibo.it/~dbilli/bfont/bfont.html
http://www.daimi.au.dk/~eriksoe/krnfont.html
http://www.grinninglizard.com/kyra/index.html
//David Olofson - Programmer, Composer, Open Source Advocate
–
Happiness isn’t something you experience; it’s something you remember.
– Oscar Levant