From 2584fb044fe0a9945a4164ce4b8221758414aa0a Mon Sep 17 00:00:00 2001 From: wiz Date: Mon, 24 Jan 2011 12:08:26 +0000 Subject: [PATCH] Complete fix for png-1.5. --- fonts/fontforge/distinfo | 6 +- fonts/fontforge/patches/patch-aj | 25 ++-- fonts/fontforge/patches/patch-ak | 210 ++++++++++++++++++++++++++++++- 3 files changed, 225 insertions(+), 16 deletions(-) diff --git a/fonts/fontforge/distinfo b/fonts/fontforge/distinfo index ee4c4d3f4188..0115e39aa1b7 100644 --- a/fonts/fontforge/distinfo +++ b/fonts/fontforge/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.56 2011/01/24 10:36:58 wiz Exp $ +$NetBSD: distinfo,v 1.57 2011/01/24 12:08:26 wiz Exp $ SHA1 (fontforge_full-20100501.tar.bz2) = 483425116c6af6ad90e37f9ada0c28e34f251ec3 RMD160 (fontforge_full-20100501.tar.bz2) = 4dee2ecdbd32bf3854105f195984d9cabf198fd8 @@ -7,6 +7,6 @@ SHA1 (patch-aa) = e6846a21c973aaa265bb46ba63d145d5f9c00714 SHA1 (patch-ab) = ec93a47051186bcb901fd145edffad7c457c33fd SHA1 (patch-ae) = ca532490137e83ff328ad32c0102d57bed7bb453 SHA1 (patch-ai) = 4b30556509007d1c74ccdfc9d27f7f23f30bbdb1 -SHA1 (patch-aj) = 885ac072e22f6c5d6ba2c9c9d3d7e8f4336b0c1a -SHA1 (patch-ak) = 57167ede3fbb5f9bebf85cc74a605c667e3ed324 +SHA1 (patch-aj) = 751baf7cdaf3c74632a95389611366134fe36da5 +SHA1 (patch-ak) = a69ec30586d61b89896758d5a1e817d917a835d2 SHA1 (patch-al) = f34104791646030bb76df20e5ddb88bf21842b02 diff --git a/fonts/fontforge/patches/patch-aj b/fonts/fontforge/patches/patch-aj index d312ad6a3924..6497a608bf55 100644 --- a/fonts/fontforge/patches/patch-aj +++ b/fonts/fontforge/patches/patch-aj @@ -1,10 +1,10 @@ -$NetBSD: patch-aj,v 1.3 2011/01/24 10:36:58 wiz Exp $ +$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,14 @@ static void (*_png_set_packing)(png_stru +@@ -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); @@ -14,12 +14,13 @@ Fix build with png-1.5. +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 +86,7 @@ return( 0 ); +@@ -78,7 +87,7 @@ return( 0 ); } # if !defined(_LIBPNG12) @@ -28,7 +29,7 @@ Fix build with png-1.5. # ifdef SO_2_EXT if ( libpng==NULL ) libpng = dlopen("libpng" SO_2_EXT,RTLD_LAZY); -@@ -105,6 +113,14 @@ return( 0 ); +@@ -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"); @@ -38,12 +39,13 @@ Fix build with png-1.5. + _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 +142,14 @@ return( 0 ); +@@ -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 @@ -53,12 +55,13 @@ Fix build with png-1.5. +# 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 +157,11 @@ 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); @@ -70,7 +73,7 @@ Fix build with png-1.5. } static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) { -@@ -146,6 +174,9 @@ GImage *GImageRead_Png(FILE *fp) { +@@ -146,6 +177,9 @@ GImage *GImageRead_Png(FILE *fp) { png_structp png_ptr; png_infop info_ptr; png_bytep *row_pointers=NULL; @@ -80,7 +83,7 @@ Fix build with png-1.5. int i; if ( libpng==NULL ) -@@ -164,7 +195,7 @@ return( NULL ); +@@ -164,7 +198,7 @@ return( NULL ); return( NULL ); } @@ -89,7 +92,7 @@ Fix build with png-1.5. /* 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 +209,63 @@ return( 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); @@ -146,7 +149,7 @@ Fix build with png-1.5. - 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); ++ _png_get_PLTE(png_ptr,info_ptr,&palette,&num_palette); + clut->clut_len = num_palette; + for ( i=0; iclut[i] = COLOR_CREATE(palette[i].red, @@ -196,7 +199,7 @@ Fix build with png-1.5. row_pointers[i] = (png_bytep) (base->data + i*base->bytes_per_line); /* Ignore progressive loads for now */ -@@ -254,7 +274,7 @@ return( NULL ); +@@ -254,7 +277,7 @@ return( NULL ); _png_read_image(png_ptr,row_pointers); _png_read_end(png_ptr, NULL); diff --git a/fonts/fontforge/patches/patch-ak b/fonts/fontforge/patches/patch-ak index de893e7bc95b..05637a23dcd4 100644 --- a/fonts/fontforge/patches/patch-ak +++ b/fonts/fontforge/patches/patch-ak @@ -1,8 +1,22 @@ -$NetBSD: patch-ak,v 1.2 2011/01/13 13:52:52 wiz Exp $ +$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 -@@ -66,7 +66,7 @@ static int loadpng() { +@@ -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) @@ -11,3 +25,195 @@ $NetBSD: patch-ak,v 1.2 2011/01/13 13:52:52 wiz Exp $ # 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; inum_palette; ++i ) { ++ for ( i=0; iclut->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); + }