|
Added
Link Here
|
| 1 |
--- src/alfont.c.orig 2016-10-18 20:04:21 UTC |
| 2 |
+++ src/alfont.c |
| 3 |
@@ -1,3 +1,28 @@ |
| 4 |
+/* |
| 5 |
+ * Modified Alfont 2.0.9 |
| 6 |
+ * |
| 7 |
+ * The original AllegroFont v2.0.9 has a few problems. |
| 8 |
+ * This modification solves them. |
| 9 |
+ * |
| 10 |
+ * Modification by: Alexandre Martins (thanks to http://allegro.cc forums) |
| 11 |
+ * Modification date: 2010-10-30 |
| 12 |
+ * |
| 13 |
+ * Modification by: Rusmir Dusko |
| 14 |
+ * (thanks to http://allegro.cc forums and Hans de Goede [alfont] Fix undefined reference to _msize) |
| 15 |
+ * Modification date: 2014-03-10 |
| 16 |
+ * |
| 17 |
+ * Original Alfont website: http://chernsha.sitesled.com/ |
| 18 |
+ * AllegroFont (c) 2001, 2002 Javier Gonzalez |
| 19 |
+ * Enhanced by Chernsha since 2004 year |
| 20 |
+ */ |
| 21 |
+ |
| 22 |
+//#define malloc_usable_size malloc_size |
| 23 |
+ |
| 24 |
+#ifdef __GNUC__ |
| 25 |
+#define _msize malloc_usable_size |
| 26 |
+#include <malloc_np.h> |
| 27 |
+#endif |
| 28 |
+ |
| 29 |
/* AllegroFont - a wrapper for FreeType 2 */ |
| 30 |
/* to render TTF and other font formats with Allegro */ |
| 31 |
|
| 32 |
@@ -336,7 +361,7 @@ int alfont_set_font_size(ALFONT_FONT *f, |
| 33 |
break; |
| 34 |
|
| 35 |
/* compare real height with asked height */ |
| 36 |
- real_height = abs(f->face->size->metrics.ascender >> 6) + abs(f->face->size->metrics.descender >> 6); |
| 37 |
+ real_height = labs(f->face->size->metrics.ascender >> 6) + labs(f->face->size->metrics.descender >> 6); |
| 38 |
if (real_height == h) { |
| 39 |
/* we found the wanted height */ |
| 40 |
break; |
| 41 |
@@ -468,7 +493,7 @@ ALFONT_FONT *alfont_load_font(const char |
| 42 |
alfont_set_char_extra_spacing(font, 0); |
| 43 |
|
| 44 |
//Initial Font attribute |
| 45 |
- font->language=""; /* Initial Language */ |
| 46 |
+ font->language=NULL; /* Initial Language */ |
| 47 |
font->type=0; /* Initial Code Convert */ |
| 48 |
font->outline_top=0; /* Initial Font top outline width */ |
| 49 |
font->outline_bottom=0; /* Initial Font bottom outline width */ |
| 50 |
@@ -515,7 +540,7 @@ ALFONT_FONT *alfont_load_font_from_mem(c |
| 51 |
memcpy((void *)font->data, (void *)data, data_len); |
| 52 |
|
| 53 |
/* load the font */ |
| 54 |
- error = FT_New_Memory_Face(ft_library, font->data, font->data_size, 0, &font->face); |
| 55 |
+ error = FT_New_Memory_Face(ft_library, (unsigned char*)font->data, font->data_size, 0, &font->face); |
| 56 |
|
| 57 |
if (error) { |
| 58 |
free(font->data); |
| 59 |
@@ -548,7 +573,7 @@ ALFONT_FONT *alfont_load_font_from_mem(c |
| 60 |
alfont_set_char_extra_spacing(font, 0); |
| 61 |
|
| 62 |
//Initial Font attribute |
| 63 |
- font->language=""; /* Initial Language */ |
| 64 |
+ font->language=NULL; /* Initial Language */ |
| 65 |
font->type=0; /* Initial Code Convert */ |
| 66 |
font->outline_top=0; /* Initial Font top outline width */ |
| 67 |
font->outline_bottom=0; /* Initial Font bottom outline width */ |
| 68 |
@@ -3761,15 +3786,15 @@ int alfont_ugetx(ALFONT_FONT *f, char ** |
| 69 |
//advances the *s pointer to the next character |
| 70 |
|
| 71 |
if (f->type==1) { |
| 72 |
- ugetxc((char**)s); |
| 73 |
+ ugetxc((const char**)s); |
| 74 |
#ifdef ALFONT_LINUX |
| 75 |
- ugetxc((char**)s); |
| 76 |
+ ugetxc((const char**)s); |
| 77 |
#endif |
| 78 |
} |
| 79 |
else if(f->type==2) { |
| 80 |
- ugetxc(&lpszWS); |
| 81 |
+ ugetxc((const char**)&lpszWS); |
| 82 |
#ifdef ALFONT_LINUX |
| 83 |
- ugetxc(&lpszWS); |
| 84 |
+ ugetxc((const char**)&lpszWS); |
| 85 |
#endif |
| 86 |
#ifdef ALFONT_DOS |
| 87 |
if ((c_pt = iconv_open(f->language, "UTF-16LE")) == (iconv_t)-1) { |
| 88 |
@@ -3814,9 +3839,9 @@ int alfont_ugetx(ALFONT_FONT *f, char ** |
| 89 |
#ifdef ALFONT_LINUX |
| 90 |
set_uformat(U_UTF8); |
| 91 |
#endif |
| 92 |
- ugetxc((char**)s); |
| 93 |
+ ugetxc((const char**)s); |
| 94 |
#ifdef ALFONT_LINUX |
| 95 |
- ugetxc((char**)s); |
| 96 |
+ ugetxc((const char**)s); |
| 97 |
#endif |
| 98 |
} |
| 99 |
|
| 100 |
@@ -4083,9 +4108,9 @@ int alfont_ugetxc(ALFONT_FONT *f, const |
| 101 |
#endif |
| 102 |
} |
| 103 |
else if(f->type==2) { |
| 104 |
- ugetxc(&lpszWS); |
| 105 |
+ ugetxc((const char**)&lpszWS); |
| 106 |
#ifdef ALFONT_LINUX |
| 107 |
- ugetxc(&lpszWS); |
| 108 |
+ ugetxc((const char**)&lpszWS); |
| 109 |
#endif |
| 110 |
#ifdef ALFONT_DOS |
| 111 |
if ((c_pt = iconv_open(f->language, "UTF-16LE")) == (iconv_t)-1) { |
| 112 |
@@ -4828,7 +4853,7 @@ void alfont_set_language(ALFONT_FONT *f, |
| 113 |
} |
| 114 |
else |
| 115 |
{ |
| 116 |
- f->language=(char *)malloc(strlen(language)*sizeof(char)); |
| 117 |
+ f->language=(char *)malloc((strlen(language)+1)*sizeof(char)); |
| 118 |
strcpy(f->language,language); |
| 119 |
} |
| 120 |
} |