Introducing new macro LOCA_VAR to solve some problems with structures containing function pointers. FT will now compile again with C++.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index 11e697e..854109f 100644
--- 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 */
@@ -176,6 +175,13 @@
#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
+#ifdef __cplusplus
+#define LOCAL_VAR extern "C"
+#else
+#define LOCAL_VAR extern
+#endif
+
+
#ifndef BASE_DEF
#ifdef __cplusplus
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index 8bd70ac..a8a1cf4 100644
--- 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;
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 9439c96..637a894 100644
--- 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,29 +142,29 @@
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 )
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,19 +189,14 @@
}
-
-
-
- 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,
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,
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 740e71d..a30579f 100644
--- 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 *****/
- /***** *****/
- /**************************************************************************/
- /**************************************************************************/
-
- static
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FACE & SIZE LRU CALLBACKS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ 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,
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 6352731..16ebb21 100644
--- 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 )
{
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index bc4c539..70c0d0b 100644
--- 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 }
};
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index b8660dc..efe4165 100644
--- 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,
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 8a78262..b6bf532 100644
--- 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 )
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index e01292c..c13a451 100644
--- 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,
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index 0ff4bc0..49060ba 100644
--- 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 );
diff --git a/src/psaux/t1decode.h b/src/psaux/t1decode.h
index d14a7f0..7ce8bf5 100644
--- 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 );
@@ -49,6 +55,11 @@
void T1_Decoder_Done( T1_Decoder* decoder );
+#ifdef __cplusplus
+ }
+#endif
+
+
#endif /* T1DECODE_H */
diff --git a/src/type1z/z1load.c b/src/type1z/z1load.c
index 71c1537..c87f7a1 100644
--- 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 }
};