Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to change font size?

This thread is locked; no one can reply to it. rss feed Print
How to change font size?
thirdy
Member #8,409
March 2007
avatar

I've searched the forum for this problem but it the engine return too many results.
So can anyone help me? How can I make textprintf_ex(); output larger strings(higher font size)? Thanx!!!

GullRaDriel
Member #3,861
September 2003
avatar

Checking the example provided by allegro should help, expecially the exfonts...

Use a different font
Use TrueType Library
Use GlyphKeeper
Make your own bigger font
...

Output the text somewhere else and stretch_blit it on the destination

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

thirdy
Member #8,409
March 2007
avatar

Hello Gull! I can't find the code in the exfont.c that makes the char 'H' huge.

GullRaDriel
Member #3,861
September 2003
avatar

Yeah I realized that and that is why I stroke the first line of my post.

Using pure allegro, only 2 options: a different font or a little hack.

Little hack is something as this:

1/*!\fn textout_hack( BITMAP *bmp , FONT font , int x , int y , double multiplier , char *msg , int color )
2 *
3 *\brief output a text in with the chosen font, the final size = source size * multiplier
4 *
5 *\param bmp The destination bitmap
6 *\param font The used font
7 *\param x Destination point, X coordinate
8 *\param y Destination point, Y coordinate
9 *\param msg The string to output
10 *\param color The color of the text
11 *
12 *\return TRUE or FALSE
13 */
14int textout_hack( BITMAP *bmp , FONT font , int x , int y , double multiplier , char *msg , int color )
15{
16 BITMAP *tmp;
17
18 tmp = create_bitmap( text_length(font, msg), text_height(font));
19
20 if( !tmp)
21 return FALSE;
22
23 clear_to_color( tmp , makecol( 255 , 0 , 255 ) );
24 textout_ex( tmp, font, msg, 0, 0, 1, -1) ;
25
26 masked_stretch_blit( tmp , bmp , 0 , 0 , tmp -> w , tmp -> h , x , y , (int)(tmp -> w * multiplier), (int)(tmp -> h * multiplier));
27
28 destroy_bitmap( tmp );
29
30 return TRUE;
31
32}

Untested but should work, and you get the idea.
It is a slow way. There are faster.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

thirdy
Member #8,409
March 2007
avatar

I used alfont devpak and it helped me flawlessly. I just copied a arial.ttf then I'm ok.

I gave up with the cgui and adime, right now I'm coding my own GUI in my program =)
Maybe later I'll work on cgui and adime.

Go to: