--- /dev/null
+AUX freetype-1.4-glibc-2.10.patch 2377 RMD160 d975058636f69cf061704a866fc83d5068f8aa79 SHA1 7644c03725bc248d49cfa43ac6d362227b1b79e1 SHA256 60d41048bd11a024c041a24a424c9663b4debe3ab188db400928925b71039d4a
+AUX freetype-1.4_pre-contrib-destdir.patch 3679 RMD160 96f79dbd53bc0b2d24739e87481b27b6247d6d2c SHA1 c9cb6dc45f25d419f3ee0155e564deb1e203cf5b SHA256 8d99ce9264a83033d6df455488e80e763f3774b74a97b27c321b5c018076cad2
+AUX freetype-1.4_pre-malloc.patch 494 RMD160 179fb32b4a0181d453b3773ef97f5224d8e623b0 SHA1 15a6267c3c74a350380a448114ff49787663ff10 SHA256 a69ea481382974172440bc717d29ae3480cf119175c9d2411385118ec5cffde6
+AUX freetype-1.4_pre-silence-strict-aliasing.patch 9450 RMD160 75c0f05c04dd8ef849b0234a269a577f5fa889fe SHA1 bad2209c104c88ec361ab00c885e2f9f67fc1d39 SHA256 73c1fe056dc21200251f2d13b8af26fd9efee8583cdbade16e6134e79fc28ee8
+AUX freetype-1.4_pre-ttf2pk-tetex-3.patch 13454 RMD160 e92964fe510825687548f575a6752292b809b947 SHA1 77aed4bc52fc3d5698402e4ae037258e2a069fae SHA256 1ff2c6842c654656bd2b97a69afd443d56b25b8a62b514b0026653692546ee84
+AUX freetype-1.4_pre-ttf2tfm-segfault.patch 671 RMD160 bdb25be0640ee446550e8744b17572ea332d3f39 SHA1 0038e8634071501a6a0b8799b5256beae86616a8 SHA256 bfe6248b29cad47dd74b0eb42d7952bf7cd45e9f4e57248d66f76631a5ba7ca7
+AUX freetype-1.4_pre20080316-CVE-2006-1861.patch 545 RMD160 76ca8cb30fa0b98148056dc1c9be12ab641268a0 SHA1 d87a148c8d1adb8eaf423c5aeaf23755f319cc4b SHA256 c4379377d747b8788099d994d79da29fa59b475bd804da8564865dbd43206cbc
+AUX freetype-1.4_pre20080316-CVE-2007-2754.patch 486 RMD160 c25be4bfd795ecdaf23f0902dd6a5327587f8b81 SHA1 5e70793d4df12ae2362b930da107aa0fe527b65b SHA256 1577dc97b5103c2c8f9a0a0c2d495d0f853b42c02c58f76000def30bf481b83b
+AUX freetype-1.4_pre20080316-CVE-2008-1808.patch 2595 RMD160 beb43899f15f92a25c32773d7b9618d92e718a06 SHA1 58c9ada82e84ad8c8a0c2209d8642a338cb90f88 SHA256 c78403687ed4519ecc8f53e3eddeaf991ce28a07c80a546a5d9a519b8f333e79
+AUX freetype-1.4_pre20080316-LDLFAGS.patch 1322 RMD160 c8a9123281039e9ae52ba7275452e3a88e0f33fb SHA1 720dbd33eb18fd307b54cf3458a4745aad247d77 SHA256 ce0490240cb78b90fe8c28fa56ca4c379b72aedd2d1c5926a1fcb871e3ab40c4
+AUX freetype-1.4_pre20080316-kpathsea_version.patch 1215 RMD160 b6c5fdc3e5c19038ffd341f2432ea4f9efaff59f SHA1 b9e1f1ebaad73a66ed3bf938289b7df2e10b8bdd SHA256 e95fa815f820fbc1391e49c9406d48dc310838053e174972c437000cc3c646da
+DIST freetype-1.4_pre20080316.tar.bz2 1199805 RMD160 5fb5b0737de968602008991c80dac827ea6fdca0 SHA1 73d4289f509213361b040dc9b649e27f810b133a SHA256 b88e8827dfeebcd0c663cac19c798acbd2f1129eaf89172eb26c3594700316a2
+EBUILD freetype-1.4_pre20080316-r3.ebuild 3887 RMD160 5d873d93d47f676ccf5f7625e21a6c7d87250f07 SHA1 9d3c939fbc821e8152143b8b0803e01a92e8882b SHA256 11c4196ceec3aa1c118a4305f10a93012831ce8982ae645e165fdd4db7d5d9fd
--- /dev/null
+diff -upr freetype.orig/freetype1-contrib/ttf2pk/newobj.c freetype/freetype1-contrib/ttf2pk/newobj.c
+--- freetype.orig/freetype1-contrib/ttf2pk/newobj.c 2002-06-20 22:34:37.000000000 +0500
++++ freetype/freetype1-contrib/ttf2pk/newobj.c 2009-05-19 22:01:07.314923296 +0500
+@@ -128,13 +128,13 @@ get_line(FILE *f)
+
+
+ /*
+- * getline() is a wrapper function for get_line(). It returns `False' in
++ * getline_() is a wrapper function for get_line(). It returns `False' in
+ * case of error and expects a pointer to a buffer to store the current
+ * line. Additionally, the final newline character is stripped.
+ */
+
+ Boolean
+-getline(char **bufferp, FILE *f)
++getline_(char **bufferp, FILE *f)
+ {
+ size_t l;
+
+diff -upr freetype.orig/freetype1-contrib/ttf2pk/newobj.h freetype/freetype1-contrib/ttf2pk/newobj.h
+--- freetype.orig/freetype1-contrib/ttf2pk/newobj.h 2002-01-08 16:48:27.000000000 +0400
++++ freetype/freetype1-contrib/ttf2pk/newobj.h 2009-05-19 22:00:23.324243127 +0500
+@@ -26,7 +26,7 @@ void *mycalloc(size_t len);
+ void *myrealloc(void *oldp, size_t len);
+
+ char *get_line(FILE *f);
+-Boolean getline(char **bufferp, FILE *f);
++Boolean getline_(char **bufferp, FILE *f);
+ char *newstring(char *s);
+
+ ttfinfo *newchar(Font *fnt);
+diff -upr freetype.orig/freetype1-contrib/ttf2pk/parse.c freetype/freetype1-contrib/ttf2pk/parse.c
+--- freetype.orig/freetype1-contrib/ttf2pk/parse.c 2002-03-15 05:33:52.000000000 +0400
++++ freetype/freetype1-contrib/ttf2pk/parse.c 2009-05-19 22:00:58.944122095 +0500
+@@ -63,7 +63,7 @@ gettoken(char **bufferp, size_t *offsetp
+ if (*bufferp)
+ free(*bufferp);
+
+- if (getline(bufferp, f) == False)
++ if (getline_(bufferp, f) == False)
+ oops("Premature end in encoding file.");
+
+ curp = *bufferp;
+@@ -187,7 +187,7 @@ readencoding(char **enc, Font *fnt, Bool
+ "Token 258 in encoding must be make-array (]).");
+ free(p);
+
+- while (getline(&buffer, enc_file))
++ while (getline_(&buffer, enc_file))
+ {
+ for (p = buffer; *p; p++)
+ if (*p == '%')
+@@ -246,7 +246,7 @@ get_replacements(Font *fnt)
+ if (replacement_file == NULL)
+ oops("Cannot open replacement file `%s'.", real_replacement_name);
+
+- while (getline(&buffer, replacement_file))
++ while (getline_(&buffer, replacement_file))
+ {
+ for (p = buffer; *p; p++)
+ if (*p == '%')
--- /dev/null
+diff -Naur freetype-orig/freetype1-contrib/ttf2bdf/configure.in freetype/freetype1-contrib/ttf2bdf/configure.in
+--- freetype-orig/freetype1-contrib/ttf2bdf/configure.in 2000-04-14 11:53:50.000000000 -0600
++++ freetype/freetype1-contrib/ttf2bdf/configure.in 2008-03-19 20:24:48.000000000 -0600
+@@ -29,6 +29,7 @@
+ AC_SUBST(XX_CFLAGS)
+
+ AC_CHECK_PROG(RM, rm, rm)
++AC_PROG_INSTALL
+
+ dnl Checks for header files.
+ AC_HEADER_STDC
+diff -Naur freetype-orig/freetype1-contrib/ttf2bdf/Makefile.in freetype/freetype1-contrib/ttf2bdf/Makefile.in
+--- freetype-orig/freetype1-contrib/ttf2bdf/Makefile.in 2001-02-03 11:03:12.000000000 -0600
++++ freetype/freetype1-contrib/ttf2bdf/Makefile.in 2008-03-19 20:24:15.000000000 -0600
+@@ -45,6 +45,10 @@
+ bindir = @bindir@
+ mandir = @mandir@
+
++INSTALL = @INSTALL@
++INSTALL_DATA = @INSTALL_DATA@
++INSTALL_PROGRAM = @INSTALL_PROGRAM@
++
+ all: ttf2bdf
+
+ ttf2bdf: $(OBJS)
+@@ -63,9 +67,9 @@
+ $(CC) $(CFLAGS) $(INCS) -c $< -o $@
+
+ install: ttf2bdf
+- @$(MKINSTALLDIRS) $(bindir) $(mandir)/man1
+- @cp ttf2bdf $(bindir)/ttf2bdf
+- @cp ttf2bdf.man $(mandir)/man1/ttf2bdf.1
++ @$(MKINSTALLDIRS) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
++ @$(INSTALL_PROGRAM) ttf2bdf $(DESTDIR)$(bindir)/ttf2bdf
++ @$(INSTALL_DATA) ttf2bdf.man $(DESTDIR)$(mandir)/man1/ttf2bdf.1
+
+ uninstall:
+ @$(RM) -f $(bindir)/ttf2bdf
+diff -Naur freetype-orig/freetype1-contrib/ttf2pfb/Makefile.in freetype/freetype1-contrib/ttf2pfb/Makefile.in
+--- freetype-orig/freetype1-contrib/ttf2pfb/Makefile.in 2000-04-14 11:53:50.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pfb/Makefile.in 2008-03-19 20:24:15.000000000 -0600
+@@ -32,7 +32,7 @@
+
+ SRC = t1asm.c ttf2pfb.c
+
+-PROGRAMS = t1asm ttf2pfb
++PROGRAMS = ttf2pfb
+
+ default all: $(PROGRAMS)
+
+@@ -58,11 +58,10 @@
+ $(CC) -c $(FT_CFLAGS) $<
+
+ install: $(PROGRAMS)
+- $(MKINSTALLDIRS) $(bindir)
++ $(MKINSTALLDIRS) $(DESTDIR)$(bindir)
+ for P in $(PROGRAMS) ; do \
+- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
++ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(DESTDIR)$(bindir)/$$P ; \
+ done
+- $(INSTALL_PROGRAM) $(srcdir)/getafm $(bindir)/getafm
+
+ uninstall:
+ -for P in $(PROGRAMS) ; do \
+diff -Naur freetype-orig/freetype1-contrib/ttf2pk/Makefile.in freetype/freetype1-contrib/ttf2pk/Makefile.in
+--- freetype-orig/freetype1-contrib/ttf2pk/Makefile.in 2001-02-03 11:03:12.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/Makefile.in 2008-03-19 20:24:15.000000000 -0600
+@@ -69,10 +69,10 @@
+ $(LIBDIR)/libttf.la $(LDFLAGS)
+
+ install: $(PROGRAMS)
+- $(MKINSTALLDIRS) $(bindir) $(mandir)/man1
++ $(MKINSTALLDIRS) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
+ for P in $(PROGRAMS) ; do \
+- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
+- $(INSTALL_DATA) $(srcdir)/$$P.1 $(mandir)/man1 ; \
++ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(DESTDIR)$(bindir)/$$P ; \
++ $(INSTALL_DATA) $(srcdir)/$$P.1 $(DESTDIR)$(mandir)/man1 ; \
+ done
+
+ uninstall:
+diff -Naur freetype-orig/freetype1-contrib/ttfbanner/Makefile.in freetype/freetype1-contrib/ttfbanner/Makefile.in
+--- freetype-orig/freetype1-contrib/ttfbanner/Makefile.in 2000-04-14 11:53:50.000000000 -0600
++++ freetype/freetype1-contrib/ttfbanner/Makefile.in 2008-03-19 20:24:15.000000000 -0600
+@@ -53,8 +53,8 @@
+ $(CC) -c $(FT_CFLAGS) $<
+
+ install: ttfbanner
+- $(MKINSTALLDIRS) $(bindir)
+- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ttfbanner $(bindir)/
++ $(MKINSTALLDIRS) $(DESTDIR)$(bindir)
++ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) ttfbanner $(DESTDIR)$(bindir)
+
+ uninstall:
+ $(LIBTOOL) --mode=uninstall $(RM) $(bindir)/ttfbanner
--- /dev/null
+https://bugs.gentoo.org/show_bug.cgi?id=104016
+
+diff -Naurp freetype-orig/freetype1-contrib/ttfbanner/ttfbanner.c freetype/freetype1-contrib/ttfbanner/ttfbanner.c
+--- freetype-orig/freetype1-contrib/ttfbanner/ttfbanner.c 2008-03-18 18:16:36.000000000 -0600
++++ freetype/freetype1-contrib/ttfbanner/ttfbanner.c 2008-03-18 18:16:22.000000000 -0600
+@@ -4,7 +4,6 @@
+
+ #include <stdlib.h>
+ #include <stdio.h>
+-#include <malloc.h>
+ #include <string.h>
+ #include "freetype.h"
+ #include "ttfbanner.h"
--- /dev/null
+diff -Naurp freetype-orig/lib/extend/ftxgdef.c freetype/lib/extend/ftxgdef.c
+--- freetype-orig/lib/extend/ftxgdef.c 2002-01-18 18:23:23.000000000 -0600
++++ freetype/lib/extend/ftxgdef.c 2008-03-18 19:04:49.000000000 -0600
+@@ -142,7 +142,7 @@
+ if ( !faze )
+ return TT_Err_Invalid_Face_Handle;
+
+- error = TT_Extension_Get( faze, GDEF_ID, (void**)&gdef );
++ error = TT_Extension_Get( faze, GDEF_ID, (void**)(void*)&gdef );
+ if ( error )
+ return error;
+
+diff -Naurp freetype-orig/lib/extend/ftxgpos.c freetype/lib/extend/ftxgpos.c
+--- freetype-orig/lib/extend/ftxgpos.c 2002-09-26 02:40:00.000000000 -0600
++++ freetype/lib/extend/ftxgpos.c 2008-03-18 19:04:49.000000000 -0600
+@@ -184,7 +184,7 @@
+ if ( !faze )
+ return TT_Err_Invalid_Face_Handle;
+
+- error = TT_Extension_Get( faze, GPOS_ID, (void**)&gpos );
++ error = TT_Extension_Get( faze, GPOS_ID, (void**)(void*)&gpos );
+ if ( error )
+ return error;
+
+@@ -283,7 +283,7 @@
+
+ /* copy the class definition pointer into the extension structure */
+
+- error = TT_Extension_Get( faze, GDEF_ID, (void**)&gdef_reg );
++ error = TT_Extension_Get( faze, GDEF_ID, (void**)(void*)&gdef_reg );
+ if ( error )
+ return error;
+
+diff -Naurp freetype-orig/lib/extend/ftxgsub.c freetype/lib/extend/ftxgsub.c
+--- freetype-orig/lib/extend/ftxgsub.c 2002-09-26 02:40:00.000000000 -0600
++++ freetype/lib/extend/ftxgsub.c 2008-03-18 19:04:49.000000000 -0600
+@@ -264,7 +264,7 @@
+ if ( !faze )
+ return TT_Err_Invalid_Face_Handle;
+
+- error = TT_Extension_Get( faze, GSUB_ID, (void**)&gsub );
++ error = TT_Extension_Get( faze, GSUB_ID, (void**)(void*)&gsub );
+ if ( error )
+ return error;
+
+@@ -363,7 +363,7 @@
+
+ /* copy the class definition pointer into the extension structure */
+
+- error = TT_Extension_Get( faze, GDEF_ID, (void**)&gdef_reg );
++ error = TT_Extension_Get( faze, GDEF_ID, (void**)(void*)&gdef_reg );
+ if ( error )
+ return error;
+
+diff -Naurp freetype-orig/lib/extend/ftxkern.c freetype/lib/extend/ftxkern.c
+--- freetype-orig/lib/extend/ftxkern.c 2002-03-14 19:33:53.000000000 -0600
++++ freetype/lib/extend/ftxkern.c 2008-03-18 19:04:49.000000000 -0600
+@@ -545,7 +545,7 @@
+ return TT_Err_Invalid_Face_Handle;
+
+ /* copy directory header */
+- error = TT_Extension_Get( faze, KERNING_ID, (void**)&kerning );
++ error = TT_Extension_Get( faze, KERNING_ID, (void**)(void*)&kerning );
+ if ( !error )
+ *directory = *kerning;
+
+@@ -584,7 +584,7 @@
+ if ( !faze )
+ return TT_Err_Invalid_Face_Handle;
+
+- error = TT_Extension_Get( faze, KERNING_ID, (void**)&kern );
++ error = TT_Extension_Get( faze, KERNING_ID, (void**)(void*)&kern );
+ if ( error )
+ return error;
+
+diff -Naurp freetype-orig/lib/extend/ftxpost.c freetype/lib/extend/ftxpost.c
+--- freetype-orig/lib/extend/ftxpost.c 2002-07-20 15:24:26.000000000 -0600
++++ freetype/lib/extend/ftxpost.c 2008-03-18 19:04:49.000000000 -0600
+@@ -404,7 +404,7 @@
+ if ( !faze )
+ return TT_Err_Invalid_Face_Handle;
+
+- error = TT_Extension_Get( faze, POST_ID, (void**)&post );
++ error = TT_Extension_Get( faze, POST_ID, (void**)(void*)&post );
+ if ( error )
+ return error;
+
+@@ -494,7 +494,7 @@
+ if ( index >= faze->numGlyphs )
+ return TT_Err_Invalid_Glyph_Index;
+
+- error = TT_Extension_Get( faze, POST_ID, (void**)&post );
++ error = TT_Extension_Get( faze, POST_ID, (void**)(void*)&post );
+ if ( error )
+ return error;
+
+diff -Naurp freetype-orig/lib/extend/ftxsbit.c freetype/lib/extend/ftxsbit.c
+--- freetype-orig/lib/extend/ftxsbit.c 2002-01-18 18:23:24.000000000 -0600
++++ freetype/lib/extend/ftxsbit.c 2008-03-18 19:04:49.000000000 -0600
+@@ -1145,7 +1145,7 @@
+ TT_Error error;
+
+
+- error = TT_Extension_Get( faze, SBIT_ID, (void**)&eblc );
++ error = TT_Extension_Get( faze, SBIT_ID, (void**)(void*)&eblc );
+ if ( !error )
+ {
+ if ( eblc->version )
+@@ -1200,7 +1200,7 @@
+ if ( !strike || !ins || ins->owner != faze )
+ return TT_Err_Invalid_Argument;
+
+- error = TT_Extension_Get( faze, SBIT_ID, (void**)&eblc );
++ error = TT_Extension_Get( faze, SBIT_ID, (void**)(void*)&eblc );
+ if ( error )
+ goto Exit;
+
+diff -Naurp freetype-orig/lib/ttapi.c freetype/lib/ttapi.c
+--- freetype-orig/lib/ttapi.c 2002-11-15 03:42:15.000000000 -0600
++++ freetype/lib/ttapi.c 2008-03-18 19:04:49.000000000 -0600
+@@ -598,7 +598,7 @@
+
+ for ( n = 0; n <= num; n++ )
+ {
+- TT_Get_Metrics( (TT_Horizontal_Header*)&_face->verticalHeader,
++ TT_Get_Metrics( (TT_Horizontal_Header*)(void*)&_face->verticalHeader,
+ firstGlyph + n, &top_bearing, &advance_height );
+
+ if ( topBearings ) topBearings[n] = top_bearing;
+diff -Naurp freetype-orig/lib/ttcache.h freetype/lib/ttcache.h
+--- freetype-orig/lib/ttcache.h 2002-03-14 19:33:52.000000000 -0600
++++ freetype/lib/ttcache.h 2008-03-18 19:04:49.000000000 -0600
+@@ -192,7 +192,7 @@
+ Cache_Done( TCache* cache, void* data );
+
+ #define CACHE_New( _cache, _newobj, _parent ) \
+- Cache_New( (TCache*)_cache, (void**)&_newobj, (void*)_parent )
++ Cache_New( (TCache*)_cache, (void**)(void*)&_newobj, (void*)_parent )
+
+ #define CACHE_Done( _cache, _obj ) \
+ Cache_Done( (TCache*)_cache, (void*)_obj )
+diff -Naurp freetype-orig/lib/ttgload.c freetype/lib/ttgload.c
+--- freetype-orig/lib/ttgload.c 2002-03-14 19:33:52.000000000 -0600
++++ freetype/lib/ttgload.c 2008-03-18 19:04:49.000000000 -0600
+@@ -1251,7 +1251,7 @@
+ /* Don't assume that both the vertical header and vertical */
+ /* metrics are present in the same font :-) */
+
+- TT_Get_Metrics( (TT_Horizontal_Header*)&face->verticalHeader,
++ TT_Get_Metrics( (TT_Horizontal_Header*)(void*)&face->verticalHeader,
+ glyph_index,
+ &top_bearing,
+ &advance_height );
+diff -Naurp freetype-orig/lib/ttload.c freetype/lib/ttload.c
+--- freetype-orig/lib/ttload.c 2003-11-05 15:47:14.000000000 -0600
++++ freetype/lib/ttload.c 2008-03-18 19:04:49.000000000 -0600
+@@ -533,8 +533,8 @@
+ }
+
+ num_longs = face->verticalHeader.number_Of_VMetrics;
+- longs = (PLongMetrics*)&face->verticalHeader.long_metrics;
+- shorts = (PShortMetrics*)&face->verticalHeader.short_metrics;
++ longs = (PLongMetrics*)(void*)&face->verticalHeader.long_metrics;
++ shorts = (PShortMetrics*)(void*)&face->verticalHeader.short_metrics;
+ }
+ else
+ {
+@@ -545,8 +545,8 @@
+ }
+
+ num_longs = face->horizontalHeader.number_Of_HMetrics;
+- longs = (PLongMetrics*)&face->horizontalHeader.long_metrics;
+- shorts = (PShortMetrics*)&face->horizontalHeader.short_metrics;
++ longs = (PLongMetrics*)(void*)&face->horizontalHeader.long_metrics;
++ shorts = (PShortMetrics*)(void*)&face->horizontalHeader.short_metrics;
+ }
+
+ /* never trust derived values! */
+@@ -647,7 +647,7 @@
+ return TT_Err_Ok;
+
+ face->verticalInfo = 1;
+- header = (TT_Horizontal_Header*)&face->verticalHeader;
++ header = (TT_Horizontal_Header*)(void*)&face->verticalHeader;
+ }
+ else
+ {
+diff -Naurp freetype-orig/lib/ttmemory.h freetype/lib/ttmemory.h
+--- freetype-orig/lib/ttmemory.h 2002-03-14 19:33:52.000000000 -0600
++++ freetype/lib/ttmemory.h 2008-03-18 19:04:49.000000000 -0600
+@@ -54,10 +54,10 @@
+
+
+ #define MEM_Alloc( _pointer_, _size_ ) \
+- TT_Alloc( _size_, (void**)&(_pointer_) )
++ TT_Alloc( _size_, (void**)(void*)&(_pointer_) )
+
+ #define MEM_Realloc( _pointer_, _size_ ) \
+- TT_Realloc( _size_, (void**)&(_pointer_) )
++ TT_Realloc( _size_, (void**)(void*)&(_pointer_) )
+
+ #define ALLOC( _pointer_, _size_ ) \
+ ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok )
+@@ -74,7 +74,7 @@
+ (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok )
+
+ #define FREE( _pointer_ ) \
+- TT_Free( (void**)&(_pointer_) )
++ TT_Free( (void**)(void*)&(_pointer_) )
+
+
+ /* Allocate a block of memory of 'Size' bytes from the heap, and */
+diff -Naurp freetype-orig/lib/ttobjs.c freetype/lib/ttobjs.c
+--- freetype-orig/lib/ttobjs.c 2002-03-14 19:33:52.000000000 -0600
++++ freetype/lib/ttobjs.c 2008-03-18 19:04:49.000000000 -0600
+@@ -550,14 +550,14 @@
+
+ error = Update_Max( &exec->loadSize,
+ sizeof ( TSubglyph_Record ),
+- (void**)&exec->loadStack,
++ (void**)(void*)&exec->loadStack,
+ face->maxComponents + 1 );
+ if ( error )
+ return error;
+
+ error = Update_Max( &exec->stackSize,
+ sizeof ( TT_F26Dot6 ),
+- (void**)&exec->stack,
++ (void**)(void*)&exec->stack,
+ maxp->maxStackElements + 32 );
+ /* XXX : We reserve a little more elements on the stack to deal safely */
+ /* with broken fonts like arialbs, courbs, timesbs... */
+@@ -566,7 +566,7 @@
+
+ error = Update_Max( &exec->glyphSize,
+ sizeof ( Byte ),
+- (void**)&exec->glyphIns,
++ (void**)(void*)&exec->glyphIns,
+ maxp->maxSizeOfInstructions );
+ if ( error )
+ return error;
--- /dev/null
+http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=344439
+
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/filesrch.c freetype/freetype1-contrib/ttf2pk/filesrch.c
+--- freetype-orig/freetype1-contrib/ttf2pk/filesrch.c 2002-01-08 06:48:27.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/filesrch.c 2008-03-17 19:19:41.000000000 -0600
+@@ -96,7 +96,7 @@ TeX_search_encoding_file(char **name)
+ return kpse_find_file(*name, kpse_tex_ps_header_format, True);
+ #endif
+ #else
+- return kpse_find_file(*name, kpse_program_text_format, True);
++ return kpse_find_file(*name, kpse_enc_format, True);
+ #endif
+ }
+
+@@ -113,7 +113,7 @@ TeX_search_replacement_file(char **name)
+ return kpse_find_file(*name, kpse_tex_ps_header_format, True);
+ #endif
+ #else
+- return kpse_find_file(*name, kpse_program_text_format, True);
++ return kpse_find_file(*name, kpse_sfd_format, True);
+ #endif
+ }
+
+@@ -147,7 +147,7 @@ TeX_search_map_file(char **name)
+ return kpse_find_file(*name, kpse_tex_ps_header_format, True);
+ #endif
+ #else
+- return kpse_find_file(*name, kpse_program_text_format, True);
++ return kpse_find_file(*name, kpse_fontmap_format, True);
+ #endif
+ }
+
+@@ -197,9 +197,11 @@ TeX_search_ttf_file(char **name)
+
+ #else /* OLD_KPATHSEA */
+
+- /* no extra extension handling necessary */
+-
+- return kpse_find_file(*name, kpse_truetype_format, True);
++ char* real_name;
++ real_name= kpse_find_file(*name, kpse_truetype_format, True);
++ if (!real_name)
++ real_name= kpse_find_file(*name, kpse_program_binary_format, True);
++ return real_name;
+
+ #endif
+ }
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/newobj.c freetype/freetype1-contrib/ttf2pk/newobj.c
+--- freetype-orig/freetype1-contrib/ttf2pk/newobj.c 2002-06-20 11:34:37.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/newobj.c 2008-03-17 19:29:06.000000000 -0600
+@@ -202,6 +202,8 @@ newchar(Font *fnt)
+ ti->dptr = 0;
+ ti->iptr = 0;
+
++ ti->fntnum = -1;
++
+ fnt->charlist = ti;
+
+ return ti;
+@@ -313,6 +315,10 @@ init_font_structure(Font *fnt)
+ fnt->codingscheme = default_codingscheme;
+ fnt->titlebuf = NULL;
+
++ fnt->cksum = 0;
++ fnt->subfont_num = 0;
++ fnt->subfont_list = NULL;
++
+ fnt->units_per_em = 0;
+ fnt->italicangle = 0.0;
+ fnt->fixedpitch = 0;
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/subfont.c freetype/freetype1-contrib/ttf2pk/subfont.c
+--- freetype-orig/freetype1-contrib/ttf2pk/subfont.c 2002-03-14 19:33:52.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/subfont.c 2008-03-17 19:29:06.000000000 -0600
+@@ -35,7 +35,7 @@ static realsubfont *real_sfd_name = NULL
+ static realsubfont *
+ really_init_sfd(char *name, Boolean fatal);
+ static Boolean
+-really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf);
++really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf, Boolean new_sfd);
+ static void
+ really_close_sfd(realsubfont *real_name);
+
+@@ -163,14 +163,14 @@ really_init_sfd(char *name, Boolean fata
+ Boolean get_sfd(Font *fnt, Boolean is_sfd)
+ {
+ if (is_sfd)
+- return really_get_sfd(fnt, False, real_sfd_name);
++ return really_get_sfd(fnt, False, real_sfd_name, True);
+ else
+- return really_get_sfd(fnt, False, real_lig_name);
++ return really_get_sfd(fnt, False, real_lig_name, False);
+ }
+
+
+ static Boolean
+-really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf)
++really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf, Boolean new_sfd)
+ {
+ long i, offset;
+ long begin, end = -1;
+@@ -229,7 +229,7 @@ again:
+ if (*bufp == '\0')
+ oops("Invalid subfont entry in `%s'.", rsf->name);
+
+- if (next)
++ if (next || !new_sfd)
+ {
+ if (strcmp(fnt->subfont_name, buffer))
+ goto again;
+@@ -309,7 +309,7 @@ again:
+
+ if (!next)
+ while ((rsf = rsf->next))
+- (void)really_get_sfd(fnt, True, rsf);
++ (void)really_get_sfd(fnt, True, rsf, new_sfd);
+
+ return True;
+ }
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/tfmaux.c freetype/freetype1-contrib/ttf2pk/tfmaux.c
+--- freetype-orig/freetype1-contrib/ttf2pk/tfmaux.c 2002-01-08 06:48:27.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/tfmaux.c 2008-03-17 19:29:06.000000000 -0600
+@@ -283,7 +283,6 @@ buildtfm(Font *fnt)
+ register int i, j;
+ register ttfinfo *ti;
+ int byte1, old_byte1, byte2;
+- long cksum;
+ double Slant;
+ char buffer[256];
+ struct sf sf_array[256];
+@@ -366,8 +365,8 @@ buildtfm(Font *fnt)
+ }
+
+ header = (long *)mymalloc(40000L);
+- cksum = checksum(fnt->inencptrs);
+- header[0] = cksum;
++ fnt->cksum = checksum(fnt->inencptrs);
++ header[0] = fnt->cksum;
+ header[1] = 0xA00000; /* 10pt design size */
+
+ (void)makebcpl(header + 2, fnt->codingscheme, 39);
+@@ -510,7 +509,8 @@ buildtfm(Font *fnt)
+ old_byte1 = byte1;
+ nl++;
+ }
+- ligkern[nl - 1] |= 0x80000000L;
++ if (nl > 0)
++ ligkern[nl - 1] |= 0x80000000L;
+ }
+
+ kerns = ligkern + nl;
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/ttf2tfm.c freetype/freetype1-contrib/ttf2pk/ttf2tfm.c
+--- freetype-orig/freetype1-contrib/ttf2pk/ttf2tfm.c 2002-06-20 11:34:37.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/ttf2tfm.c 2008-03-17 19:29:06.000000000 -0600
+@@ -235,6 +235,37 @@ end:
+ }
+
+
++#define MAX_SFLIST 10
++static void
++add_subfont_list(Font *fnt)
++{
++ if (fnt->subfont_list == NULL)
++ fnt->subfont_list = (sflist *)mymalloc(MAX_SFLIST * sizeof(sflist));
++ else if (fnt->subfont_num % MAX_SFLIST == 0)
++ fnt->subfont_list = (sflist *)myrealloc(fnt->subfont_list,
++ (fnt->subfont_num / MAX_SFLIST + 1) * MAX_SFLIST * sizeof(sflist));
++
++ (fnt->subfont_list[fnt->subfont_num]).name =
++ (char *)mymalloc(strlen(fnt->fullname)+1);
++ strcpy((fnt->subfont_list[fnt->subfont_num]).name, fnt->fullname);
++ (fnt->subfont_list[fnt->subfont_num]).cksum = fnt->cksum;
++
++ fnt->subfont_num++;
++}
++
++
++static void
++release_subfont_list(Font *fnt)
++{
++ register int i;
++
++ for (i = 0; i < fnt->subfont_num; i++)
++ free((fnt->subfont_list[i]).name);
++
++ free(fnt->subfont_list);
++}
++
++
+ #define VERSION "\
+ Copyright (C) 1997-1999, 2000, 2002 Frederic Loyer and Werner Lemberg.\n\
+ There is NO warranty. You may redistribute this software\n\
+@@ -251,6 +282,7 @@ and the FreeType project from\n\
+ David Turner, Robert Wilhelm, and Werner Lemberg.\n\
+ "
+
++
+ static void
+ version(void)
+ {
+@@ -272,6 +304,7 @@ version(void)
+ -L LIGFILE[.sfd] create 1st/2nd byte ligatures in subfonts using LIGFILE\n\
+ -n use PS names of TrueType font\n\
+ -N use only PS names and no cmap\n\
++-o FILE[.ovp] make an OVP file for conversion to OVF and OFM\n\
+ -O use octal for all character codes in the vpl file\n\
+ -p ENCFILE[.enc] read ENCFILE for the TTF->raw TeX mapping\n\
+ -P INT select INT as the TTF platform ID [3]\n\
+@@ -528,6 +561,15 @@ handle_options(int argc, char *argv[], F
+ arginc = 1;
+ break;
+
++ case 'o':
++ if (argc <= 3)
++ oops("Missing parameter for -o option.");
++ if (vpl_name)
++ free(vpl_name);
++ vpl_name = newstring(argv[3]);
++ handle_extension(&vpl_name, ".ovp");
++ break;
++
+ default:
+ if (argc <= 3 || argv[3][0] == '-')
+ {
+@@ -664,6 +706,9 @@ handle_options(int argc, char *argv[], F
+ warning("Ignoring `-v' and `-V' switches for subfonts.");
+ makevpl = 0;
+ }
++ if (vpl_name)
++ if ((fnt->vplout = fopen(vpl_name, "wt")) == NULL)
++ oops("Cannot open ovp output file.");
+ if (have_capheight)
+ warning("Ignoring `-c' switch for subfonts.");
+ if (fnt->inencname || fnt->outencname)
+@@ -890,10 +935,19 @@ main(int argc, char *argv[])
+ writetfm(&font);
+ if (font.write_enc)
+ writeenc(&font);
++ if (font.vplout)
++ add_subfont_list(&font);
+ }
+ }
+
+ close_sfd();
++
++ if (font.vplout)
++ {
++ writeovp(&font);
++ fclose(font.vplout);
++ release_subfont_list(&font);
++ }
+ }
+ else
+ {
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/ttf2tfm.h freetype/freetype1-contrib/ttf2pk/ttf2tfm.h
+--- freetype-orig/freetype1-contrib/ttf2pk/ttf2tfm.h 2002-01-08 06:48:27.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/ttf2tfm.h 2008-03-17 19:29:06.000000000 -0600
+@@ -54,7 +54,8 @@ struct _pcc;
+ typedef struct _pcc pcc;
+ struct _stringlist;
+ typedef struct _stringlist stringlist;
+-
++struct _sflist;
++typedef struct _sflist sflist;
+
+
+ struct _ttfinfo
+@@ -77,6 +78,8 @@ struct _ttfinfo
+ pcc *pccs; /* we use the composite feature for */
+ /* `germandbls' <--> `SS' only */
+ unsigned char wptr, hptr, dptr, iptr;
++
++ short fntnum;
+ };
+
+
+@@ -120,6 +123,13 @@ struct _stringlist
+ };
+
+
++struct _sflist
++{
++ char *name;
++ long cksum;
++};
++
++
+ struct _Font
+ {
+ char *ttfname;
+@@ -187,6 +197,11 @@ struct _Font
+ char *codingscheme; /* coding scheme for TeX */
+ char *titlebuf;
+
++ long cksum;
++
++ short subfont_num;
++ sflist *subfont_list;
++
+ /*
+ * The name of the subfont definition file.
+ */
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/ttfaux.c freetype/freetype1-contrib/ttf2pk/ttfaux.c
+--- freetype-orig/freetype1-contrib/ttf2pk/ttfaux.c 2003-11-05 06:19:02.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/ttfaux.c 2008-03-17 19:29:06.000000000 -0600
+@@ -562,6 +562,8 @@ readttf(Font *fnt, Boolean quiet, Boolea
+ ti->urx = bbox.xMax * 1000 / fnt->units_per_em;
+ ti->ury = bbox.yMax * 1000 / fnt->units_per_em;
+
++ ti->fntnum = fnt->subfont_num;
++
+ /*
+ * We must now shift the rotated character both horizontally
+ * and vertically. The vertical amount is 25% by default.
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/vplaux.c freetype/freetype1-contrib/ttf2pk/vplaux.c
+--- freetype-orig/freetype1-contrib/ttf2pk/vplaux.c 2002-11-15 03:41:24.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/vplaux.c 2008-03-17 19:29:06.000000000 -0600
+@@ -568,4 +568,117 @@ writevpl(Font *fnt, char makevpl, Boolea
+ }
+
+
++void
++writeovp(Font *fnt)
++{
++ register int i;
++ register ttfinfo *ti;
++ long bc, ec;
++ char header[256];
++ float Slant;
++ ttfinfo *ofm_array[65536];
++
++
++ out = fnt->vplout;
++
++ header[0] = '\0';
++ strncat(header, "Created by `", 12);
++ strncat(header, fnt->titlebuf, 255 - 12 - 1);
++ strncat(header, "'", 1);
++
++ voutln2("(VTITLE %s)", header);
++ voutln("(COMMENT Please change VTITLE if you edit this file)");
++
++ voutln("(OFMLEVEL H 1)");
++ voutln("(FONTDIR TL)");
++ voutln2("(FAMILY %s)", fnt->outname);
++ voutln("(FACE F MRR)");
++ voutln("(CODINGSCHEME UNSPECIFIED)");
++ voutln("(DESIGNSIZE R 10.0)");
++ voutln("(DESIGNUNITS R 1000)");
++ voutln("(COMMENT DESIGNSIZE (1 em) IS IN POINTS)");
++ voutln("(COMMENT OTHER DIMENSIONS ARE MULTIPLES OF DESIGNSIZE/1000)");
++
++#if 0
++ /* Let vptovf compute the checksum. */
++ voutln2("(CHECKSUM O %lo)", cksum ^ 0xFFFFFFFF);
++#endif
++
++ vleft(&level);
++ voutln("FONTDIMEN");
++
++ Slant = fnt->slant - fnt->efactor * tan(fnt->italicangle * (PI / 180.0));
++
++ if (Slant)
++ voutln2("(SLANT R %f)", Slant);
++ voutln2("(SPACE D %d)", fnt->fontspace);
++ if (!fnt->fixedpitch)
++ {
++ voutln2("(STRETCH D %d)", transform(200, 0, fnt->efactor, fnt->slant));
++ voutln2("(SHRINK D %d)", transform(100, 0, fnt->efactor, fnt->slant));
++ }
++ voutln2("(XHEIGHT D %d)", fnt->xheight);
++ voutln2("(QUAD D %d)", transform(1000, 0, fnt->efactor, fnt->slant));
++ voutln2("(EXTRASPACE D %d)",
++ fnt->fixedpitch ? fnt->fontspace :
++ transform(111, 0, fnt->efactor, fnt->slant));
++ vright(&level);
++
++ for (i = 0; i < fnt->subfont_num; i++)
++ {
++ vleft(&level);
++ voutln2("MAPFONT D %d", i);
++ voutln2("(FONTNAME %s)", (fnt->subfont_list[i]).name);
++ voutln2("(FONTCHECKSUM O %lo)", (fnt->subfont_list[i]).cksum);
++ vright(&level);
++ }
++
++ for (i = 0; i <= 0xFFFF; i++)
++ ofm_array[i] = NULL;
++
++ for (ti = fnt->charlist; ti != NULL; ti = ti->next)
++ if (ti->charcode >= 0 && ti->charcode <= 0xFFFF)
++ ofm_array[ti->charcode] = ti;
++
++ for (i = 0; i <= 0xFFFF && ofm_array[i] == NULL; i++)
++ ;
++ bc = i;
++ for (i = 0xFFFF; i >= 0 && ofm_array[i] == NULL; i--)
++ ;
++ ec = i;
++
++ if (ec < bc)
++ oops("No TTF characters.");
++
++ for (i = bc; i <= ec; i++)
++ {
++ if ((ti = ofm_array[i]) == NULL) continue;
++
++ vleft(&level);
++ fprintf(out, "CHARACTER H %X\n ", ti->charcode);
++
++ voutln2("(CHARWD R %d)", ti->width);
++ if (ti->ury)
++ voutln2("(CHARHT R %d)", ti->ury);
++ if (ti->lly)
++ voutln2("(CHARDP R %d)", -ti->lly);
++ if (ti->urx > ti->width)
++ voutln2("(CHARIC R %d)", ti->urx - ti->width);
++
++ vleft(&level);
++ voutln("MAP");
++ if (ti->fntnum)
++ voutln2("(SELECTFONT D %d)", ti->fntnum);
++
++ voutln2("(SETCHAR H %X)", (unsigned)ti->incode);
++ vright(&level);
++
++ vright(&level);
++ }
++
++ if (level)
++ oops("I forgot to match the parentheses.");
++}
++
++
+ /* end */
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/vplaux.h freetype/freetype1-contrib/ttf2pk/vplaux.h
+--- freetype-orig/freetype1-contrib/ttf2pk/vplaux.h 2002-01-08 06:48:27.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/vplaux.h 2008-03-17 19:29:06.000000000 -0600
+@@ -16,6 +16,7 @@
+
+ void writevpl(Font *fnt, char makevpl, Boolean forceoctal);
+ void upmap(Font *fnt);
++void writeovp(Font *fnt);
+
+ #endif /* VPLAUX_H */
+
--- /dev/null
+https://bugs.gentoo.org/show_bug.cgi?id=209303
+http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=395341
+
+diff -Naurp freetype-orig/freetype1-contrib/ttf2pk/ttfaux.c freetype/freetype1-contrib/ttf2pk/ttfaux.c
+--- freetype-orig/freetype1-contrib/ttf2pk/ttfaux.c 2008-03-18 18:19:30.000000000 -0600
++++ freetype/freetype1-contrib/ttf2pk/ttfaux.c 2008-03-18 18:33:22.000000000 -0600
+@@ -135,7 +135,7 @@ readttf(Font *fnt, Boolean quiet, Boolea
+ static Boolean initialized = False;
+
+ TT_UShort in_string[2];
+- TTO_GSUB_String in, out;
++ static TTO_GSUB_String in, out;
+
+ TT_UShort script_index, language_index, feature_index;
+ TT_UShort req_feature_index = 0xFFFF;
--- /dev/null
+diff -up freetype-pre1.4/lib/ttgload.c.freetype-pre1.4-CVE-2006-1861-null-pointer freetype-pre1.4/lib/ttgload.c
+--- freetype-pre1.4/lib/ttgload.c.freetype-pre1.4-CVE-2006-1861-null-pointer 2009-05-12 19:40:52.000000000 -0400
++++ freetype-pre1.4/lib/ttgload.c 2009-05-12 19:41:03.000000000 -0400
+@@ -270,6 +270,10 @@
+ j = 0;
+ flag = exec->pts.touch;
+
++ /* CVE-2006-1861 */
++ if ( flag == NULL )
++ return TT_Err_Invalid_Composite; /* for lack of a better err code */
++
+ while ( j < n_points )
+ {
+ Byte c, cnt;
--- /dev/null
+diff -up freetype-pre1.4/lib/ttgload.c.ttf-overflow freetype-pre1.4/lib/ttgload.c
+--- freetype-pre1.4/lib/ttgload.c.ttf-overflow 2009-05-12 19:25:25.000000000 -0400
++++ freetype-pre1.4/lib/ttgload.c 2009-05-12 19:28:15.000000000 -0400
+@@ -236,7 +236,7 @@
+
+ FORGET_Frame();
+
+- if ( n_points > left_points )
++ if ( n_points < 0 || n_points > left_points )
+ {
+ PTRACE0(( "ERROR: Too many points in glyph %ld\n", subg->index ));
+ return TT_Err_Too_Many_Points;
--- /dev/null
+diff -up freetype-1.3.1/lib/ttfile.c~ freetype-1.3.1/lib/ttfile.c
+--- freetype-1.3.1/lib/ttfile.c~ 2008-06-14 09:51:56.000000000 +0200
++++ freetype-1.3.1/lib/ttfile.c 2008-06-14 09:51:56.000000000 +0200
+@@ -931,6 +931,9 @@
+ EXPORT_FUNC
+ TT_Error TT_Skip_File( STREAM_ARGS Long distance )
+ {
++ if ( distance < 0 )
++ return TT_Err_Invalid_File_Offset;
++
+ return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) -
+ CUR_Stream->base + distance );
+ }
+diff -up freetype-1.3.1/lib/ttinterp.c~ freetype-1.3.1/lib/ttinterp.c
+--- freetype-1.3.1/lib/ttinterp.c~ 2008-06-14 09:56:48.000000000 +0200
++++ freetype-1.3.1/lib/ttinterp.c 2008-06-14 09:56:48.000000000 +0200
+@@ -4144,7 +4144,7 @@
+
+ /* XXX: this is probably wrong... at least it prevents memory */
+ /* corruption when zp2 is the twilight zone */
+- if ( last_point > CUR.zp2.n_points )
++ if ( BOUNDS ( last_point , CUR.zp2.n_points ) )
+ {
+ if ( CUR.zp2.n_points > 0 )
+ last_point = CUR.zp2.n_points - 1;
+diff -up freetype-1.3.1/lib/ttload.c~ freetype-1.3.1/lib/ttload.c
+--- freetype-1.3.1/lib/ttload.c~ 2008-06-14 09:37:02.000000000 +0200
++++ freetype-1.3.1/lib/ttload.c 2008-06-14 09:46:33.000000000 +0200
+@@ -284,6 +284,12 @@
+
+ /* read frame data into face table */
+ maxProfile->version = GET_ULong();
++
++ if (maxProfile->version < 0x10000L)
++ {
++ PERROR(( "!! invalid file format" ));
++ return TT_Err_Invalid_File_Format;
++ }
+
+ maxProfile->numGlyphs = GET_UShort();
+
+@@ -294,6 +300,14 @@
+
+ maxProfile->maxZones = GET_UShort();
+ maxProfile->maxTwilightPoints = GET_UShort();
++ /* we add 4 phantom points later */
++ if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
++ {
++ PERROR(( "Too much twilight points in `maxp' table;\n" ));
++ PERROR(( " some glyphs might be rendered incorrectly.\n" ));
++
++ maxProfile->maxTwilightPoints = 0xFFFFU - 4;
++ }
+
+ maxProfile->maxStorage = GET_UShort();
+ maxProfile->maxFunctionDefs = GET_UShort();
+@@ -330,8 +344,10 @@
+
+ /* We also increase maxPoints and maxContours in order to support */
+ /* some broken fonts. */
+- face->maxPoints += 8;
+- face->maxContours += 4;
++ if ( face->maxPoints < ( 0xFFFFU - 8 ) )
++ face->maxPoints += 8;
++ if ( face->maxContours < ( 0xFFFFU - 4 ) )
++ face->maxContours += 4;
+
+ PTRACE2(( "GASP loaded.\n" ));
+ return TT_Err_Ok;
--- /dev/null
+=== modified file 'configure.in'
+--- configure.in 2009-03-23 12:17:31 +0000
++++ configure.in 2009-03-23 14:15:09 +0000
+@@ -66,7 +66,7 @@
+ dnl NLS/gettext nightmare^H^H^H^H^H^H^H^H^H^H support...
+
+ if test "$USE_NLS" = "yes"; then
+- AC_REQUIRE([AC_PROG_MAKE_SET])
++ AC_PROG_MAKE_SET
+ AC_CHECK_HEADERS(locale.h)
+ AC_CHECK_FUNCS(setlocale)
+ AC_SUBST(HAVE_LOCALE_H)
+
+=== modified file 'freetype1-contrib/ttf2bdf/Makefile.in'
+--- freetype1-contrib/ttf2bdf/Makefile.in 2009-03-23 12:17:31 +0000
++++ freetype1-contrib/ttf2bdf/Makefile.in 2009-03-23 12:25:17 +0000
+@@ -52,7 +52,7 @@
+ all: ttf2bdf
+
+ ttf2bdf: $(OBJS)
+- $(PURIFY) $(CC) $(STATIC) $(CFLAGS) -o ttf2bdf $(OBJS) $(LIBS)
++ $(PURIFY) $(CC) $(LDFLAGS) $(STATIC) $(CFLAGS) -o ttf2bdf $(OBJS) $(LIBS)
+
+ clean:
+ $(RM) -f *.o *BAK *CKP *~ a.out core
+
+=== modified file 'lib/arch/unix/Makefile.in'
+--- lib/arch/unix/Makefile.in 2009-03-23 12:17:31 +0000
++++ lib/arch/unix/Makefile.in 2009-03-23 12:26:37 +0000
+@@ -205,7 +205,7 @@
+ $(SRC_S)
+
+ libttf.la: $(LIB_FILES)
+- $(LIBTOOL) --mode=link $(CC) -o libttf.la $(LIB_FILES) \
++ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o libttf.la $(LIB_FILES) \
+ -rpath $(libdir) \
+ -version-info $(version_info) $(FT_LIBS)
+
+
--- /dev/null
+Include kpathsea/version.h when available. Fixes a build failure with TeX Live
+2010.
+
+Index: freetype/freetype1-contrib/ttf2pk/configure.ac
+===================================================================
+--- freetype.orig/freetype1-contrib/ttf2pk/configure.ac
++++ freetype/freetype1-contrib/ttf2pk/configure.ac
+@@ -58,6 +58,7 @@ if test -n "$kpathsea_include" -o -n "$k
+
+ AC_CHECK_HEADER(kpathsea/c-auto.h, ,[
+ AC_MSG_ERROR([Can't find kpathsea include files! Use --with-kpathsea-include option.])])
++ AC_CHECK_HEADERS([kpathsea/version.h])
+ else
+ CPPFLAGS="$CPPFLAGS -I$srcdir"
+ fi
+Index: freetype/freetype1-contrib/ttf2pk/filesrch.c
+===================================================================
+--- freetype.orig/freetype1-contrib/ttf2pk/filesrch.c
++++ freetype/freetype1-contrib/ttf2pk/filesrch.c
+@@ -34,12 +34,16 @@
+ #include "kpathsea/kpathsea.h"
+ #endif
+
++#ifdef HAVE_KPATHSEA_VERSION_H
++#include <kpathsea/version.h>
++#else
+ #ifdef KPSEDLL
+ /* this is kpathsea 3.3 and newer */
+ extern KPSEDLL char *kpathsea_version_string;
+ #else
+ extern DllImport char *kpathsea_version_string;
+ #endif
++#endif
+
+ /*
+ * Initialize kpathsea library; arguments are the full name of the
--- /dev/null
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/media-libs/freetype/freetype-1.4_pre20080316-r2.ebuild,v 1.8 2011/08/28 17:32:21 grobian Exp $
+
+inherit autotools eutils libtool multilib
+
+DESCRIPTION="Freetype font rendering engine"
+HOMEPAGE="http://www.freetype.org/"
+SRC_URI="mirror://gentoo/${P}.tar.bz2"
+
+LICENSE="FTL"
+SLOT="1"
+KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
+IUSE="doc nls kpathsea"
+
+COMMON_DEPEND="kpathsea? ( virtual/tex-base )"
+RDEPEND="${COMMON_DEPEND}
+ nls? ( sys-devel/gettext )"
+DEPEND="${COMMON_DEPEND}
+ >=sys-devel/autoconf-2.59"
+
+S="${WORKDIR}"/${PN}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ # remove unneeded include for BSD (#104016)
+ epatch "${FILESDIR}"/freetype-1.4_pre-malloc.patch
+
+ # fix ttf2pk to work with tetex 3.0
+ epatch "${FILESDIR}"/freetype-1.4_pre-ttf2pk-tetex-3.patch
+
+ # fix segfault due to undefined behaviour of non-static structs
+ epatch "${FILESDIR}"/freetype-1.4_pre-ttf2tfm-segfault.patch
+
+ # silence strict-aliasing warnings
+ epatch "${FILESDIR}"/freetype-1.4_pre-silence-strict-aliasing.patch
+
+ # add DESTDIR support to contrib Makefiles
+ epatch "${FILESDIR}"/freetype-1.4_pre-contrib-destdir.patch
+
+ epatch "${FILESDIR}"/${P}-CVE-2008-1808.patch #225851
+ epatch "${FILESDIR}"/${P}-LDLFAGS.patch #263131
+ epatch "${FILESDIR}"/${PN}-1.4-glibc-2.10.patch #270460
+
+ epatch "${FILESDIR}"/${P}-CVE-2006-1861.patch #271234
+ epatch "${FILESDIR}"/${P}-CVE-2007-2754.patch #271234
+
+ epatch "${FILESDIR}"/${P}-kpathsea_version.patch #Fix build with TL2010
+
+ # disable tests (they don't compile)
+ sed -i -e "/^all:/ s:tttest ::" Makefile.in
+
+ rm aclocal.m4 # Force recreation
+ # Copying this code from autotools.eclass but avoid autoheader call...
+ eaclocal
+ if ${LIBTOOLIZE:-libtoolize} -n --install >& /dev/null ; then
+ _elibtoolize --copy --force --install
+ else
+ _elibtoolize --copy --force
+ fi
+ eautoconf
+ elibtoolize
+
+ # contrib isn't compatible with autoconf-2.13
+ unset WANT_AUTOCONF
+
+ for x in ttf2bdf ttf2pfb ttf2pk ttfbanner; do
+ cd "${S}"/freetype1-contrib/${x}
+ eautoconf
+ done
+}
+
+src_compile() {
+ use kpathsea && kpathseaconf="--with-kpathsea-lib=${EPREFIX}/usr/$(get_libdir) --with-kpathsea-include=${EPREFIX}/usr/include"
+
+ # core
+ einfo "Building core library..."
+ econf $(use_enable nls) || die "econf failed"
+ emake || die "emake failed"
+
+ # contrib
+ cd "${S}"/freetype1-contrib/ttf2pk
+ einfo "Building ttf2pk..."
+ econf ${kpathseaconf} || die "econf ttf2pk failed"
+ emake || die "emake ttf2pk failed"
+ for x in ttf2bdf ttf2pfb ttfbanner; do
+ cd "${S}"/freetype1-contrib/${x}
+ einfo "Building ${x}..."
+ econf || die "econf ${x} failed"
+ emake || die "emake ${x} failed"
+ done
+}
+
+src_install() {
+ dodoc announce PATENTS README docs/*.txt docs/FAQ
+ use doc && dohtml -r docs
+
+ # core
+ # Seems to require a shared libintl (getetxt comes only with a static one
+ # But it seems to work without problems
+ einfo "Installing core library..."
+ cd "${S}"/lib
+ emake -f arch/unix/Makefile \
+ prefix="${D}"/usr libdir="${D}"/usr/$(get_libdir) install \
+ || die "lib install failed"
+
+ # install po files
+ einfo "Installing po files..."
+ cd "${S}"/po
+ emake prefix="${D}"/usr libdir="${D}"/usr/$(get_libdir) install \
+ || die "po install failed"
+
+ # contrib (DESTDIR now works here)
+ einfo "Installing contrib..."
+ for x in ttf2bdf ttf2pfb ttf2pk ttfbanner; do
+ cd "${S}"/freetype1-contrib/${x}
+ emake DESTDIR="${D}" install || die "${x} install failed"
+ done
+
+ # tex stuff
+ if use kpathsea; then
+ cd "${S}"/freetype1-contrib
+ insinto /usr/share/texmf/ttf2pk
+ doins ttf2pk/data/* || die "kpathsea ttf2pk install failed"
+ insinto /usr/share/texmf/ttf2pfb
+ doins ttf2pfb/Uni-T1.enc || die "kpathsea ttf2pfb install failed"
+ fi
+}