Changes 20110222:

* Did a lot of work to improve the accuracy in remove overlap. Improved
  accuracy means that it is less likely to do the wrong thing. Problems happen
  when there are points or intersections very close to each other.
  (So quadratic glyphs are more likely to have problems than cubics simply
  because they have more points, on average).
* Fix various error messages.
* Remove some obsolete documentation.
* Technical fixes to stroking code.
* Add a miterlimit to stroking code.
* FontForge was using the wrong MIME type for svg files. W3C has changed it and
  it's now "image/svg+xml" not "image/svg-xml" or "image/svg".
* Since Inkscape images tend to be at unexpected y positions, force the view to
  rescale/recenter itself if the result after a paste/import is outside the
  current window. (Inkscape tends to put things at the top of a page, but the
  origin is at the bottom, and FF looks at the origin.
* A line joint of 180 degrees (which shouldn't have happened in stroking, but
  did) caused an infinite loop.
* Typo in add extrema code (again).
* More...
This commit is contained in:
adam 2011-05-02 11:15:41 +00:00
parent 4fc4592863
commit 034f81066a
9 changed files with 23 additions and 526 deletions

View file

@ -1,8 +1,7 @@
# $NetBSD: Makefile,v 1.72 2011/04/22 13:43:31 obache Exp $
# $NetBSD: Makefile,v 1.73 2011/05/02 11:15:41 adam Exp $
DISTNAME= fontforge_full-${VERSION}
PKGNAME= fontforge-${VERSION}
PKGREVISION= 7
CATEGORIES= fonts editors
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=fontforge/}
EXTRACT_SUFX= .tar.bz2
@ -10,26 +9,27 @@ EXTRACT_SUFX= .tar.bz2
MAINTAINER= adam@NetBSD.org
HOMEPAGE= http://fontforge.sourceforge.net/
COMMENT= Postscript font editor
LICENSE= modified-bsd
VERSION= 20100501
VERSION= 20110222
PKG_DESTDIR_SUPPORT= user-destdir
WRKSRC= ${WRKDIR}/${PKGNAME_NOREV}
MAKE_ENV+= PKGLOCALEDIR=${PKGLOCALEDIR}
GNU_CONFIGURE= yes
USE_LANGUAGES= c
USE_LIBTOOL= yes
USE_PKGLOCALEDIR= yes
USE_TOOLS+= gmake msgfmt
GNU_CONFIGURE= yes
CONFIGURE_ARGS+= --without-freetype-src
CONFIGURE_ARGS+= --without-python
BROKEN_GETTEXT_DETECTION= yes
MAKE_ENV+= PKGLOCALEDIR=${PKGLOCALEDIR}
LDFLAGS.SunOS+= -lrt
BROKEN_GETTEXT_DETECTION= yes
.include "options.mk"
.include "../../converters/libiconv/buildlink3.mk"
@ -37,9 +37,9 @@ LDFLAGS.SunOS+= -lrt
.include "../../devel/pango/buildlink3.mk"
.include "../../graphics/cairo/buildlink3.mk"
.include "../../graphics/freetype2/buildlink3.mk"
.include "../../mk/jpeg.buildlink3.mk"
.include "../../mk/giflib.buildlink3.mk"
.include "../../graphics/png/buildlink3.mk"
.include "../../graphics/tiff/buildlink3.mk"
.include "../../textproc/libxml2/buildlink3.mk"
.include "../../mk/giflib.buildlink3.mk"
.include "../../mk/jpeg.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

View file

