FreeType font driver for pcf files
- Copyright (C) 2000-2004, 2006-2011 by
+ Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
cmap->num_encodings = (FT_UInt)face->nencodings;
cmap->encodings = face->encodings;
- return PCF_Err_Ok;
+ return FT_Err_Ok;
}
}
- FT_CALLBACK_TABLE_DEF
+ static
const FT_CMap_ClassRec pcf_cmap_class =
{
sizeof ( PCF_CMapRec ),
FT_FREE( face->metrics );
/* free properties */
+ if ( face->properties )
{
- PCF_Property prop;
- FT_Int i;
+ FT_Int i;
- if ( face->properties )
+ for ( i = 0; i < face->nprops; i++ )
{
- for ( i = 0; i < face->nprops; i++ )
+ PCF_Property prop = &face->properties[i];
+
+
+ if ( prop )
{
- prop = &face->properties[i];
-
- if ( prop )
- {
- FT_FREE( prop->name );
- if ( prop->isString )
- FT_FREE( prop->value.atom );
- }
+ FT_FREE( prop->name );
+ if ( prop->isString )
+ FT_FREE( prop->value.atom );
}
}
+
FT_FREE( face->properties );
}
FT_Parameter* params )
{
PCF_Face face = (PCF_Face)pcfface;
- FT_Error error = PCF_Err_Ok;
+ FT_Error error;
FT_UNUSED( num_params );
FT_UNUSED( params );
- FT_UNUSED( face_index );
FT_TRACE2(( "PCF driver\n" ));
/* this didn't work, try gzip support! */
error2 = FT_Stream_OpenGzip( &face->comp_stream, stream );
- if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature )
+ if ( FT_ERR_EQ( error2, Unimplemented_Feature ) )
goto Fail;
error = error2;
/* this didn't work, try LZW support! */
error3 = FT_Stream_OpenLZW( &face->comp_stream, stream );
- if ( FT_ERROR_BASE( error3 ) == FT_Err_Unimplemented_Feature )
+ if ( FT_ERR_EQ( error3, Unimplemented_Feature ) )
goto Fail;
error = error3;
/* this didn't work, try Bzip2 support! */
error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream );
- if ( FT_ERROR_BASE( error4 ) == FT_Err_Unimplemented_Feature )
+ if ( FT_ERR_EQ( error4, Unimplemented_Feature ) )
goto Fail;
error = error4;
#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
+ * an invalid argument error when the font could be
+ * opened by the specified driver.
+ */
+ if ( face_index > 0 ) {
+ FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
+ PCF_Face_Done( pcfface );
+ return FT_THROW( Invalid_Argument );
+ }
+
/* set up charmap */
{
FT_String *charset_registry = face->charset_registry;
Fail:
FT_TRACE2(( " not a PCF file\n" ));
PCF_Face_Done( pcfface );
- error = PCF_Err_Unknown_File_Format; /* error */
+ error = FT_THROW( Unknown_File_Format ); /* error */
goto Exit;
}
size->metrics.descender = -accel->fontDescent << 6;
size->metrics.max_advance = accel->maxbounds.characterWidth << 6;
- return PCF_Err_Ok;
+ return FT_Err_Ok;
}
{
PCF_Face face = (PCF_Face)size->face;
FT_Bitmap_Size* bsize = size->face->available_sizes;
- FT_Error error = PCF_Err_Invalid_Pixel_Size;
+ FT_Error error = FT_ERR( Invalid_Pixel_Size );
FT_Long height;
{
case FT_SIZE_REQUEST_TYPE_NOMINAL:
if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
- error = PCF_Err_Ok;
+ error = FT_Err_Ok;
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
if ( height == ( face->accel.fontAscent +
face->accel.fontDescent ) )
- error = PCF_Err_Ok;
+ error = FT_Err_Ok;
break;
default:
- error = PCF_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
break;
}
{
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
FT_Stream stream;
- FT_Error error = PCF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Bitmap* bitmap = &slot->bitmap;
PCF_Metric metric;
FT_Offset bytes;
FT_UNUSED( load_flags );
- FT_TRACE4(( "load_glyph %d ---", glyph_index ));
+ FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
- if ( !face || glyph_index >= (FT_UInt)face->root.num_glyphs )
+ if ( !face )
{
- error = PCF_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Face_Handle );
+ goto Exit;
+ }
+
+ if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
+ {
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
break;
default:
- return PCF_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
}
/* XXX: to do: are there cases that need repadding the bitmap? */
bytes = bitmap->pitch * bitmap->rows;
- error = ft_glyphslot_alloc_bitmap( slot, bytes );
+ error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes );
if ( error )
goto Exit;
( face->accel.fontAscent +
face->accel.fontDescent ) << 6 );
- FT_TRACE4(( " --- ok\n" ));
-
Exit:
return error;
}
return 0;
}
- return PCF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
0, /* FT_Slot_InitFunc */
0, /* FT_Slot_DoneFunc */
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
PCF_Glyph_Load,
0, /* FT_Face_GetKerningFunc */