Sign in to follow this  

Creating a font with Allegro

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So Allegro is great and all, I even got some simple stuff up and running very quickly, and using basic text is fine. But how do you create a new font like arial or whatever and use it with Allegro? Does anyone have any resources on this? The documentation in the manual doesn't cover it and searches on allegro.cc don't turn up anything useful either. I'm just looking for a simple example to set up and use a font...

Share this post


Link to post
Share on other sites
for custom fonts: The grabber program can create fonts from sets of characters drawn in a bitmap file. If you need more help try reading grabber.txt in allegro\tools thats where grabber resides as well assuming you built the tools.

it shouldnt be to tough. if you need more help i can probably help ya, youll need to draw a set of chars in paint or something in order to do this.

Share this post


Link to post
Share on other sites
Quote:
I've got a program (LMNOPc Bitmap Font Builder) that seems to do just what you say it needs to, but when I tried to load it with the grabber it didn't work. What are the specifics of how you make a font with the grabber? I tried reading grabber.txt but it didn't make much sense to me.


Alright here ya go man:
first you need a bmp file that looks like this one:
Here
Then you fire up grabber and click object->new->font
type in a name for your font like FONT_NAME.
select it in the object list and press ctrl+G(or click objects->grab) and select your file thats in the format like above. It should show your font now in the lower right corner.
make sure you enter a name in for a header file(second line under menu)
save your grabber file, make sure you have a foo.dat and foo.h

to use it in your programs
include and initialise allegro
then
#include "foo.h"
then :

DATAFILE *data = load_datafile("d:\foo.dat");
FONT *myfont = (FONT *)data[FONT_NAME].dat;

textprintf(screen,myfont,10,10,makecol(255,255,255),"This text should be on screen in your font!");

EDIT: haven't tried this but it should work... letme know if I missed something lol

Share this post


Link to post
Share on other sites
There are also some other tools

allegttf which is a library to use TTFs from Allegro but also contains a program which can be used to export existing TTFs into Allegro bitmapped font format.

GlyphKeeper which is a newer TTF library for Allegro, it probably has much higher quality - there is more control over antialiasing and hinting with this one.

A program for win32 which Shawn wrote a long time ago I think called ttf2pcx which does one-off conversions from TTF into Allegro PCX font format.

I don't know how well any of these deal with Unicode ranges; Allegro contains font-drawing routines which support UTF-8 if your font has the appropriate glyphs in.

Mark

Share this post


Link to post
Share on other sites
well I figured the problem then...what are the stats on how you size your .bmp? I got it to work with Chad's example, but with my similar but not equal .bmp file it says "error reading .bmp as a font". Does the text have to be very small? I can't see how you know if you have it just right or what

Share this post


Link to post
Share on other sites

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this