Modified Alfont 2.0.9

Overview

The original AllegroFont 2.0.9 is broken, making programs crash. This modification solves the problem.

Updated: 2012-02-17. E-mail: alemartf (at) gmail.com

AllegroFont (c) 2001, 2002 Javier Gonzalez

FreeType project Copyright (c) 1996-2000 by David Turner, Robert Wilhelm, and Werner Lemberg
Enhanced by Chernsha since 2004 year

AllegroFont is an Allegro wrapper for the wonderful FreeType2 library that makes Allegro (amongst other things) able to load and render TTF and many other famous font formats. Other feature is that it is able to render the fonts antialiased.

Generic Installation

  1. Download the regular AllegroFont 2.0.9 from http://chernsha.sitesled.com/ (or use our mirror)
  2. Replace alfont/src/alfont.c by the modified alfont.c
  3. Follow the compilation process described in alfont/README.txt
  4. Assuming static linkage, after running make, copy alfont/lib/<your_platform>/libalfont.a and alfont/include/* to their proper places (system folders under Linux, compiler directories under Windows)

Linux users

Linux user? This simplified guide has been taken from AGS:

wget http://opensnc.sourceforge.net/alfont/AlFont209.rar
unrar x AlFont209.rar   
cd alfont/  
wget http://opensnc.sourceforge.net/alfont/alfont-2.0.9-linux.patch  
patch -p1 < alfont-2.0.9-linux.patch   
gcc -fPIC -DPIC -O2 -m32 -Iinclude `freetype-config --cflags` -o src/alfont.o -c src/alfont.c  
gcc -O2 -m32 -shared -Wl,-soname,libalfont.so.2 -o libalfont.so.2.0.9 src/alfont.o `freetype-config --libs` `allegro-config --libs |sed 's/-lalleg_unsharable//'`  
sudo install -m 755 libalfont.so.2.0.9 /usr/lib/  
sudo install -m 644 include/alfont*.h /usr/include/  
sudo ln -s libalfont.so.2.0.9 /usr/lib/libalfont.so.2.0  
sudo ln -s libalfont.so.2.0.9 /usr/lib/libalfont.so.2  
sudo ln -s libalfont.so.2.0.9 /usr/lib/libalfont.so  
cd ..

The diff

$ diff alfont.c alfont.c.1 
0a1,18
> /*
>  * Modified Alfont 2.0.9
>  *
>  * The original AllegroFont v2.0.9 has a few problems.
>  * This modification solves them.
>  *
>  * Modification by: Alexandre Martins (thanks to http://allegro.cc forums)
>  * Modification date: 2010-10-30
>  *
>  * Original Alfont website: http://chernsha.sitesled.com/
>  * AllegroFont (c) 2001, 2002 Javier Gonzalez
>  * Enhanced by Chernsha since 2004 year
>  */
> 
> #if defined(__GNUC__) && !defined(__MINGW32__)
> #define _msize malloc_usable_size
> #endif
> 
471c489
<   font->language="";           /* Initial Language */
---
>   font->language=NULL;         /* Initial Language */
551c569
<   font->language="";           /* Initial Language */
---
>   font->language=NULL;         /* Initial Language */
4831c4849
<    f->language=(char *)malloc(strlen(language)*sizeof(char));
---
>    f->language=(char *)malloc((strlen(language)+1)*sizeof(char));

Back to Open Surge