# Allegro, Fudge Font

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

## Recommended Posts

Okay so I finally found a ttf library thats for allegro, took about 3 hours. So I was wondering has anyone used it if so can you help me out with this one function. This example: http://fudgefont.sourceforge.net/#head-372850c07e6aac0b7cd33999d0a7f1eabdb0268b
   1 #include <allegro.h>
2 #include <fudgefont.h>
3
4 int main(void)
5 {
6     allegro_init();
7     install_keyboard();
8     install_timer();
9     install_fudgefont();
10     set_color_depth(32);
11     set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
12     clear_to_color(screen, makecol(255, 255, 255));
13     int size = 40; /* Size of our font in pixels. */
15     size = 12;
16     FONT *f2 = load_font("DejaVuSans.ttf", NULL, &size); /* Another. */
17
18     fudgefont_color_range(255, 255, 255, 100, 0, 0); /* Set up palette. */
19     textprintf_centre_ex(screen, f, 320, 200, -1, -1,
20         "Fudge the Font!");
21     fudgefont_color_range(255, 255, 255, 0, 0, 200);
22     textprintf_centre_ex(screen, f2, 320, 200 + text_height(f), -1, -1,
23         "Fudging Truetype fonts into Allegro in a minimalistic way..");
24
26     return 0;
27 }
28 END_OF_MAIN()

How do you think this function works, I know the first 3 arguments are RGB colors.
Quote:
 fudgefont_color_range(255, 255, 255, 0, 0, 200);
Theres 3 more args but I have no clue on what it is, and theres like no documentation. Also do all I need is to include this .cpp and include the header file that came with the DL to work[haven't tried it yet](check attachments) Okay I looked in the source again and found:
/* Create a palette ranging from r1/g1/b1 to r2/g2/b2, and select it. */
void fudgefont_color_range(int r1, int g1, int b1, int r2, int g2, int b2)
{
PALETTE pal;
int i;
for (i = 0; i < 256; i++)
{
int red = r1 + (r2 - r1) * i / 255;
int green = g1 + (g2 - g1) * i / 255;
int blue = b1 + (b2 - b1) * i / 255;
RGB rgb = {red * 63 / 255, green * 63 / 255, blue * 63 / 255, 0};
pal = rgb;
}
select_palette(pal);
}

Is it supposed to be gradient like(basing on the comment..)

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 14
• ### Forum Statistics

• Total Topics
632155
• Total Posts
3004477

×