ref: 4e9dae68b74411f9a5a1a1ba390868f83a17c7ba
parent: 80b96f350c8ea73f7da0dd76fc5c075dcbfdfaa9
author: Werner Lemberg <[email protected]>
date: Tue Aug 29 12:50:01 EDT 2000
Introducing new macro LOCA_VAR to solve some problems with structures containing function pointers. FT will now compile again with C++.
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -138,7 +138,6 @@
#else
-
/*************************************************************************/
/* */
/* Many compilers provide the non-ANSI `long long' 64-bit type. You can */
@@ -174,6 +173,13 @@
#endif
#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
+
+
+#ifdef __cplusplus
+#define LOCAL_VAR extern "C"
+#else
+#define LOCAL_VAR extern
+#endif
#ifndef BASE_DEF
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -77,10 +77,10 @@
typedef enum T1_EncodingType_
{
- t1_encoding_none = 0,
- t1_encoding_array,
- t1_encoding_standard,
- t1_encoding_expert
+ t1_encoding_none = 0,
+ t1_encoding_array,
+ t1_encoding_standard,
+ t1_encoding_expert
} T1_EncodingType;
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -22,6 +22,7 @@
#include <freetype/internal/ftlist.h>
#include <freetype/fterrors.h>
+
/**************************************************************************/
/**************************************************************************/
/***** *****/
@@ -74,7 +75,7 @@
/*************************************************************************/
- static
+ LOCAL_FUNC_X
void ftc_done_glyph_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
@@ -84,7 +85,7 @@
}
- static
+ LOCAL_FUNC_X
FT_ULong ftc_size_bitmap_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
@@ -103,7 +104,7 @@
}
- static
+ LOCAL_FUNC_X
FT_ULong ftc_size_outline_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
@@ -123,7 +124,7 @@
}
- static
+ LOCAL_FUNC_X
FT_Error ftc_init_glyph_image( FTC_Image_Queue queue,
FTC_ImageNode node )
{
@@ -131,6 +132,7 @@
FT_Size size;
FT_Error error;
+
error = FTC_Manager_Lookup_Size( queue->manager,
&queue->descriptor.size,
&face, &size );
@@ -140,7 +142,7 @@
FT_UInt load_flags = FT_LOAD_DEFAULT;
FT_UInt image_type = queue->descriptor.image_type;
- if ( FTC_IMAGE_FORMAT(image_type) == ftc_image_format_bitmap )
+ if ( FTC_IMAGE_FORMAT( image_type ) == ftc_image_format_bitmap )
{
load_flags |= FT_LOAD_RENDER;
if ( image_type & ftc_image_flag_monochrome )
@@ -147,22 +149,22 @@
load_flags |= FT_LOAD_MONOCHROME;
/* disable embedded bitmaps loading if necessary */
- if (load_flags & ftc_image_flag_no_sbits)
+ if ( load_flags & ftc_image_flag_no_sbits )
load_flags |= FT_LOAD_NO_BITMAP;
}
- else if ( FTC_IMAGE_FORMAT(image_type) == ftc_image_format_outline )
+ else if ( FTC_IMAGE_FORMAT( image_type ) == ftc_image_format_outline )
{
/* disable embedded bitmaps loading */
load_flags |= FT_LOAD_NO_BITMAP;
- if (image_type & ftc_image_flag_unscaled)
+ if ( image_type & ftc_image_flag_unscaled )
load_flags |= FT_LOAD_NO_SCALE;
}
- if (image_type & ftc_image_flag_unhinted)
+ if ( image_type & ftc_image_flag_unhinted )
load_flags |= FT_LOAD_NO_HINTING;
- if (image_type & ftc_image_flag_autohinted)
+ if ( image_type & ftc_image_flag_autohinted )
load_flags |= FT_LOAD_FORCE_AUTOHINT;
error = FT_Load_Glyph( face, glyph_index, load_flags );
@@ -187,11 +189,7 @@
}
-
-
-
- static
- const FTC_Image_Class ftc_bitmap_image_class =
+ FT_CPLUSPLUS( const FTC_Image_Class ) ftc_bitmap_image_class =
{
ftc_init_glyph_image,
ftc_done_glyph_image,
@@ -198,8 +196,7 @@
ftc_size_bitmap_image
};
- static
- const FTC_Image_Class ftc_outline_image_class =
+ FT_CPLUSPLUS( const FTC_Image_Class ) ftc_outline_image_class =
{
ftc_init_glyph_image,
ftc_done_glyph_image,
@@ -233,20 +230,20 @@
if ( ALLOC_ARRAY( queue->buckets, queue->hash_size, FT_ListRec ) )
goto Exit;
- switch (FTC_IMAGE_FORMAT(desc->image_type))
+ switch ( FTC_IMAGE_FORMAT( desc->image_type ) )
{
- case ftc_image_format_bitmap:
- clazz = &ftc_bitmap_image_class;
- break;
+ case ftc_image_format_bitmap:
+ clazz = &ftc_bitmap_image_class;
+ break;
- case ftc_image_format_outline:
- clazz = &ftc_outline_image_class;
- break;
+ case ftc_image_format_outline:
+ clazz = &ftc_outline_image_class;
+ break;
- default:
- /* invalid image type! */
- error = FT_Err_Invalid_Argument;
- goto Exit;
+ default:
+ /* invalid image type! */
+ error = FT_Err_Invalid_Argument;
+ goto Exit;
}
queue->clazz = (FTC_Image_Class*)clazz;
@@ -288,8 +285,8 @@
queue->clazz->done_image( queue, inode );
FT_List_Remove( glyphs_lru, lrunode );
- cache->num_bytes -= queue->clazz->size_image(queue,inode) +
- sizeof(FTC_ImageNodeRec);
+ cache->num_bytes -= queue->clazz->size_image( queue, inode ) +
+ sizeof( FTC_ImageNodeRec );
FTC_ImageNode_Done( cache, inode );
}
@@ -321,7 +318,7 @@
FT_UInt gindex;
inode = (FTC_ImageNode)node;
- gindex = FTC_IMAGENODE_GET_GINDEX(inode);
+ gindex = FTC_IMAGENODE_GET_GINDEX( inode );
if ( gindex == glyph_index )
{
@@ -354,8 +351,8 @@
/* insert the node at the start the global LRU glyph list */
FT_List_Insert( &cache->glyphs_lru, FTC_IMAGENODE_TO_LISTNODE( inode ) );
- cache->num_bytes += queue->clazz->size_image(queue,inode) +
- sizeof(FTC_ImageNodeRec);
+ cache->num_bytes += queue->clazz->size_image( queue, inode ) +
+ sizeof( FTC_ImageNodeRec );
*anode = inode;
@@ -381,7 +378,7 @@
( (FTC_Image_Queue)(node)->root.data )
- static
+ LOCAL_FUNC_X
FT_Error ftc_image_cache_init_queue( FT_Lru lru,
FT_LruNode node )
{
@@ -403,7 +400,7 @@
}
- static
+ LOCAL_FUNC_X
void ftc_image_cache_done_queue( FT_Lru lru,
FT_LruNode node )
{
@@ -416,7 +413,7 @@
}
- static
+ LOCAL_FUNC_X
FT_Bool ftc_image_cache_compare_queue( FT_LruNode node,
FT_LruKey key )
{
@@ -432,8 +429,7 @@
}
- static
- const FT_Lru_Class ftc_image_queue_lru_class =
+ FT_CPLUSPLUS( const FT_Lru_Class ) ftc_image_queue_lru_class =
{
sizeof( FT_LruRec ),
ftc_image_cache_init_queue,
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -23,15 +23,16 @@
#define FTC_LRU_GET_MANAGER( lru ) (FTC_Manager)lru->user_data
- /**************************************************************************/
- /**************************************************************************/
- /***** *****/
- /***** FACE & SIZE LRU CALLBACKS *****/
- /***** *****/
- /**************************************************************************/
- /**************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FACE & SIZE LRU CALLBACKS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- static
+
+ LOCAL_FUNC_X
FT_Error ftc_manager_init_face( FT_Lru lru,
FT_LruNode node )
{
@@ -57,7 +58,7 @@
/* helper function for ftc_manager_done_face */
- static
+ LOCAL_FUNC_X
FT_Bool ftc_manager_size_selector( FT_Lru lru,
FT_LruNode node,
FT_Pointer data )
@@ -68,7 +69,7 @@
}
- static
+ LOCAL_FUNC_X
void ftc_manager_done_face( FT_Lru lru,
FT_LruNode node )
{
@@ -97,7 +98,7 @@
} FTC_SizeRequest;
- static
+ LOCAL_FUNC_X
FT_Error ftc_manager_init_size( FT_Lru lru,
FT_LruNode node )
{
@@ -126,7 +127,7 @@
}
- static
+ LOCAL_FUNC_X
void ftc_manager_done_size( FT_Lru lru,
FT_LruNode node )
{
@@ -136,7 +137,7 @@
}
- static
+ LOCAL_FUNC_X
FT_Error ftc_manager_flush_size( FT_Lru lru,
FT_LruNode node,
FT_LruKey key )
@@ -163,7 +164,7 @@
}
- static
+ LOCAL_FUNC_X
FT_Bool ftc_manager_compare_size( FT_LruNode node,
FT_LruKey key )
{
@@ -179,8 +180,7 @@
}
- static
- const FT_Lru_Class ftc_face_lru_class =
+ FT_CPLUSPLUS( const FT_Lru_Class ) ftc_face_lru_class =
{
sizeof ( FT_LruRec ),
ftc_manager_init_face,
@@ -190,8 +190,7 @@
};
- static
- const FT_Lru_Class ftc_size_lru_class =
+ FT_CPLUSPLUS( const FT_Lru_Class ) ftc_size_lru_class =
{
sizeof ( FT_LruRec ),
ftc_manager_init_size,
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -44,7 +44,7 @@
#define FT_COMPONENT trace_cidgload
- static
+ LOCAL_FUNC_X
FT_Error cid_load_glyph( T1_Decoder* decoder,
FT_UInt glyph_index )
{
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -283,7 +283,7 @@
T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
T1_FIELD_CALLBACK( "FDArray", parse_fd_array )
T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix )
- { 0, 0, 0, 0, 0, 0, 0, 0 }
+ { 0, t1_field_cid_info, t1_field_none, 0, 0, 0, 0, 0 }
};
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -21,8 +21,7 @@
#include <psaux/t1decode.h>
- LOCAL_FUNC
- const PS_Table_Funcs ps_table_funcs =
+ FT_CPLUSPLUS( const PS_Table_Funcs ) ps_table_funcs =
{
PS_Table_New,
PS_Table_Done,
@@ -31,8 +30,7 @@
};
- LOCAL_FUNC
- const T1_Parser_Funcs t1_parser_funcs =
+ FT_CPLUSPLUS( const T1_Parser_Funcs ) t1_parser_funcs =
{
T1_Init_Parser,
T1_Done_Parser,
@@ -49,8 +47,7 @@
};
- LOCAL_FUNC
- const T1_Builder_Funcs t1_builder_funcs =
+ FT_CPLUSPLUS( const T1_Builder_Funcs ) t1_builder_funcs =
{
T1_Builder_Init,
T1_Builder_Done,
@@ -63,8 +60,7 @@
};
- LOCAL_FUNC
- const T1_Decoder_Funcs t1_decoder_funcs =
+ FT_CPLUSPLUS( const T1_Decoder_Funcs ) t1_decoder_funcs =
{
T1_Decoder_Init,
T1_Decoder_Done,
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -216,7 +216,8 @@
if ( !old_base )
return;
- (void)REALLOC( table->block, table->capacity, table->cursor );
+ if ( REALLOC( table->block, table->capacity, table->cursor ) )
+ return;
table->capacity = table->cursor;
if ( old_base != table->block )
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -35,14 +35,16 @@
/*************************************************************************/
/*************************************************************************/
- LOCAL_DEF
+
+ LOCAL_VAR
const PS_Table_Funcs ps_table_funcs;
- LOCAL_DEF
+ LOCAL_VAR
const T1_Parser_Funcs t1_parser_funcs;
-
- LOCAL_DEF
+
+ LOCAL_VAR
const T1_Builder_Funcs t1_builder_funcs;
+
LOCAL_DEF
FT_Error PS_Table_New( PS_Table* table,
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -21,6 +21,7 @@
#include <freetype/internal/ftdebug.h> /* for FT_ERROR() */
#include <freetype/internal/t1errors.h>
#include <freetype/ftoutln.h>
+#include <freetype/internal/ftdebug.h>
/*************************************************************************/
@@ -310,7 +311,7 @@
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
- LOCAL_FUNC
+ LOCAL_FUNC_X
FT_Error T1_Decoder_Parse_Charstrings( T1_Decoder* decoder,
FT_Byte* charstring_base,
FT_UInt charstring_len )
@@ -1011,7 +1012,7 @@
}
- LOCAL_FUNC
+ LOCAL_FUNC_X
FT_Error T1_Decoder_Init( T1_Decoder* decoder,
FT_Face face,
FT_Size size,
@@ -1051,7 +1052,7 @@
}
- LOCAL_FUNC
+ LOCAL_FUNC_X
void T1_Decoder_Done( T1_Decoder* decoder )
{
T1_Builder_Done( &decoder->builder );
--- a/src/psaux/t1decode.h
+++ b/src/psaux/t1decode.h
@@ -24,9 +24,15 @@
#include <freetype/internal/t1types.h>
- LOCAL_DEF
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+ LOCAL_VAR
const T1_Decoder_Funcs t1_decoder_funcs;
+
LOCAL_DEF
FT_Error T1_Decoder_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph_index );
@@ -47,6 +53,11 @@
LOCAL_DEF
void T1_Decoder_Done( T1_Decoder* decoder );
+
+
+#ifdef __cplusplus
+ }
+#endif
#endif /* T1DECODE_H */
--- a/src/type1z/z1load.c
+++ b/src/type1z/z1load.c
@@ -1299,7 +1299,7 @@
T1_FIELD_CALLBACK( "shareddict", parse_shared_dict )
#endif
- { 0,0,0,0, 0,0,0,0 }
+ { 0, t1_field_cid_info, t1_field_none, 0, 0, 0, 0, 0 }
};