From 428c2e4f62abb2c7f158f7f0da43d82f848db30d Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 25 Apr 2003 05:35:04 +0000 Subject: [PATCH] * src/bdf/bdflib.c (hash_bucket, hash_lookup): Use `const' for first argument. (bdf_get_font_property): Use `const' for third argument. Updated all callers. * src/bdf/bdfdrivr.c (BDF_Face_Init): Set pixel width and height similar to the PCF driver. * src/bdf/bdf.h (_hashnode): Use `const' for `key'. Updated. * src/gzip/ftgzip.c: C++ doesn't like that the array `inflate_mask' is declared twice. It is perhaps better to modify the zlip source files directly instead of this hack. (zcalloc, zfree, ft_gzip_stream_close, ft_gzip_stream_io): Add casts to make build with g++ successful. --- ChangeLog | 31 +++++++++++++++++++++++++++---- src/base/ftobjs.c | 4 ++-- src/bdf/bdf.h | 8 ++++---- src/bdf/bdfdrivr.c | 30 +++++++++++++++--------------- src/bdf/bdflib.c | 14 +++++++------- src/cff/cffgload.c | 4 ++-- src/cid/cidgload.c | 4 ++-- src/cid/cidobjs.c | 8 +++++--- src/gzip/ftgzip.c | 23 +++++++++++++++++------ src/pcf/pcfdriver.c | 2 +- src/pcf/pcfread.c | 12 ++++++------ src/type1/t1objs.c | 6 ++++-- src/type42/t42objs.c | 6 ++++-- 13 files changed, 96 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71e29b6ad..e4cdd18f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,32 @@ +2003-04-25 Werner Lemberg + + * src/bdf/bdflib.c (hash_bucket, hash_lookup): Use `const' for first + argument. + (bdf_get_font_property): Use `const' for third argument. + Updated all callers. + * src/bdf/bdfdrivr.c (BDF_Face_Init): Set pixel width and height + similar to the PCF driver. + * src/bdf/bdf.h (_hashnode): Use `const' for `key'. + Updated. + + * src/gzip/ftgzip.c: C++ doesn't like that the array `inflate_mask' + is declared twice. It is perhaps better to modify the zlip source + files directly instead of this hack. + (zcalloc, zfree, ft_gzip_stream_close, ft_gzip_stream_io): Add casts + to make build with g++ successful. + +2003-04-24 Manish Singh + + * src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c + (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Split on `-' + also for searching the style name. + 2003-04-24 David Turner - * src/pcf/pcfread.c (pcf_load_font): fixed the computation of - face->num_glyphs, this required increase the value by 1 to respect - the convention that gindex 0 always corresponds to the "missing - glyph". + * src/pcf/pcfread.c (pcf_load_font): fixed the computation of + face->num_glyphs, this required increase the value by 1 to respect + the convention that gindex 0 always corresponds to the "missing + glyph". 2003-04-24 Werner Lemberg diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index dd873cdf6..ef4a7f6a1 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1426,8 +1426,8 @@ if ( char_height < 1 * 64 ) char_height = 1 * 64; - /* Compute pixel sizes in 26.6 units. we use rounding - */ + /* Compute pixel sizes in 26.6 units. we use rounding + */ dim_x = ( ( char_width * horz_resolution + (36+32*72) ) / 72 ) & -64; dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & -64; diff --git a/src/bdf/bdf.h b/src/bdf/bdf.h index 6a4bb821f..4dab5ae9d 100644 --- a/src/bdf/bdf.h +++ b/src/bdf/bdf.h @@ -1,6 +1,6 @@ /* * Copyright 2000 Computing Research Labs, New Mexico State University - * Copyright 2001, 2002 Francesco Zappa Nardelli + * Copyright 2001, 2002, 2003 Francesco Zappa Nardelli * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -159,8 +159,8 @@ FT_BEGIN_HEADER typedef struct _hashnode_ { - char* key; - void* data; + const char* key; + void* data; } _hashnode, *hashnode; @@ -283,7 +283,7 @@ FT_BEGIN_HEADER FT_LOCAL( bdf_property_t * ) bdf_get_font_property( bdf_font_t* font, - char* name ); + const char* name ); FT_END_HEADER diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index 62e7ca7cf..c7c140fe4 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -169,8 +169,6 @@ THE SOFTWARE. }; - - FT_CALLBACK_DEF( FT_Error ) BDF_Face_Done( BDF_Face face ) { @@ -250,7 +248,7 @@ THE SOFTWARE. FT_FACE_FLAG_HORIZONTAL | FT_FACE_FLAG_FAST_GLYPHS; - prop = bdf_get_font_property( font, (char *)"SPACING" ); + prop = bdf_get_font_property( font, "SPACING" ); if ( prop != NULL ) if ( prop->format == BDF_ATOM ) if ( prop->value.atom != NULL ) @@ -262,7 +260,7 @@ THE SOFTWARE. /* FZ XXX: I need a font to implement this */ root->style_flags = 0; - prop = bdf_get_font_property( font, (char *)"SLANT" ); + prop = bdf_get_font_property( font, "SLANT" ); if ( prop != NULL ) if ( prop->format == BDF_ATOM ) if ( prop->value.atom != NULL ) @@ -270,14 +268,14 @@ THE SOFTWARE. ( *(prop->value.atom) == 'I' ) ) root->style_flags |= FT_STYLE_FLAG_ITALIC; - prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" ); + prop = bdf_get_font_property( font, "WEIGHT_NAME" ); if ( prop != NULL ) if ( prop->format == BDF_ATOM ) if ( prop->value.atom != NULL ) if ( *(prop->value.atom) == 'B' ) root->style_flags |= FT_STYLE_FLAG_BOLD; - prop = bdf_get_font_property( font, (char *)"FAMILY_NAME" ); + prop = bdf_get_font_property( font, "FAMILY_NAME" ); if ( ( prop != NULL ) && ( prop->value.atom != NULL ) ) { int l = ft_strlen( prop->value.atom ) + 1; @@ -307,22 +305,24 @@ THE SOFTWARE. if ( FT_NEW_ARRAY( root->available_sizes, 1 ) ) goto Exit; - prop = bdf_get_font_property( font, (char *)"AVERAGE_WIDTH" ); + prop = bdf_get_font_property( font, "AVERAGE_WIDTH" ); if ( ( prop != NULL ) && ( prop->value.int32 >= 10 ) ) root->available_sizes->width = (short)( prop->value.int32 / 10 ); - prop = bdf_get_font_property( font, (char *)"PIXEL_SIZE" ); - if ( prop != NULL ) - root->available_sizes->height = (short) prop->value.int32; + prop = bdf_get_font_property( font, "PIXEL_SIZE" ); + if ( prop != NULL ) { + root->available_sizes->height = + root->available_sizes->width = (short) prop->value.int32; + } else { - prop = bdf_get_font_property( font, (char *)"POINT_SIZE" ); + prop = bdf_get_font_property( font, "POINT_SIZE" ); if ( prop != NULL ) { bdf_property_t *yres; - yres = bdf_get_font_property( font, (char *)"RESOLUTION_Y" ); + yres = bdf_get_font_property( font, "RESOLUTION_Y" ); if ( yres != NULL ) { FT_TRACE4(( "POINT_SIZE: %d RESOLUTION_Y: %d\n", @@ -371,9 +371,9 @@ THE SOFTWARE. charset_registry = - bdf_get_font_property( font, (char *)"CHARSET_REGISTRY" ); + bdf_get_font_property( font, "CHARSET_REGISTRY" ); charset_encoding = - bdf_get_font_property( font, (char *)"CHARSET_ENCODING" ); + bdf_get_font_property( font, "CHARSET_ENCODING" ); if ( ( charset_registry != NULL ) && ( charset_encoding != NULL ) ) { if ( ( charset_registry->format == BDF_ATOM ) && @@ -640,7 +640,7 @@ THE SOFTWARE. FT_ASSERT( face && face->bdffont ); - prop = bdf_get_font_property( face->bdffont, (char*)prop_name ); + prop = bdf_get_font_property( face->bdffont, prop_name ); if ( prop != NULL ) { switch ( prop->format ) diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index 06ce4ddbb..9d6cc52fb 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -183,10 +183,10 @@ (*hash_free_func)( hashnode node ); static hashnode* - hash_bucket( char* key, - hashtable* ht ) + hash_bucket( const char* key, + hashtable* ht ) { - char* kp = key; + const char* kp = key; unsigned long res = 0; hashnode* bp = ht->table, *ndp; @@ -317,7 +317,7 @@ static hashnode - hash_lookup( char* key, + hash_lookup( const char* key, hashtable* ht ) { hashnode *np = hash_bucket( key, ht ); @@ -1882,7 +1882,7 @@ /* */ /* This is *always* done regardless of the options, because X11 */ /* requires these two fields to compile fonts. */ - if ( bdf_get_font_property( p->font, (char *)"FONT_ASCENT" ) == 0 ) + if ( bdf_get_font_property( p->font, "FONT_ASCENT" ) == 0 ) { p->font->font_ascent = p->font->bbx.ascent; ft_sprintf( nbuf, "%hd", p->font->bbx.ascent ); @@ -1894,7 +1894,7 @@ p->font->modified = 1; } - if ( bdf_get_font_property( p->font, (char *)"FONT_DESCENT" ) == 0 ) + if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 ) { p->font->font_descent = p->font->bbx.descent; ft_sprintf( nbuf, "%hd", p->font->bbx.descent ); @@ -2418,7 +2418,7 @@ FT_LOCAL_DEF( bdf_property_t * ) bdf_get_font_property( bdf_font_t* font, - char* name ) + const char* name ) { hashnode hn; diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index 6c5c5d9ee..0d75d8961 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -2374,8 +2374,8 @@ metrics.bearing_x = decoder.builder.left_bearing.x; - metrics.bearing_y = decoder.builder.left_bearing.y; - metrics.advance = decoder.builder.advance.x; + metrics.bearing_y = decoder.builder.left_bearing.y; + metrics.advance = decoder.builder.advance.x; error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( face->root.internal->incremental_interface->object, glyph_index, FALSE, &metrics ); diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index 9d953d5e3..6de7fd99b 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -166,8 +166,8 @@ metrics.bearing_x = decoder->builder.left_bearing.x; - metrics.bearing_y = decoder->builder.left_bearing.y; - metrics.advance = decoder->builder.advance.x; + metrics.bearing_y = decoder->builder.left_bearing.y; + metrics.advance = decoder->builder.advance.x; error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( face->root.internal->incremental_interface->object, glyph_index, FALSE, &metrics ); diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index ac5f16e4a..acccd160c 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -4,7 +4,7 @@ /* */ /* CID objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -361,8 +361,10 @@ full++; } - root->style_name = ( *full == ' ' ) ? full + 1 - : (char *)"Regular"; + if ( *full == ' ' || *full == '-' ) + root->style_name = full + 1; + else + root->style_name = (char *)"Regular"; } else { diff --git a/src/gzip/ftgzip.c b/src/gzip/ftgzip.c index c9bd4a51d..d495800cd 100644 --- a/src/gzip/ftgzip.c +++ b/src/gzip/ftgzip.c @@ -48,12 +48,23 @@ #include "zlib.h" #undef SLOW -#define SLOW 1 /* we can't use asm-optimized sources here !! */ +#define SLOW 1 /* we can't use asm-optimized sources here! */ + /* Urgh. `inflate_mask' must not be declared twice -- C++ doesn't like + this. We temporarily rename it and load all necessary header files. */ +#define inflate_mask ft_gzip_dummy +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" +#undef inflate_mask + + /* infutil.c must be included before infcodes.c */ #include "zutil.c" #include "inftrees.c" -#include "infcodes.c" #include "infutil.c" +#include "infcodes.c" #include "infblock.c" #include "inflate.c" #include "adler32.c" @@ -102,14 +113,14 @@ unsigned items, unsigned size ) { - return ft_gzip_alloc( opaque, items, size ); + return ft_gzip_alloc( (FT_Memory)opaque, items, size ); } local void zcfree( voidpf opaque, voidpf ptr ) { - ft_gzip_free( opaque, ptr ); + ft_gzip_free( (FT_Memory)opaque, ptr ); } #endif /* !SYSTEM_ZLIB */ @@ -502,7 +513,7 @@ static void ft_gzip_stream_close( FT_Stream stream ) { - FT_GZipFile zip = stream->descriptor.pointer; + FT_GZipFile zip = (FT_GZipFile)stream->descriptor.pointer; FT_Memory memory = stream->memory; @@ -524,7 +535,7 @@ FT_Byte* buffer, FT_ULong count ) { - FT_GZipFile zip = stream->descriptor.pointer; + FT_GZipFile zip = (FT_GZipFile)stream->descriptor.pointer; return ft_gzip_file_io( zip, pos, buffer, count ); diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c index 269a088ee..2d46c2037 100644 --- a/src/pcf/pcfdriver.c +++ b/src/pcf/pcfdriver.c @@ -478,7 +478,7 @@ THE SOFTWARE. } else { - /* apparently, the PCF driver loads all properties as signed integers! + /* Apparently, the PCF driver loads all properties as signed integers! * This really doesn't seem to be a problem, because this is * sufficient for any meaningful values. */ diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c index ff11a8616..10c82607f 100644 --- a/src/pcf/pcfread.c +++ b/src/pcf/pcfread.c @@ -972,12 +972,12 @@ THE SOFTWARE. else root->family_name = 0; - /* note: we shift all glyph indices by +1 since we must - * respect the convention that glyph 0 always correspond - * to the "missing glyph". - * - * this implies bumping the number of "available" glyphs by 1 - */ + /* Note: We shift all glyph indices by +1 since we must + * respect the convention that glyph 0 always corresponds + * to the "missing glyph". + * + * This implies bumping the number of "available" glyphs by 1. + */ root->num_glyphs = face->nmetrics + 1; root->num_fixed_sizes = 1; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 5933adf9f..bd4f43175 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -355,8 +355,10 @@ full++; } - root->style_name = ( *full == ' ' ? full + 1 - : (char *)"Regular" ); + if ( *full == ' ' || *full == '-' ) + root->style_name = full + 1; + else + root->style_name = (char *)"Regular"; } else root->style_name = (char *)"Regular"; diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index af42379d6..88d2fac89 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -223,8 +223,10 @@ full++; } - root->style_name = ( *full == ' ' ? full + 1 - : (char *)"Regular" ); + if ( *full == ' ' || *full == '-' ) + root->style_name = full + 1; + else + root->style_name = (char *)"Regular"; } else root->style_name = (char *)"Regular";