@ -1,4 +1,4 @@
@comment $NetBSD: PLIST,v 1.29 2010/05/21 06:34:23 adam Exp $
@comment $NetBSD: PLIST,v 1.30 2011/05/02 11:15:42 adam Exp $
bin/fontforge
bin/fontimage
bin/fontlint
@ -13,7 +13,7 @@ include/fontforge/bitmapcontrol.h
include/fontforge/chardata.h
include/fontforge/charset.h
include/fontforge/config.h
include/fontforge/configure-pfaedit.h
include/fontforge/configure-fontforge.h
include/fontforge/delta.h
include/fontforge/dynamic.h
include/fontforge/edgelist.h
@ -22,6 +22,7 @@ include/fontforge/encoding.h
include/fontforge/fffreetype.h
include/fontforge/ffpython.h
include/fontforge/fileutil.h
include/fontforge/fontforge.h
include/fontforge/fontforgevw.h
include/fontforge/fvmetrics.h
include/fontforge/gdraw.h
@ -45,7 +46,6 @@ include/fontforge/mm.h
include/fontforge/namehash.h
include/fontforge/nonlineartrans.h
include/fontforge/ofl.h
include/fontforge/pfaedit.h
include/fontforge/plugins.h
include/fontforge/print.h
include/fontforge/psfont.h
@ -247,7 +247,7 @@ share/locale/es/LC_MESSAGES/FontForge.mo
share/locale/fr/LC_MESSAGES/FontForge.mo
share/locale/it/LC_MESSAGES/FontForge.mo
share/locale/ja/LC_MESSAGES/FontForge.mo
share/locale/mal/LC_MESSAGES/FontForge.mo
share/locale/ml/LC_MESSAGES/FontForge.mo
share/locale/pl/LC_MESSAGES/FontForge.mo
share/locale/ru/LC_MESSAGES/FontForge.mo
share/locale/uk/LC_MESSAGES/FontForge.mo

View file

@ -1,12 +1,8 @@
$NetBSD: distinfo,v 1.57 2011/01/24 12:08:26 wiz Exp $
$NetBSD: distinfo,v 1.58 2011/05/02 11:15:42 adam Exp $
SHA1 (fontforge_full-20100501.tar.bz2) = 483425116c6af6ad90e37f9ada0c28e34f251ec3
RMD160 (fontforge_full-20100501.tar.bz2) = 4dee2ecdbd32bf3854105f195984d9cabf198fd8
Size (fontforge_full-20100501.tar.bz2) = 6666386 bytes
SHA1 (patch-aa) = e6846a21c973aaa265bb46ba63d145d5f9c00714
SHA1 (fontforge_full-20110222.tar.bz2) = 8fada07647f102351bb1d7d1c4da487356e7142f
RMD160 (fontforge_full-20110222.tar.bz2) = 7f276e9e3ef673b78355bb7be50f6b2587aee633
Size (fontforge_full-20110222.tar.bz2) = 5126031 bytes
SHA1 (patch-aa) = 9b94b0dccc3006112dae8289ed81c5aaba262576
SHA1 (patch-ab) = ec93a47051186bcb901fd145edffad7c457c33fd
SHA1 (patch-ae) = ca532490137e83ff328ad32c0102d57bed7bb453
SHA1 (patch-ai) = 4b30556509007d1c74ccdfc9d27f7f23f30bbdb1
SHA1 (patch-aj) = 751baf7cdaf3c74632a95389611366134fe36da5
SHA1 (patch-ak) = a69ec30586d61b89896758d5a1e817d917a835d2
SHA1 (patch-al) = f34104791646030bb76df20e5ddb88bf21842b02
SHA1 (patch-ae) = 2cffc4dad365ff3f7850c1982bbe27bc9821f792

View file

@ -1,4 +1,4 @@
$NetBSD: patch-aa,v 1.9 2010/05/21 06:34:23 adam Exp $
$NetBSD: patch-aa,v 1.10 2011/05/02 11:15:42 adam Exp $
--- fontforge/Makefile.dynamic.in.orig 2010-02-02 05:23:06.000000000 +0000
+++ fontforge/Makefile.dynamic.in
@ -11,7 +11,7 @@ $NetBSD: patch-aa,v 1.9 2010/05/21 06:34:23 adam Exp $
X_11LIB = @X_11LIB@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
@@ -74,7 +74,7 @@ LIBLIBS = -rpath $(libdir) ../libgutils.
@@ -75,7 +75,7 @@ LIBLIBS = -rpath $(libdir) ../libgutils.
@LIBS@ $(STATIC_LIBS) -lm
DLIBS = -rpath $(libdir) ../libfontforge.la ../libgutils.la ../libgunicode.la @LIBS@ $(STATIC_LIBS) -lm

View file

@ -1,4 +1,4 @@
$NetBSD: patch-ae,v 1.22 2010/05/21 06:34:23 adam Exp $
$NetBSD: patch-ae,v 1.23 2011/05/02 11:15:42 adam Exp $
--- configure.orig 2010-04-29 17:53:45.000000000 +0000
+++ configure
@ -29,7 +29,7 @@ $NetBSD: patch-ae,v 1.22 2010/05/21 06:34:23 adam Exp $
else
$as_echo "#define _NO_LIBXML 1" >>confdefs.h
@@ -22930,7 +22930,7 @@ if test "$gww_has_gettext" = "yes" >/dev
@@ -23016,7 +23016,7 @@ if test "$gww_has_gettext" = "yes" >/dev
cat </dev/null >$ac_confdir/po/Makefile.in
echo 'prefix = @prefix@' >> $ac_confdir/po/Makefile.in

