Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro TTF

This thread is locked; no one can reply to it. rss feed Print
Allegro TTF
Edward Griffin
Member #2,716
September 2002

I'm using a library called Allegro TTF to display antialiased true type fonts.

http://huizen.dds.nl/~deleveld/allegttf.htm

The loading function reads the a TTF file and converts it to a FONT with antialiasing. What I want to do is save this into a datafile so that I don't need to keep a .ttf file in my game directory. I basically need a function that will export the font as data which I can grab into grabber. I've tried to adapt the "font plugin" source code (from grabber) without much success. I'm not even sure just using export_font would work anyway, since that might loose the antialiasing information if the font was converted to a bmp/txt file. All I really need to do is save the raw data, but I don't know how to find the number of bytes of a font so I couldn't specify how much data to write. Can anyone help. I'm in 32 bit color depth at 640x480.

FONT *smoothfont;
smoothfont = load_ttf_font("verdana.ttf", 12, ALLEGTTF_REALSMOOTH);

I'm not at all sure how this library antialiases text since when I use aatextout, -- the output is antialiased text, but I seem to get antialiased text when I use plain old textout. I don't know why.

spellcaster
Member #1,493
September 2001
avatar

That's what ttf2pcs is for :)
You can grab a copy of that program from this site... not sure where it is, though.

Check the files section on the main page.

I'm not sure, but I think allegTTF comes with it's own version of ttf2pcx.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Matt Smith
Member #783
November 2000

If you are getting smooth text with plain textout it is because you have made a coloured font. This can have a couple of problems

  • when you print onto a different colour background you get fringes

  • You cannot change the colour of the text with text_mode

There are functions which people have written which take a greyscale bitmap font and let you print it anti-aliased in any colour, but textout won't do that by itself.

If you like a GUI version of ttf2pcx but don't run Windows, then here is one I knocked up which uses the Allegro GUI and works in Linux and DOS. This needs the AllegroFont library which is similar to AllegroTTF

spellcaster
Member #1,493
September 2001
avatar

If you work in a hicolor mode, the fastest way to work with fonst is to select a palette with changed values, so it blends nicely into the bg.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Go to: