diff options
Diffstat (limited to 'src/3rdparty/freetype/src/pcf')
-rw-r--r-- | src/3rdparty/freetype/src/pcf/Jamfile | 7 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pcf/pcf.h | 4 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pcf/pcfdrivr.c | 67 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pcf/pcfread.c | 99 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/pcf/rules.mk | 5 |
5 files changed, 117 insertions, 65 deletions
diff --git a/src/3rdparty/freetype/src/pcf/Jamfile b/src/3rdparty/freetype/src/pcf/Jamfile index 752fcac2a1..f4789ea625 100644 --- a/src/3rdparty/freetype/src/pcf/Jamfile +++ b/src/3rdparty/freetype/src/pcf/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pcf Jamfile # -# Copyright 2001, 2003 by +# Copyright 2001-2015 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -16,7 +16,10 @@ SubDir FT2_TOP $(FT2_SRC_DIR) pcf ; if $(FT2_MULTI) { - _sources = pcfdrivr pcfread pcfutil ; + _sources = pcfdrivr + pcfread + pcfutil + ; } else { diff --git a/src/3rdparty/freetype/src/pcf/pcf.h b/src/3rdparty/freetype/src/pcf/pcf.h index af0ffc3378..c0da503412 100644 --- a/src/3rdparty/freetype/src/pcf/pcf.h +++ b/src/3rdparty/freetype/src/pcf/pcf.h @@ -148,9 +148,9 @@ FT_BEGIN_HEADER int nprops; PCF_Property properties; - FT_Long nmetrics; + FT_ULong nmetrics; PCF_Metric metrics; - FT_Long nencodings; + FT_ULong nencodings; PCF_Encoding encodings; FT_Short defaultChar; diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.c b/src/3rdparty/freetype/src/pcf/pcfdrivr.c index 96f6912ba9..8d2ed7cf4d 100644 --- a/src/3rdparty/freetype/src/pcf/pcfdrivr.c +++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.c @@ -48,7 +48,7 @@ THE SOFTWARE. #define FT_COMPONENT trace_pcfread #include FT_SERVICE_BDF_H -#include FT_SERVICE_XFREE86_NAME_H +#include FT_SERVICE_FONT_FORMAT_H /*************************************************************************/ @@ -64,7 +64,7 @@ THE SOFTWARE. typedef struct PCF_CMapRec_ { FT_CMapRec root; - FT_UInt num_encodings; + FT_ULong num_encodings; PCF_Encoding encodings; } PCF_CMapRec, *PCF_CMap; @@ -80,7 +80,7 @@ THE SOFTWARE. FT_UNUSED( init_data ); - cmap->num_encodings = (FT_UInt)face->nencodings; + cmap->num_encodings = face->nencodings; cmap->encodings = face->encodings; return FT_Err_Ok; @@ -104,7 +104,7 @@ THE SOFTWARE. { PCF_CMap cmap = (PCF_CMap)pcfcmap; PCF_Encoding encodings = cmap->encodings; - FT_UInt min, max, mid; + FT_ULong min, max, mid; FT_UInt result = 0; @@ -117,7 +117,7 @@ THE SOFTWARE. mid = ( min + max ) >> 1; - code = encodings[mid].enc; + code = (FT_ULong)encodings[mid].enc; if ( charcode == code ) { @@ -141,7 +141,7 @@ THE SOFTWARE. { PCF_CMap cmap = (PCF_CMap)pcfcmap; PCF_Encoding encodings = cmap->encodings; - FT_UInt min, max, mid; + FT_ULong min, max, mid; FT_ULong charcode = *acharcode + 1; FT_UInt result = 0; @@ -155,7 +155,7 @@ THE SOFTWARE. mid = ( min + max ) >> 1; - code = encodings[mid].enc; + code = (FT_ULong)encodings[mid].enc; if ( charcode == code ) { @@ -172,7 +172,7 @@ THE SOFTWARE. charcode = 0; if ( min < cmap->num_encodings ) { - charcode = encodings[min].enc; + charcode = (FT_ULong)encodings[min].enc; result = encodings[min].glyph + 1; } @@ -345,13 +345,14 @@ THE SOFTWARE. #endif } - /* PCF could not have multiple face in single font file. - * XXX: non-zero face_index is already invalid argument, but - * Type1, Type42 driver has a convention to return + /* PCF cannot have multiple faces in a single font file. + * XXX: A non-zero face_index is already an invalid argument, but + * Type1, Type42 drivers have a convention to return * an invalid argument error when the font could be * opened by the specified driver. */ - if ( face_index > 0 ) { + if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 ) + { FT_ERROR(( "PCF_Face_Init: invalid face index\n" )); PCF_Face_Done( pcfface ); return FT_THROW( Invalid_Argument ); @@ -430,9 +431,9 @@ THE SOFTWARE. FT_Select_Metrics( size->face, strike_index ); - size->metrics.ascender = accel->fontAscent << 6; - size->metrics.descender = -accel->fontDescent << 6; - size->metrics.max_advance = accel->maxbounds.characterWidth << 6; + size->metrics.ascender = accel->fontAscent * 64; + size->metrics.descender = -accel->fontDescent * 64; + size->metrics.max_advance = accel->maxbounds.characterWidth * 64; return FT_Err_Ok; } @@ -487,7 +488,7 @@ THE SOFTWARE. FT_Error error = FT_Err_Ok; FT_Bitmap* bitmap = &slot->bitmap; PCF_Metric metric; - FT_Offset bytes; + FT_ULong bytes; FT_UNUSED( load_flags ); @@ -513,8 +514,10 @@ THE SOFTWARE. metric = face->metrics + glyph_index; - bitmap->rows = metric->ascent + metric->descent; - bitmap->width = metric->rightSideBearing - metric->leftSideBearing; + bitmap->rows = (unsigned int)( metric->ascent + + metric->descent ); + bitmap->width = (unsigned int)( metric->rightSideBearing - + metric->leftSideBearing ); bitmap->num_grays = 1; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; @@ -526,19 +529,19 @@ THE SOFTWARE. switch ( PCF_GLYPH_PAD( face->bitmapsFormat ) ) { case 1: - bitmap->pitch = ( bitmap->width + 7 ) >> 3; + bitmap->pitch = (int)( ( bitmap->width + 7 ) >> 3 ); break; case 2: - bitmap->pitch = ( ( bitmap->width + 15 ) >> 4 ) << 1; + bitmap->pitch = (int)( ( ( bitmap->width + 15 ) >> 4 ) << 1 ); break; case 4: - bitmap->pitch = ( ( bitmap->width + 31 ) >> 5 ) << 2; + bitmap->pitch = (int)( ( ( bitmap->width + 31 ) >> 5 ) << 2 ); break; case 8: - bitmap->pitch = ( ( bitmap->width + 63 ) >> 6 ) << 3; + bitmap->pitch = (int)( ( ( bitmap->width + 63 ) >> 6 ) << 3 ); break; default: @@ -546,7 +549,7 @@ THE SOFTWARE. } /* XXX: to do: are there cases that need repadding the bitmap? */ - bytes = bitmap->pitch * bitmap->rows; + bytes = (FT_ULong)bitmap->pitch * bitmap->rows; error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes ); if ( error ) @@ -581,16 +584,16 @@ THE SOFTWARE. slot->bitmap_left = metric->leftSideBearing; slot->bitmap_top = metric->ascent; - slot->metrics.horiAdvance = metric->characterWidth << 6; - slot->metrics.horiBearingX = metric->leftSideBearing << 6; - slot->metrics.horiBearingY = metric->ascent << 6; - slot->metrics.width = ( metric->rightSideBearing - - metric->leftSideBearing ) << 6; - slot->metrics.height = bitmap->rows << 6; + slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 ); + slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 ); + slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 ); + slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing - + metric->leftSideBearing ) * 64 ); + slot->metrics.height = (FT_Pos)( bitmap->rows * 64 ); ft_synthesize_vertical_metrics( &slot->metrics, ( face->accel.fontAscent + - face->accel.fontDescent ) << 6 ); + face->accel.fontDescent ) * 64 ); Exit: return error; @@ -667,8 +670,8 @@ THE SOFTWARE. static const FT_ServiceDescRec pcf_services[] = { - { FT_SERVICE_ID_BDF, &pcf_service_bdf }, - { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_PCF }, + { FT_SERVICE_ID_BDF, &pcf_service_bdf }, + { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PCF }, { NULL, NULL } }; diff --git a/src/3rdparty/freetype/src/pcf/pcfread.c b/src/3rdparty/freetype/src/pcf/pcfread.c index a29a9e371b..afa1480771 100644 --- a/src/3rdparty/freetype/src/pcf/pcfread.c +++ b/src/3rdparty/freetype/src/pcf/pcfread.c @@ -448,14 +448,14 @@ THE SOFTWARE. pcf_get_properties( FT_Stream stream, PCF_Face face ) { - PCF_ParseProperty props = 0; + PCF_ParseProperty props = NULL; PCF_Property properties = NULL; FT_ULong nprops, i; FT_ULong format, size; FT_Error error; FT_Memory memory = FT_FACE( face )->memory; FT_ULong string_size; - FT_String* strings = 0; + FT_String* strings = NULL; error = pcf_seek_to_table_type( stream, @@ -485,9 +485,9 @@ THE SOFTWARE. goto Bail; FT_TRACE4(( " nprop = %d (truncate %d props)\n", - (int)nprops, nprops - (int)nprops )); + (int)nprops, nprops - (FT_ULong)(int)nprops )); - nprops = (int)nprops; + nprops = (FT_ULong)(int)nprops; /* rough estimate */ if ( nprops > size / PCF_PROPERTY_SIZE ) @@ -620,7 +620,7 @@ THE SOFTWARE. FT_Error error; FT_Memory memory = FT_FACE( face )->memory; FT_ULong format, size; - PCF_Metric metrics = 0; + PCF_Metric metrics = NULL; FT_ULong nmetrics, i; @@ -766,8 +766,7 @@ THE SOFTWARE. FT_TRACE4(( " number of bitmaps: %d\n", nbitmaps )); - /* XXX: PCF_Face->nmetrics is signed FT_Long, see pcf.h */ - if ( face->nmetrics < 0 || nbitmaps != (FT_ULong)face->nmetrics ) + if ( nbitmaps != face->nmetrics ) return FT_THROW( Invalid_File_Format ); if ( FT_NEW_ARRAY( offsets, nbitmaps ) ) @@ -795,9 +794,10 @@ THE SOFTWARE. if ( error ) goto Bail; - sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX( format )]; + sizebitmaps = (FT_ULong)bitmapSizes[PCF_GLYPH_PAD_INDEX( format )]; - FT_TRACE4(( " padding %d implies a size of %ld\n", i, bitmapSizes[i] )); + FT_TRACE4(( " padding %d implies a size of %ld\n", + i, bitmapSizes[i] )); } FT_TRACE4(( " %d bitmaps, padding index %ld\n", @@ -817,7 +817,7 @@ THE SOFTWARE. " invalid offset to bitmap data of glyph %d\n", i )); } else - face->metrics[i].bits = stream->pos + offsets[i]; + face->metrics[i].bits = stream->pos + (FT_ULong)offsets[i]; } face->bitmapsFormat = format; @@ -837,8 +837,10 @@ THE SOFTWARE. FT_ULong format, size; int firstCol, lastCol; int firstRow, lastRow; - int nencoding, encodingOffset; - int i, j, k; + FT_ULong nencoding; + int encodingOffset; + int i, j; + FT_ULong k; PCF_Encoding encoding = NULL; @@ -893,7 +895,8 @@ THE SOFTWARE. FT_TRACE4(( " firstCol %d, lastCol %d, firstRow %d, lastRow %d\n", firstCol, lastCol, firstRow, lastRow )); - nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 ); + nencoding = (FT_ULong)( lastCol - firstCol + 1 ) * + (FT_ULong)( lastRow - firstRow + 1 ); if ( FT_NEW_ARRAY( encoding, nencoding ) ) return FT_THROW( Out_Of_Memory ); @@ -912,10 +915,10 @@ THE SOFTWARE. else encodingOffset = FT_GET_SHORT_LE(); - if ( encodingOffset != -1 ) + if ( encodingOffset > -1 ) { encoding[k].enc = i * 256 + j; - encoding[k].glyph = (FT_Short)encodingOffset; + encoding[k].glyph = (FT_UShort)encodingOffset; FT_TRACE5(( " code %d (0x%04X): idx %d\n", encoding[k].enc, encoding[k].enc, encoding[k].glyph )); @@ -1256,7 +1259,7 @@ THE SOFTWARE. * * This implies bumping the number of `available' glyphs by 1. */ - root->num_glyphs = face->nmetrics + 1; + root->num_glyphs = (FT_Long)( face->nmetrics + 1 ); root->num_fixed_sizes = 1; if ( FT_NEW_ARRAY( root->available_sizes, 1 ) ) @@ -1269,51 +1272,91 @@ THE SOFTWARE. FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) ); + /* for simplicity, we take absolute values of integer properties */ + #if 0 bsize->height = face->accel.maxbounds.ascent << 6; #endif - bsize->height = (FT_Short)( face->accel.fontAscent + - face->accel.fontDescent ); + +#ifdef FT_DEBUG_LEVEL_TRACE + if ( face->accel.fontAscent + face->accel.fontDescent < 0 ) + FT_TRACE0(( "pcf_load_font: negative height\n" )); +#endif + bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent + + face->accel.fontDescent ) ); prop = pcf_find_property( face, "AVERAGE_WIDTH" ); if ( prop ) - bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 ); + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "pcf_load_font: negative average width\n" )); +#endif + bsize->width = FT_ABS( (FT_Short)( ( prop->value.l ) + 5 ) / 10 ); + } else - bsize->width = (FT_Short)( bsize->height * 2/3 ); + bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 ); prop = pcf_find_property( face, "POINT_SIZE" ); if ( prop ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "pcf_load_font: negative point size\n" )); +#endif /* convert from 722.7 decipoints to 72 points per inch */ - bsize->size = - (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L ); + bsize->size = FT_MulDiv( FT_ABS( prop->value.l ), + 64 * 7200, + 72270L ); + } prop = pcf_find_property( face, "PIXEL_SIZE" ); if ( prop ) - bsize->y_ppem = (FT_Short)prop->value.l << 6; + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "pcf_load_font: negative pixel size\n" )); +#endif + bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6; + } prop = pcf_find_property( face, "RESOLUTION_X" ); if ( prop ) - resolution_x = (FT_Short)prop->value.l; + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "pcf_load_font: negative X resolution\n" )); +#endif + resolution_x = FT_ABS( (FT_Short)prop->value.l ); + } prop = pcf_find_property( face, "RESOLUTION_Y" ); if ( prop ) - resolution_y = (FT_Short)prop->value.l; + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "pcf_load_font: negative Y resolution\n" )); +#endif + resolution_y = FT_ABS( (FT_Short)prop->value.l ); + } if ( bsize->y_ppem == 0 ) { bsize->y_ppem = bsize->size; if ( resolution_y ) - bsize->y_ppem = bsize->y_ppem * resolution_y / 72; + bsize->y_ppem = FT_MulDiv( bsize->y_ppem, resolution_y, 72 ); } if ( resolution_x && resolution_y ) - bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y; + bsize->x_ppem = FT_MulDiv( bsize->y_ppem, + resolution_x, + resolution_y ); else bsize->x_ppem = bsize->y_ppem; } /* set up charset */ { - PCF_Property charset_registry = 0, charset_encoding = 0; + PCF_Property charset_registry, charset_encoding; charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" ); diff --git a/src/3rdparty/freetype/src/pcf/rules.mk b/src/3rdparty/freetype/src/pcf/rules.mk index 78641528fa..1b55daf4f4 100644 --- a/src/3rdparty/freetype/src/pcf/rules.mk +++ b/src/3rdparty/freetype/src/pcf/rules.mk @@ -30,7 +30,10 @@ PCF_DIR := $(SRC_DIR)/pcf -PCF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PCF_DIR)) +PCF_COMPILE := $(CC) $(ANSIFLAGS) \ + $I$(subst /,$(COMPILER_SEP),$(PCF_DIR)) \ + $(INCLUDE_FLAGS) \ + $(FT_CFLAGS) # pcf driver sources (i.e., C files) |