View file

@ -1,16 +0,0 @@
$NetBSD: patch-ai,v 1.5 2010/10/10 18:44:54 wiz Exp $
Stack overflow bug, see:
http://sourceforge.net/mailarchive/forum.php?thread_name=4C5D676B.3000509%40limes.com.pl&forum_name=fontforge-devel
--- fontforge/svg.c.orig 2010-04-29 03:53:22.000000000 +0000
+++ fontforge/svg.c
@@ -150,7 +150,7 @@ return( defwid );
static int svg_pathdump(FILE *file, SplineSet *spl, int lineout,
int forceclosed, int do_clips) {
BasePoint last;
- char buffer[60];
+ char buffer[85];
int closed=false;
Spline *sp, *first;
/* as I see it there is nothing to be gained by optimizing out the */

View file

@ -1,210 +0,0 @@
$NetBSD: patch-aj,v 1.4 2011/01/24 12:08:26 wiz Exp $
Fix build with png-1.5.
--- gutils/gimagereadpng.c.orig 2010-04-29 03:53:22.000000000 +0000
+++ gutils/gimagereadpng.c
@@ -60,6 +60,15 @@ static void (*_png_set_packing)(png_stru
static void (*_png_set_filler)(png_structp,png_uint_32,int);
static void (*_png_read_image)(png_structp,png_bytep*);
static void (*_png_read_end)(png_structp,png_infop);
+static void (*_png_longjmp)(png_structp, int);
+static jmp_buf* (*_png_set_longjmp_fn)(png_structp,png_longjmp_ptr, size_t);
+static png_byte (*_png_get_color_type)(png_structp,png_infop);
+static png_byte (*_png_get_bit_depth)(png_structp,png_infop);
+static png_uint_32 (*_png_get_image_width)(png_structp,png_infop);
+static png_uint_32 (*_png_get_image_height)(png_structp,png_infop);
+static png_uint_32 (*_png_get_PLTE)(png_structp,png_infop,png_colorp *,int *);
+static png_uint_32 (*_png_get_tRNS)(png_structp,png_infop,png_bytep *,int *,png_color_16p *);
+static png_uint_32 (*_png_get_valid)(png_structp,png_infop,png_uint_32);
#ifndef RTLD_GLOBAL /* OSF on Alpha doesn't define this */
# define RTLD_GLOBAL 0
@@ -78,7 +87,7 @@ return( 0 );
}
# if !defined(_LIBPNG12)
- libpng = dlopen("libpng" SO_EXT,RTLD_LAZY);
+ libpng = dlopen("libpng15" SO_EXT,RTLD_LAZY);
# ifdef SO_2_EXT
if ( libpng==NULL )
libpng = dlopen("libpng" SO_2_EXT,RTLD_LAZY);
@@ -105,6 +114,15 @@ return( 0 );
_png_set_filler = (void (*)(png_structp,png_uint_32,int)) dlsym(libpng,"png_set_filler");
_png_read_image = (void (*)(png_structp,png_bytep*)) dlsym(libpng,"png_read_image");
_png_read_end = (void (*)(png_structp,png_infop)) dlsym(libpng,"png_read_end");
+ _png_longjmp = (void (*)(png_structp, int)) dlsym(libpng,"png_longjmp");
+ _png_set_longjmp_fn = (jmp_buf* (*)(png_structp,png_longjmp_ptr,size_t)) dlsym(libpng,"png_set_longjmp_fn");
+ _png_get_color_type = (png_byte (*)(png_structp,png_infop)) dlsym(libpng,"png_get_color_type");
+ _png_get_bit_depth = (png_byte (*)(png_structp,png_infop)) dlsym(libpng,"png_get_bit_depth");
+ _png_get_image_width = (png_uint_32 (*)(png_structp,png_infop)) dlsym(libpng,"png_get_image_width");
+ _png_get_image_height = (png_uint_32 (*)(png_structp,png_infop)) dlsym(libpng,"png_get_image_height");
+ _png_get_PLTE = (png_uint_32 (*)(png_structp,png_infop,png_colorp *,int *)) dlsym(libpng,"png_get_PLTE");
+ _png_get_tRNS = (png_uint_32 (*)(png_structp,png_infop,png_bytep *,int *,png_color_16p *)) dlsym(libpng,"png_get_tRNS");
+ _png_get_valid = (png_uint_32 (*)(png_structp,png_infop,png_uint_32)) dlsym(libpng,"png_get_valid");
if ( _png_create_read_struct && _png_create_info_struct && _png_destroy_read_struct &&
_png_init_io && _png_read_info && _png_set_strip_16 && _png_set_packing &&
_png_set_filler && _png_read_image && _png_read_end &&
@@ -126,6 +144,15 @@ return( 0 );
# define _png_set_filler png_set_filler
# define _png_read_image png_read_image
# define _png_read_end png_read_end
+# define _png_longjmp png_longjmp
+# define _png_set_longjmp_fn png_set_longjmp_fn
+# define _png_get_color_type png_get_color_type
+# define _png_get_bit_depth png_get_bit_depth
+# define _png_get_image_width png_get_image_width
+# define _png_get_image_height png_get_image_height
+# define _png_get_PLTE png_get_PLTE
+# define _png_get_tRNS png_get_tRNS
+# define _png_get_valid png_get_valid
static void *libpng=(void *) 1;
static int loadpng() { return true; }
@@ -133,7 +160,11 @@ static int loadpng() { return true; }
static void user_error_fn(png_structp png_ptr, png_const_charp error_msg) {
fprintf(stderr,"%s\n", error_msg);
+#if (PNG_LIBPNG_VER < 10500)
longjmp(png_ptr->jmpbuf,1);
+#else
+ _png_longjmp (png_ptr, 1);
+#endif
}
static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) {
@@ -146,6 +177,9 @@ GImage *GImageRead_Png(FILE *fp) {
png_structp png_ptr;
png_infop info_ptr;
png_bytep *row_pointers=NULL;
+ png_bytep trans_alpha;
+ int num_trans;
+ png_color_16p trans_color;
int i;
if ( libpng==NULL )
@@ -164,7 +198,7 @@ return( NULL );
return( NULL );
}
- if (setjmp(png_ptr->jmpbuf)) {
+ if (setjmp(*_png_set_longjmp_fn(png_ptr, longjmp, sizeof (jmp_buf)))) {
/* Free all of the memory associated with the png_ptr and info_ptr */
_png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
if ( ret!=NULL ) {
@@ -178,74 +212,63 @@ return( NULL );
_png_init_io(png_ptr, fp);
_png_read_info(png_ptr, info_ptr);
_png_set_strip_16(png_ptr);
- if ( (info_ptr->color_type==PNG_COLOR_TYPE_GRAY || info_ptr->color_type==PNG_COLOR_TYPE_PALETTE ) &&
- info_ptr->bit_depth == 1 )
+ if ( (_png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_GRAY || _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_PALETTE ) &&
+ _png_get_bit_depth(png_ptr,info_ptr) == 1 )
/* Leave bitmaps packed */;
else
_png_set_packing(png_ptr);
- if ( info_ptr->color_type==PNG_COLOR_TYPE_GRAY_ALPHA )
+ if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_GRAY_ALPHA )
_png_set_strip_alpha(png_ptr);
- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB)
+ if (_png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB)
_png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
- if ( info_ptr->color_type==PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth == 1 ) {
- ret = GImageCreate(it_mono,info_ptr->width,info_ptr->height);
- } else if ( info_ptr->color_type==PNG_COLOR_TYPE_GRAY || info_ptr->color_type==PNG_COLOR_TYPE_GRAY_ALPHA ) {
+ if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_GRAY && _png_get_bit_depth(png_ptr,info_ptr) == 1 ) {
+ ret = GImageCreate(it_mono,_png_get_image_width(png_ptr,info_ptr),_png_get_image_height(png_ptr,info_ptr));
+ } else if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_GRAY || _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_GRAY_ALPHA ) {
GClut *clut;
- ret = GImageCreate(it_index,info_ptr->width,info_ptr->height);
+ ret = GImageCreate(it_index,_png_get_image_width(png_ptr,info_ptr),_png_get_image_height(png_ptr,info_ptr));
clut = ret->u.image->clut;
clut->is_grey = true;
clut->clut_len = 256;
for ( i=0; i<256; ++i )
clut->clut[i] = COLOR_CREATE(i,i,i);
- } else if ( info_ptr->color_type==PNG_COLOR_TYPE_RGB_ALPHA ) {
- ret = GImageCreate(it_rgba,info_ptr->width,info_ptr->height);
- } else if ( info_ptr->color_type==PNG_COLOR_TYPE_RGB || info_ptr->color_type==PNG_COLOR_TYPE_RGB_ALPHA )
- ret = GImageCreate(it_true,info_ptr->width,info_ptr->height);
+ } else if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB_ALPHA ) {
+ ret = GImageCreate(it_rgba,_png_get_image_width(png_ptr,info_ptr),_png_get_image_height(png_ptr,info_ptr));
+ } else if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB || _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB_ALPHA )
+ ret = GImageCreate(it_true,_png_get_image_width(png_ptr,info_ptr),_png_get_image_height(png_ptr,info_ptr));
else {
+ png_colorp palette;
+ int num_palette;
GClut *clut;
- ret = GImageCreate(info_ptr->bit_depth != 1? it_index : it_mono,
- info_ptr->width,info_ptr->height);
+ ret = GImageCreate(_png_get_bit_depth(png_ptr,info_ptr) != 1? it_index : it_mono,
+ _png_get_image_width(png_ptr,info_ptr),_png_get_image_height(png_ptr,info_ptr));
clut = ret->u.image->clut;
if ( clut==NULL )
clut = ret->u.image->clut = gcalloc(1,sizeof(GClut));
clut->is_grey = true;
- clut->clut_len = info_ptr->num_palette;
- for ( i=0; i<info_ptr->num_palette; ++i )
- clut->clut[i] = COLOR_CREATE(info_ptr->palette[i].red,
- info_ptr->palette[i].green,
- info_ptr->palette[i].blue);
+ _png_get_PLTE(png_ptr,info_ptr,&palette,&num_palette);
+ clut->clut_len = num_palette;
+ for ( i=0; i<num_palette; ++i )
+ clut->clut[i] = COLOR_CREATE(palette[i].red,
+ palette[i].green,
+ palette[i].blue);
}
+ _png_get_tRNS(png_ptr,info_ptr,&trans_alpha,&num_trans,&trans_color);
base = ret->u.image;
- if ( (info_ptr->valid&PNG_INFO_tRNS) && info_ptr->num_trans>0 ) {
- if ( info_ptr->color_type==PNG_COLOR_TYPE_RGB || info_ptr->color_type==PNG_COLOR_TYPE_RGB_ALPHA )
-#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 )
+ if ( (_png_get_valid(png_ptr,info_ptr,PNG_INFO_tRNS)) && num_trans>0 ) {
+ if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB || _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB_ALPHA )
base->trans = COLOR_CREATE(
- (info_ptr->trans_color.red>>8),
- (info_ptr->trans_color.green>>8),
- (info_ptr->trans_color.blue>>8));
-#else
- base->trans = COLOR_CREATE(
- (info_ptr->trans_values.red>>8),
- (info_ptr->trans_values.green>>8),
- (info_ptr->trans_values.blue>>8));
-#endif
+ (trans_color->red>>8),
+ (trans_color->green>>8),
+ (trans_color->blue>>8));
else if ( base->image_type == it_mono )
-#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 )
- base->trans = info_ptr->trans_alpha[0];
-#else
- base->trans = info_ptr->trans[0];
-#endif
+ base->trans = trans_alpha[0];
else
-#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 )
- base->clut->trans_index = base->trans = info_ptr->trans_alpha[0];
-#else
- base->clut->trans_index = base->trans = info_ptr->trans[0];
-#endif
+ base->clut->trans_index = base->trans = trans_alpha[0];
}
- row_pointers = galloc(info_ptr->height*sizeof(png_bytep));
- for ( i=0; i<info_ptr->height; ++i )
+ row_pointers = galloc(_png_get_image_height(png_ptr,info_ptr)*sizeof(png_bytep));
+ for ( i=0; i<_png_get_image_height(png_ptr,info_ptr); ++i )
row_pointers[i] = (png_bytep) (base->data + i*base->bytes_per_line);
/* Ignore progressive loads for now */
@@ -254,7 +277,7 @@ return( NULL );
_png_read_image(png_ptr,row_pointers);
_png_read_end(png_ptr, NULL);
- if ( info_ptr->color_type==PNG_COLOR_TYPE_RGB || info_ptr->color_type==PNG_COLOR_TYPE_RGB_ALPHA ) {
+ if ( _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB || _png_get_color_type(png_ptr, info_ptr)==PNG_COLOR_TYPE_RGB_ALPHA ) {
/* PNG orders its bytes as AABBGGRR instead of 00RRGGBB */
uint32 *ipt, *iend;
for ( ipt = (uint32 *) (base->data), iend=ipt+base->width*base->height; ipt<iend; ++ipt ) {

View file

@ -1,219 +0,0 @@
$NetBSD: patch-ak,v 1.3 2011/01/24 12:08:26 wiz Exp $
Fix build with png-1.5.
--- gutils/gimagewritepng.c.orig 2010-04-29 17:52:54.000000000 +0000
+++ gutils/gimagewritepng.c
@@ -53,6 +53,11 @@ static void (*_png_set_packing)(png_stru
static void (*_png_set_filler)(png_structp,png_uint_32,int);
static void (*_png_write_image)(png_structp,png_bytep*);
static void (*_png_write_end)(png_structp,png_infop);
+static void (*_png_longjmp)(png_structp, int);
+static jmp_buf* (*_png_set_longjmp_fn)(png_structp,png_longjmp_ptr, size_t);
+static void (*_png_set_IHDR)(png_structp,png_infop,png_uint_32,png_uint_32,int,int,int,int,int);
+static void (*_png_set_PLTE)(png_structp,png_infop,png_colorp,int);
+static void (*_png_set_tRNS)(png_structp,png_infop,png_bytep,int,png_color_16p);
static int loadpng() {
/* Oops someone might have libpng without libz. If we try to load libpng */
@@ -66,7 +71,7 @@ static int loadpng() {
return( 0 );
}
# if !defined(_LIBPNG12)
- libpng = dlopen("libpng" SO_EXT,RTLD_LAZY);
+ libpng = dlopen("libpng15" SO_EXT,RTLD_LAZY);
# ifdef SO_2_EXT
if ( libpng==NULL )
libpng = dlopen("libpng" SO_2_EXT,RTLD_LAZY);
@@ -100,6 +105,16 @@ return( 0 );
dlsym(libpng,"png_write_image");
_png_write_end = (void (*)(png_structp,png_infop))
dlsym(libpng,"png_write_end");
+ _png_longjmp = (void (*)(png_structp, int))
+ dlsym(libpng,"png_longjmp");
+ _png_set_longjmp_fn = (jmp_buf* (*)(png_structp,png_longjmp_ptr,size_t))
+ dlsym(libpng,"png_set_longjmp_fn");
+ _png_set_IHDR = (void (*)(png_structp,png_infop,png_uint_32,png_uint_32,int,int,int,int,int))
+ dlsym(libpng,"png_set_IHDR");
+ _png_set_PLTE = (void (*)(png_structp,png_infop,png_colorp,int))
+ dlsym(libpng,"png_set_PLTE");
+ _png_set_tRNS = (void (*)(png_structp,png_infop,png_bytep,int,png_color_16p))
+ dlsym(libpng,"png_set_tRNS");
if ( _png_create_write_struct && _png_create_info_struct && _png_destroy_write_struct &&
_png_init_io && _png_set_filler && _png_write_info && _png_set_packing &&
_png_write_image && _png_write_end)
@@ -111,7 +126,11 @@ return( 0 );
static void user_error_fn(png_structp png_ptr, png_const_charp error_msg) {
fprintf(stderr,"%s", error_msg );
+#if (PNG_LIBPNG_VER < 10500)
longjmp(png_ptr->jmpbuf,1);
+#else
+ _png_longjmp (png_ptr, 1);
+#endif
}
static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) {
@@ -124,6 +143,12 @@ int GImageWrite_Png(GImage *gi, FILE *fp
png_infop info_ptr;
png_byte **rows;
int i;
+ int bit_depth;
+ int color_type;
+ int num_palette;
+ png_bytep trans_alpha = NULL;
+ png_color_16p trans_color = NULL;
+ png_colorp palette = NULL;
if ( libpng==NULL )
if ( !loadpng())
@@ -142,75 +167,66 @@ return(false);
return(false);
}
- if (setjmp(png_ptr->jmpbuf)) {
+ if (setjmp(*_png_set_longjmp_fn(png_ptr, longjmp, sizeof (jmp_buf)))) {
_png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return(false);
}
_png_init_io(png_ptr, fp);
- info_ptr->width = base->width;
- info_ptr->height = base->height;
- info_ptr->bit_depth = 8;
- info_ptr->valid = 0;
- info_ptr->interlace_type = progressive;
- if ( base->trans!=-1 ) {
- info_ptr->num_trans = 1;
- info_ptr->valid |= PNG_INFO_tRNS;
+ bit_depth = 8;
+ num_palette = base->clut==NULL?2:base->clut->clut_len;
+ if ( base->image_type==it_index || base->image_type==it_bitmap ) {
+ color_type = PNG_COLOR_TYPE_PALETTE;
+ if ( num_palette<=2 )
+ bit_depth=1;
+ else if ( num_palette<=4 )
+ bit_depth=2;
+ else if ( num_palette<=16 )
+ bit_depth=4;
+ } else {
+ color_type = PNG_COLOR_TYPE_RGB;
+ if ( base->image_type == it_rgba )
+ color_type = PNG_COLOR_TYPE_RGB_ALPHA;
}
+
+ _png_set_IHDR(png_ptr, info_ptr, base->width, base->height,
+ bit_depth, color_type, progressive,
+ PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
if ( base->image_type==it_index || base->image_type==it_bitmap ) {
- info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
- info_ptr->valid |= PNG_INFO_PLTE;
- info_ptr->num_palette = base->clut==NULL?2:base->clut->clut_len;
- info_ptr->palette = (png_color *) galloc(info_ptr->num_palette*sizeof(png_color));
+ palette = (png_color *) galloc(num_palette*sizeof(png_color));
if ( base->clut==NULL ) {
- info_ptr->palette[0].red = info_ptr->palette[0].green = info_ptr->palette[0].blue = 0;
- info_ptr->palette[1].red = info_ptr->palette[1].green = info_ptr->palette[1].blue = 0xff;
+ palette[0].red = palette[0].green = palette[0].blue = 0;
+ palette[1].red = palette[1].green = palette[1].blue = 0xff;
} else {
- for ( i=0; i<info_ptr->num_palette; ++i ) {
+ for ( i=0; i<num_palette; ++i ) {
long col = base->clut->clut[i];
- info_ptr->palette[i].red = COLOR_RED(col);
- info_ptr->palette[i].green = COLOR_GREEN(col);
- info_ptr->palette[i].blue = COLOR_BLUE(col);
+ palette[i].red = COLOR_RED(col);
+ palette[i].green = COLOR_GREEN(col);
+ palette[i].blue = COLOR_BLUE(col);
}
}
- if ( info_ptr->num_palette<=2 )
- info_ptr->bit_depth=1;
- else if ( info_ptr->num_palette<=4 )
- info_ptr->bit_depth=2;
- else if ( info_ptr->num_palette<=16 )
- info_ptr->bit_depth=4;
- if ( info_ptr->num_palette<=16 )
+ _png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
+ if ( num_palette<=16 )
_png_set_packing(png_ptr);
+
if ( base->trans!=-1 ) {
-#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 )
- info_ptr->trans_alpha = galloc(1);
- info_ptr->trans_alpha[0] = base->trans;
-#else
- info_ptr->trans = galloc(1);
- info_ptr->trans[0] = base->trans;
-#endif
+ trans_alpha = galloc(1);
+ trans_alpha[0] = base->trans;
}
} else {
- info_ptr->color_type = PNG_COLOR_TYPE_RGB;
- if ( base->image_type == it_rgba )
- info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-
if ( base->trans!=-1 ) {
-#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 )
- info_ptr->trans_color.red = COLOR_RED(base->trans);
- info_ptr->trans_color.green = COLOR_GREEN(base->trans);
- info_ptr->trans_color.blue = COLOR_BLUE(base->trans);
-#else
- info_ptr->trans_values.red = COLOR_RED(base->trans);
- info_ptr->trans_values.green = COLOR_GREEN(base->trans);
- info_ptr->trans_values.blue = COLOR_BLUE(base->trans);
-#endif
+ trans_color->red = COLOR_RED(base->trans);
+ trans_color->green = COLOR_GREEN(base->trans);
+ trans_color->blue = COLOR_BLUE(base->trans);
}
}
+ if ( base->trans!=-1 ) {
+ _png_set_tRNS(png_ptr, info_ptr, trans_alpha, 1, trans_color);
+ }
_png_write_info(png_ptr, info_ptr);
- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB)
+ if (color_type == PNG_COLOR_TYPE_RGB)
_png_set_filler(png_ptr, '\0', PNG_FILLER_BEFORE);
rows = galloc(base->height*sizeof(png_byte *));
@@ -221,12 +237,8 @@ return(false);
_png_write_end(png_ptr, info_ptr);
-#if ( PNG_LIBPNG_VER_MAJOR > 1 || PNG_LIBPNG_VER_MINOR > 2 )
- if ( info_ptr->trans_alpha!=NULL ) gfree(info_ptr->trans_alpha);
-#else
- if ( info_ptr->trans!=NULL ) gfree(info_ptr->trans);
-#endif
- if ( info_ptr->palette!=NULL ) gfree(info_ptr->palette);
+ if ( trans_alpha!=NULL ) gfree(trans_alpha);
+ if ( palette!=NULL ) gfree(palette);
_png_destroy_write_struct(&png_ptr, &info_ptr);
gfree(rows);
return( 1 );
@@ -261,7 +273,11 @@ return( ret );
static void user_error_fn(png_structp png_ptr, png_const_charp error_msg) {
fprintf(stderr, "%s\n", error_msg );
+#if (PNG_LIBPNG_VER < 10500)
longjmp(png_ptr->jmpbuf,1);
+#else
+ _png_longjmp (png_ptr, 1);
+#endif
}
static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) {
@@ -288,7 +304,7 @@ return(false);
return(false);
}
- if (setjmp(png_ptr->jmpbuf)) {
+ if (setjmp(*_png_set_longjmp_fn(png_ptr, longjmp, sizeof (jmp_buf)))) {
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return(false);
}

View file

@ -1,54 +0,0 @@
$NetBSD: patch-al,v 1.1 2010/12/07 16:58:12 drochner Exp $
CVE-2010-4259
--- fontforge/fvimportbdf.c.orig 2010-04-16 03:02:02.000000000 +0000
+++ fontforge/fvimportbdf.c
@@ -560,7 +560,7 @@ static int slurp_header(FILE *bdf, int *
}
if ( strcmp(tok,"FONT")==0 ) {
- if ( sscanf(buf,"-%*[^-]-%[^-]-%[^-]-%[^-]-%*[^-]-", family, weight, italic )!=0 ) {
+ if ( sscanf(buf,"-%*[^-]-%99[^-]-%99[^-]-%99[^-]-%*[^-]-", family, weight, italic )!=0 ) {
char *pt=buf;
int dcnt=0;
while ( *pt=='-' && dcnt<7 ) { ++pt; ++dcnt; }
@@ -616,26 +616,30 @@ static int slurp_header(FILE *bdf, int *
sscanf(buf, "%d", &defs->metricsset );
else if ( strcmp(tok,"VVECTOR")==0 )
sscanf(buf, "%*d %d", &defs->vertical_origin );
+ /* For foundry, fontname and encname, only copy up to the buffer size */
else if ( strcmp(tok,"FOUNDRY")==0 )
- sscanf(buf, "%[^\"]", foundry );
+ sscanf(buf, "%99[^\"]", foundry );
else if ( strcmp(tok,"FONT_NAME")==0 )
- sscanf(buf, "%[^\"]", fontname );
+ sscanf(buf, "%99[^\"]", fontname );
else if ( strcmp(tok,"CHARSET_REGISTRY")==0 )
- sscanf(buf, "%[^\"]", encname );
+ sscanf(buf, "%99[^\"]", encname );
else if ( strcmp(tok,"CHARSET_ENCODING")==0 ) {
enc = 0;
if ( sscanf(buf, " %d", &enc )!=1 )
sscanf(buf, "%d", &enc );
+ /* These properties should be copied up to the buffer length too */
} else if ( strcmp(tok,"FAMILY_NAME")==0 ) {
- strcpy(family,buf);
+ strncpy(family,buf,99);
} else if ( strcmp(tok,"FULL_NAME")==0 || strcmp(tok,"FACE_NAME")==0 ) {
- strcpy(full,buf);
+ strncpy(full,buf,99);
} else if ( strcmp(tok,"WEIGHT_NAME")==0 )
- strcpy(weight,buf);
+ strncpy(weight,buf,99);
else if ( strcmp(tok,"SLANT")==0 )
- strcpy(italic,buf);
+ strncpy(italic,buf,99);
else if ( strcmp(tok,"COPYRIGHT")==0 ) {
- strcpy(comments,buf);
+ /* LS: Assume the size of the passed-in buffer is 1000, see below in
+ * COMMENT */
+ strncpy(comments,buf,999);
found_copyright = true;
} else if ( strcmp(tok,"COMMENT")==0 && !found_copyright ) {
char *pt = comments+strlen(comments);