Quickest & easiest way to have text on screen

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.

Thanks in advance,
Simon

SDL_ttf ?

i use it, is good. easy to setup. give it a font, colour and size and
it gives use an SDL_Surface…On 12/4/05, Simon <simon.xhz at gmail.com> 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.

Thanks in advance,
Simon


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

SDL_ttf ?

i use it, is good. easy to setup. give it a font, colour and size and
it gives use an SDL_Surface…

Hmmm, doesn’t it require Freetype to be already installed? I can’t do
that… I’d really prefer a bitmap-based library…

Thanks,
Simon

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

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —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

Hey thanks David!

I’ll give this a shot.

Simon

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

using SDL_TTF:

void clsControl::show_msg(char *message, int size_of_font, char *font_name, int x, int y){

  //draw message
  font_t = TTF_OpenFont(font_name,size_of_font);

  rect_button->x = x;
  rect_button->y = y;
      text_surface = TTF_RenderUTF8_Shaded(font_t,message,color,bgcolor);
  SDL_BlitSurface(text_surface,NULL , sdl->SDLscreen, rect_button);
  SDL_FreeSurface(text_surface);

  TTF_CloseFont(font_t);
  font_t = NULL;

}

Simon <simon.xhz at gmail.com> ?? vi?t: 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.

Thanks in advance,
Simon_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


B?n C? S? D?ng Yahoo! Kh?ng?
M?t m?i v? th? r?c? Yahoo! Th? c? ch??ng tr?nh b?o v? ch?ng th? r?c h?u hi?u nh?t tr?n m?ng
http://vn.mail.yahoo.com