summaryrefslogtreecommitdiff
path: root/src/freetype2/pcf/pcfdrivr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/freetype2/pcf/pcfdrivr.c')
-rw-r--r--src/freetype2/pcf/pcfdrivr.c101
1 files changed, 64 insertions, 37 deletions
diff --git a/src/freetype2/pcf/pcfdrivr.c b/src/freetype2/pcf/pcfdrivr.c
index c0f0e49..b34e542 100644
--- a/src/freetype2/pcf/pcfdrivr.c
+++ b/src/freetype2/pcf/pcfdrivr.c
@@ -2,7 +2,7 @@
FreeType font driver for pcf files
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 by
+ Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -111,7 +111,7 @@ THE SOFTWARE.
while ( min < max )
{
- FT_UInt32 code;
+ FT_ULong code;
mid = ( min + max ) >> 1;
@@ -140,7 +140,7 @@ THE SOFTWARE.
PCF_CMap cmap = (PCF_CMap)pcfcmap;
PCF_Encoding encodings = cmap->encodings;
FT_UInt min, max, mid;
- FT_UInt32 charcode = *acharcode + 1;
+ FT_ULong charcode = *acharcode + 1;
FT_UInt result = 0;
@@ -149,7 +149,7 @@ THE SOFTWARE.
while ( min < max )
{
- FT_UInt32 code;
+ FT_ULong code;
mid = ( min + max ) >> 1;
@@ -175,7 +175,14 @@ THE SOFTWARE.
}
Exit:
- *acharcode = charcode;
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "pcf_cmap_char_next: charcode 0x%x > 32bit API" ));
+ *acharcode = 0;
+ /* XXX: result should be changed to indicate an overflow error */
+ }
+ else
+ *acharcode = (FT_UInt32)charcode;
return result;
}
@@ -187,17 +194,24 @@ THE SOFTWARE.
pcf_cmap_init,
pcf_cmap_done,
pcf_cmap_char_index,
- pcf_cmap_char_next
+ pcf_cmap_char_next,
+
+ NULL, NULL, NULL, NULL, NULL
};
FT_CALLBACK_DEF( void )
PCF_Face_Done( FT_Face pcfface ) /* PCF_Face */
{
- PCF_Face face = (PCF_Face)pcfface;
- FT_Memory memory = FT_FACE_MEMORY( face );
+ PCF_Face face = (PCF_Face)pcfface;
+ FT_Memory memory;
+ if ( !face )
+ return;
+
+ memory = FT_FACE_MEMORY( face );
+
FT_FREE( face->encodings );
FT_FREE( face->metrics );
@@ -259,17 +273,26 @@ THE SOFTWARE.
error = pcf_load_font( stream, face );
if ( error )
{
- FT_Error error2;
+ PCF_Face_Done( pcfface );
+#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \
+ defined( FT_CONFIG_OPTION_USE_LZW )
- PCF_Face_Done( pcfface );
+#ifdef FT_CONFIG_OPTION_USE_ZLIB
+ {
+ FT_Error error2;
- /* this didn't work, try gzip support! */
- error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream );
- if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature )
- goto Fail;
- error = error2;
+ /* this didn't work, try gzip support! */
+ error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream );
+ if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature )
+ goto Fail;
+
+ error = error2;
+ }
+#endif /* FT_CONFIG_OPTION_USE_ZLIB */
+
+#ifdef FT_CONFIG_OPTION_USE_LZW
if ( error )
{
FT_Error error3;
@@ -281,29 +304,26 @@ THE SOFTWARE.
goto Fail;
error = error3;
- if ( error )
- goto Fail;
+ }
+#endif /* FT_CONFIG_OPTION_USE_LZW */
- face->gzip_source = stream;
- pcfface->stream = &face->gzip_stream;
+ if ( error )
+ goto Fail;
- stream = pcfface->stream;
+ face->gzip_source = stream;
+ pcfface->stream = &face->gzip_stream;
- error = pcf_load_font( stream, face );
- if ( error )
- goto Fail;
- }
- else
- {
- face->gzip_source = stream;
- pcfface->stream = &face->gzip_stream;
+ stream = pcfface->stream;
+
+ error = pcf_load_font( stream, face );
+ if ( error )
+ goto Fail;
- stream = pcfface->stream;
+#else /* !(FT_CONFIG_OPTION_USE_ZLIB || FT_CONFIG_OPTION_USE_LZW) */
- error = pcf_load_font( stream, face );
- if ( error )
- goto Fail;
- }
+ goto Fail;
+
+#endif
}
/* set up charmap */
@@ -402,7 +422,7 @@ THE SOFTWARE.
switch ( req->type )
{
case FT_SIZE_REQUEST_TYPE_NOMINAL:
- if ( height == ( bsize->y_ppem + 32 ) >> 6 )
+ if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
error = PCF_Err_Ok;
break;
@@ -431,11 +451,11 @@ THE SOFTWARE.
FT_Int32 load_flags )
{
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
- FT_Stream stream = face->root.stream;
+ FT_Stream stream;
FT_Error error = PCF_Err_Ok;
FT_Bitmap* bitmap = &slot->bitmap;
PCF_Metric metric;
- int bytes;
+ FT_Offset bytes;
FT_UNUSED( load_flags );
@@ -448,6 +468,8 @@ THE SOFTWARE.
goto Exit;
}
+ stream = face->root.stream;
+
if ( glyph_index > 0 )
glyph_index--;
@@ -563,12 +585,17 @@ THE SOFTWARE.
}
else
{
+ if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
+ {
+ FT_TRACE1(( "pcf_get_bdf_property: " ));
+ FT_TRACE1(( "too large integer 0x%x is truncated\n" ));
+ }
/* 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.
*/
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
- aproperty->u.integer = prop->value.integer;
+ aproperty->u.integer = (FT_Int32)prop->value.l;
}
return 0;
}