Modified incremental loading interface to be closer to David Turner's preferences. The header freetype.h is not now affected, the interface is specified via an FT_Parameter, the pointer to the interface is hidden in an internal part of the face record, and all the definitions are in ftincrem.h.
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 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index 93f3f29..51bced5 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -499,6 +499,8 @@
#define FT_XFREE86_H <freetype/ftxf86.h>
+#define FT_INCREMENTAL_H <freetype/ftincrem.h>
+
/* now include internal headers definitions from <freetype/internal/...> */
#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index c64b7b9..fb1448e 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -199,35 +199,6 @@ FT_BEGIN_HEADER
} FT_Glyph_Metrics;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Basic_Glyph_Metrics */
- /* */
- /* <Description> */
- /* A small glyph metrics structure used to return information for */
- /* incrementally defined fonts (see @FT_Incremental_Interface). */
- /* */
- /* <Fields> */
- /* bearing_x :: Left side bearing in font units. */
- /* */
- /* bearing_y :: Top side bearing in font units. */
- /* */
- /* advance :: Advance in font units. */
- /* */
- typedef struct FT_Basic_Glyph_Metrics_
- {
- FT_Long bearing_x;
- FT_Long bearing_y;
- FT_Long advance;
-
- } FT_Basic_Glyph_Metrics;
-
-#endif /* #ifdef FT_CONFIG_OPTION_INCREMENTAL */
-
-
/*************************************************************************/
/* */
/* <Struct> */
@@ -508,126 +479,6 @@ FT_BEGIN_HEADER
} FT_CharMapRec;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Get_Glyph_Data_Func */
- /* */
- /* <Description> */
- /* A type definition for a function to get glyph data from a face */
- /* that supplies glyph data incrementally, after the face object has */
- /* been created. */
- /* */
- /* <Input> */
- /* object :: A pointer to the user's data, specified by the `object' */
- /* field in @FT_Incremental_Interface. */
- /* */
- /* index :: The glyph index. */
- /* */
- /* <Output> */
- /* data :: The position and length of the data. */
- /* */
- /* <Return> */
- /* FreeType error code. O means success. */
- /* */
- typedef FT_Error
- (*FT_Get_Glyph_Data_Func)( void* object,
- FT_UInt index,
- FT_Data* data );
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* FT_Get_Glyph_Metrics_Func */
- /* */
- /* <Description> */
- /* A type definition for a function to get glyph metrics from a face */
- /* that supplies glyph metrics incrementally, after the face object */
- /* has been created. */
- /* */
- /* <Input> */
- /* object :: A pointer to the user's data, specified by the */
- /* `object' field in @FT_Incremental_Interface. */
- /* */
- /* index :: The glyph index. */
- /* */
- /* vertical :: True for vertical layout, false for horizontal layout. */
- /* */
- /* <Output> */
- /* metrics :: The glyph metrics in font units. */
- /* */
- /* <Return> */
- /* FreeType error code. O means success. */
- /* */
- typedef FT_Error
- (*FT_Get_Glyph_Metrics_Func)( void* object,
- FT_UInt index,
- FT_Bool vertical,
- FT_Basic_Glyph_Metrics* metrics,
- FT_Bool* found );
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Incremental_Interface_Funcs */
- /* */
- /* <Description> */
- /* A table of functions for accessing fonts that load data */
- /* incrementally. Used in @FT_Incremental_Interface. */
- /* */
- /* <Fields> */
- /* get_glyph_data :: The function to get glyph data. Must not be */
- /* null. */
- /* */
- /* get_glyph_metrics :: The function to get glyph metrics. May be */
- /* null if the font does not provide */
- /* overriding glyph metrics. */
- /* */
- typedef struct FT_Incremental_Interface_Funcs_
- {
- FT_Get_Glyph_Data_Func get_glyph_data;
- FT_Get_Glyph_Metrics_Func get_glyph_metrics;
-
- } FT_Incremental_Interface_Funcs;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FT_Incremental_Interface */
- /* */
- /* <Description> */
- /* This interface structure is provided to @FT_Open_Face to allow */
- /* incremental faces to be opened. */
- /* */
- /* An incremental face supplies no glyph data when it is opened. */
- /* Instead, the glyph data is supplied using a callback function. */
- /* Optionally, metrics that override the metrics in the typeface data */
- /* can also be supplied using another callback function. */
- /* */
- /* <Fields> */
- /* funcs :: The table of functions. */
- /* */
- /* object :: The pointer passed to the functions. Usually it points */
- /* to the object from which glyph and metric data is */
- /* obtained. */
- /* */
- typedef struct FT_Incremental_Interface_
- {
- const FT_Incremental_Interface_Funcs* funcs;
- void* object;
-
- } FT_Incremental_Interface;
-
-
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
-
-
/*************************************************************************/
/*************************************************************************/
/* */
@@ -859,10 +710,6 @@ FT_BEGIN_HEADER
FT_Face_Internal internal;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_Interface* incremental_interface;
-#endif
-
/*@private end */
} FT_FaceRec;
@@ -1601,10 +1448,6 @@ FT_BEGIN_HEADER
/* */
/* ft_open_params :: Use the `num_params' & `params' field. */
/* */
- /* ft_open_incremental :: Use the 'incremental_interface' field. */
- /* (Available if @FT_CONFIG_OPTION_INCREMENTAL */
- /* is defined.) */
- /* */
/* <Note> */
/* The `ft_open_memory', `ft_open_stream', and `ft_open_pathname' */
/* flags are mutually exclusive. */
@@ -1616,9 +1459,6 @@ FT_BEGIN_HEADER
ft_open_pathname = 4,
ft_open_driver = 8,
ft_open_params = 16
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- ,ft_open_incremental = 32
-#endif
} FT_Open_Flags;
@@ -1680,11 +1520,6 @@ FT_BEGIN_HEADER
/* params :: Extra parameters passed to the font driver when */
/* opening a new face. */
/* */
- /* incremental_interface :: */
- /* If non-null, an interface used to implement */
- /* incremental font loading. This field exists only */
- /* if @FT_CONFIG_OPTION_INCREMENTAL is defined. */
- /* */
/* <Note> */
/* The stream type is determined by the contents of `flags' which */
/* are tested in the following order by @FT_Open_Face: */
@@ -1705,10 +1540,6 @@ FT_BEGIN_HEADER
/* `num_params' and `params' will be used. They are ignored */
/* otherwise. */
/* */
- /* If the `ft_open_incremental' bit is set 'incremental_interface' */
- /* will be used, else it is ignored. This feature is available only */
- /* if @FT_CONFIG_OPTION_INCREMENTAL is defined. */
- /* */
typedef struct FT_Open_Args_
{
FT_Open_Flags flags;
@@ -1719,9 +1550,6 @@ FT_BEGIN_HEADER
FT_Module driver;
FT_Int num_params;
FT_Parameter* params;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_Interface* incremental_interface;
-#endif
} FT_Open_Args;
diff --git a/include/freetype/ftincrem.h b/include/freetype/ftincrem.h
index fdc4dcd..a941671 100644
--- a/include/freetype/ftincrem.h
+++ b/include/freetype/ftincrem.h
@@ -11,20 +11,20 @@ FT_BEGIN_HEADER
* @type: FT_Incremental
*
* @description:
- * an opaque type describing a user-provided object used to implement
+ * An opaque type describing a user-provided object used to implement
* "incremental" glyph loading within FreeType. This is used to support
* embedded fonts in certain environments (e.g. Postscript interpreters),
- * where the glyph data isn't in the font file, or must be over-ridden by
+ * where the glyph data isn't in the font file, or must be overridden by
* different values.
*
* @note:
- * it's up to client applications to create and implement @FT_Incremental
+ * It is up to client applications to create and implement @FT_Incremental
* objects, as long as they provide implementations for the methods
* @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
* and @FT_Incremental_GetGlyphMetricsFunc
*
- * see the description of @FT_Incremental_ServiceRec to understand how to
- * use incremental objects with FreeType.
+ * see the description of @FT_Incremental_InterfaceRec to understand how
+ * to use incremental objects with FreeType.
*/
typedef struct FT_IncrementalRec_* FT_Incremental;
@@ -34,17 +34,17 @@ FT_BEGIN_HEADER
* @struct: FT_Incremental_Metrics
*
* @description:
- * a small structure used to model the basic glyph metrics returned
+ * A small structure used to contain the basic glyph metrics returned
* by the @FT_Incremental_GetGlyphMetricsFunc method
*
* @fields:
- * bearing_x :: left-most bearing, in font units.
- * bearing_y :: top-most bearing, in font units.
+ * bearing_x :: left bearing, in font units.
+ * bearing_y :: top bearing, in font units.
* advance :: glyph advance, in font units
*
* @note:
- * these correspond to horizontal or vertical metrics depending on the
- * value of the 'vertical' parameter of the method
+ * These correspond to horizontal or vertical metrics depending on the
+ * value of the 'vertical' argument to the function
* @FT_Incremental_GetGlyphMetricsFunc
*/
typedef struct FT_Incremental_MetricsRec_
@@ -61,14 +61,14 @@ FT_BEGIN_HEADER
* @type: FT_Incremental_GetGlyphDataFunc
*
* @description:
- * a function called by FreeType to access a given glyph's data bytes
- * during @FT_Load_Glyph or @FT_Load_Char, when incremental loading is
- * enable.
+ * A function called by FreeType to access a given glyph's data bytes
+ * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
+ * enabled.
*
- * note that the format of the glyph's data bytes depends on the font
+ * Note that the format of the glyph's data bytes depends on the font
* file format. For TrueType, it must correspond to the raw bytes within
* the 'glyf' table. For Postscript formats, it must correspond to the
- * *unencrypted* charstrings bytes, without any 'lenIV' header. It is
+ * *unencrypted* charstring bytes, without any 'lenIV' header. It is
* undefined for any other format.
*
* @input:
@@ -85,24 +85,24 @@ FT_BEGIN_HEADER
* FreeType error code. 0 means success
*
* @note:
- * if this function returns succesfully, the method
- * @FT_Incremental_FreeGlyphDataFunc will be called later to "release"
- * the se bytes.
+ * If this function returns succesfully the method
+ * @FT_Incremental_FreeGlyphDataFunc will be called later to release
+ * the data bytes.
*
- * nested @FT_Incremental_GetGlyphDataFunc can happen, in the case of
- * compound glyphs !!
+ * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
+ * compound glyphs.
*/
typedef FT_Error (*FT_Incremental_GetGlyphDataFunc)
( FT_Incremental incremental,
FT_UInt glyph_index,
- FT_DataRec *adata );
+ FT_Data* adata );
/**************************************************************************
*
* @type: FT_Incremental_FreeGlyphDataFunc
*
* @description:
- * a function used to "release" the glyph data bytes returned by a
+ * A function used to release the glyph data bytes returned by a
* successful call to @FT_Incremental_GetGlyphDataFunc.
*
* @input:
@@ -113,7 +113,7 @@ FT_BEGIN_HEADER
*/
typedef void (*FT_Incremental_FreeGlyphDataFunc)
( FT_Incremental incremental,
- FT_DataRec* data );
+ FT_Data* data );
/**************************************************************************
@@ -121,9 +121,9 @@ FT_BEGIN_HEADER
* @type: FT_Incremental_GetGlyphMetricsFunc
*
* @description:
- * a function used to retrieve the basic metrics of a given glyph index
+ * A function used to retrieve the basic metrics of a given glyph index
* before accessing its data. This is necessary because, in certain formats
- * like TrueType, the metrics are stored in a different place than the
+ * like TrueType, the metrics are stored in a different place from the
* glyph images proper.
*
* @input:
@@ -139,32 +139,58 @@ FT_BEGIN_HEADER
FT_Bool *afound );
+ /*************************************************************************
+ *
+ * @struct: FT_Incremental_FuncsRec
+ *
+ * @description:
+ * A table of functions for accessing fonts that load data
+ * incrementally. Used in @FT_Incremental_Interface.
+ *
+ * @fields:
+ * get_glyph_data :: The function to get glyph data. Must not be
+ * null.
+ *
+ * free_glyph_data :: The function to release glyph data. Must not
+ * be null.
+ *
+ * get_glyph_metrics :: The function to get glyph metrics. May be
+ * null if the font does not provide
+ * overriding glyph metrics.
+ */
+ typedef struct FT_Incremental_FuncsRec_
+ {
+ FT_Incremental_GetGlyphDataFunc get_glyph_data;
+ FT_Incremental_FreeGlyphDataFunc free_glyph_data;
+ FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
+
+ } FT_Incremental_FuncsRec;
+
+
/**************************************************************************
*
- * @struct: FT_Incremental_ServiceRec
+ * @struct: FT_Incremental_InterfaceRec
*
* @description:
- * a structure to be used with @FT_Open_Face to indicate that the user
- * wants to support "incremental" glyph loading. You should use it with
+ * A structure to be used with @FT_Open_Face to indicate that the user
+ * wants to support incremental glyph loading. You should use it with
* @FT_PARAM_TAG_INCREMENTAL as in the following example:
*
* {
- * FT_Incremental_ServiceRec incr_service;
- * FT_Parameter parameter;
- * FT_Open_Args open_args;
+ * FT_Incremental_InterfaceRec inc_int;
+ * FT_Parameter parameter;
+ * FT_Open_Args open_args;
*
* // set up incremental descriptor
- * incr_service.incremental = my_object;
- * incr_service.get_glyph_metrics = my_get_glyph_metrics;
- * incr_service.get_glyph_data = my_get_glyph_data;
- * incr_service.free_glyph_data = my_free_glyph_data;
+ * inc_int.funcs = my_funcs;
+ * inc_int.object = my_object;
*
* // set up optional parameter
* parameter.tag = FT_PARAM_TAG_INCREMENTAL;
- * parameter.data = &incr_service;
+ * parameter.data = &inc_int;
*
* // set up FT_Open_Args structure
- * open_args.flags = ft_open_flag_pathname;
+ * open_args.flags = (FT_Open_Flags)(ft_open_pathname | ft_open_params);
* open_args.pathname = my_font_pathname;
* open_args.num_params = 1;
* open_args.params = ¶meter; // we use one optional argument
@@ -174,25 +200,21 @@ FT_BEGIN_HEADER
* ....
* }
*/
- typedef struct FT_IncrementalParamsRec_
+ typedef struct FT_Incremental_InterfaceRec_
{
- FT_Incremental incremental;
- FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
- FT_Incremental_GetGlyphDataFunc get_glyph_data;
- FT_Incremental_FreeGlyphDataFunc free_glyph_data;
+ const FT_Incremental_FuncsRec* funcs;
+ FT_Incremental object;
- } FT_IncrementalParamsRec, *FT_IncrementalParams;
-
+ } FT_Incremental_InterfaceRec;
/**************************************************************************
*
* @constant: FT_PARAM_TAG_INCREMENTAL
*
* @description:
- * a constant used as the tag of @FT_Parameter structures to indicate
- * an incremental loading object to be used by FreeType
+ * A constant used as the tag of @FT_Parameter structures to indicate
+ * an incremental loading object to be used by FreeType.
*
- * see the node for @FT_IncrementalParamsRec
*/
#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG('i','n','c','r')
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index c613b74..ede438d 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -36,6 +36,10 @@
#include FT_INTERNAL_AUTOHINT_H
#include FT_INTERNAL_OBJECT_H
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+#include FT_INCREMENTAL_H
+#endif
+
FT_BEGIN_HEADER
@@ -296,6 +300,13 @@ FT_BEGIN_HEADER
/* */
/* postscript_name :: Postscript font name for this face. */
/* */
+ /* incremental_interface :: If non-null, the interface through */
+ /* which glyph data and metrics are loaded */
+ /* incrementally for faces that do not provide */
+ /* all of this data when first opened. */
+ /* This field exists only if */
+ /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
+ /* */
typedef struct FT_Face_InternalRec_
{
FT_UShort max_points;
@@ -309,6 +320,10 @@ FT_BEGIN_HEADER
const char* postscript_name;
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ FT_Incremental_InterfaceRec* incremental_interface;
+#endif
+
} FT_Face_InternalRec;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index d679504..1d4340e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -25,7 +25,6 @@
#include FT_TRUETYPE_TABLES_H
#include FT_OUTLINE_H
-
FT_BASE_DEF( void )
ft_validator_init( FT_Validator valid,
const FT_Byte* base,
@@ -700,11 +699,6 @@
FT_Long face_index,
FT_Int num_params,
FT_Parameter* params,
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_Interface* incremental_interface,
-#endif
-
FT_Face* aface )
{
FT_Memory memory;
@@ -713,7 +707,6 @@
FT_Error error;
FT_Face_Internal internal;
-
clazz = driver->clazz;
memory = driver->root.memory;
@@ -729,8 +722,15 @@
face->driver = driver;
face->memory = memory;
face->stream = stream;
+
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- face->incremental_interface = incremental_interface;
+ {
+ int i;
+ face->internal->incremental_interface = 0;
+ for (i = 0; i < num_params && !face->internal->incremental_interface; i++)
+ if (params[i].tag == FT_PARAM_TAG_INCREMENTAL)
+ face->internal->incremental_interface = params[i].data;
+ }
#endif
error = clazz->init_face( stream,
@@ -874,14 +874,8 @@
/* not all modules are drivers, so check... */
if ( FT_MODULE_IS_DRIVER( driver ) )
{
- FT_Int num_params = 0;
- FT_Parameter* params = 0;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_Interface* incremental_interface =
- ( args->flags & ft_open_incremental ) ? args->incremental_interface
- : 0;
-#endif
+ FT_Int num_params = 0;
+ FT_Parameter* params = 0;
if ( args->flags & ft_open_params )
{
@@ -889,14 +883,8 @@
params = args->params;
}
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- error = open_face( driver, stream, face_index,
- num_params, params, incremental_interface, &face );
-#else
error = open_face( driver, stream, face_index,
num_params, params, &face );
-#endif
-
if ( !error )
goto Success;
}
@@ -921,12 +909,6 @@
FT_Int num_params = 0;
FT_Parameter* params = 0;
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_Interface* incremental_interface =
- ( args->flags & ft_open_incremental ) ? args->incremental_interface
- : 0;
-#endif
-
driver = FT_DRIVER( cur[0] );
if ( args->flags & ft_open_params )
@@ -935,14 +917,8 @@
params = args->params;
}
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- error = open_face( driver, stream, face_index,
- num_params, params, incremental_interface, &face );
-#else
error = open_face( driver, stream, face_index,
num_params, params, &face );
-#endif
-
if ( !error )
goto Success;
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index a10d290..3da48bb 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -433,7 +433,7 @@
/* do we have outlines in there? */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- has_outline = FT_BOOL( face->root.incremental_interface != 0 ||
+ has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 ||
TT_LookUp_Table( face, TTAG_glyf ) != 0 ||
TT_LookUp_Table( face, TTAG_CFF ) != 0 );
#else
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 9efaf82..5757f8c 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -756,7 +756,9 @@
FT_Bool opened_frame = 0;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- struct FT_StreamRec_ inc_stream;
+ struct FT_StreamRec_ inc_stream;
+ FT_Data glyph_data;
+ FT_Bool glyph_data_loaded = 0;
#endif
@@ -789,14 +791,14 @@
/* If this is an incrementally loaded font see if there are */
/* overriding metrics for this glyph. */
- if ( face->root.incremental_interface &&
- face->root.incremental_interface->funcs->get_glyph_metrics )
+ if ( face->root.internal->incremental_interface &&
+ face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
- FT_Basic_Glyph_Metrics m;
+ FT_Incremental_MetricsRec m;
- error = face->root.incremental_interface->funcs->get_glyph_metrics(
- face->root.incremental_interface->object,
+ error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+ face->root.internal->incremental_interface->object,
glyph_index, FALSE, &m, &metrics_found );
if ( error )
goto Exit;
@@ -841,21 +843,19 @@
/* the loader stream to a memory stream reading the data returned */
/* by the interface. */
- if ( face->root.incremental_interface )
+ if ( face->root.internal->incremental_interface )
{
- FT_Data data;
-
-
- error = face->root.incremental_interface->funcs->get_glyph_data(
- face->root.incremental_interface->object,
- glyph_index, &data );
+ error = face->root.internal->incremental_interface->funcs->get_glyph_data(
+ face->root.internal->incremental_interface->object,
+ glyph_index, &glyph_data );
if ( error )
goto Exit;
+ glyph_data_loaded = 1;
offset = 0;
- count = data.length;
+ count = glyph_data.length;
FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
- FT_Stream_OpenMemory( &inc_stream, data.pointer, data.length );
+ FT_Stream_OpenMemory( &inc_stream, glyph_data.pointer, glyph_data.length );
loader->stream = &inc_stream;
}
@@ -1264,6 +1264,14 @@
face->forget_glyph_frame( loader );
Exit:
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if (glyph_data_loaded)
+ face->root.internal->incremental_interface->funcs->free_glyph_data(
+ face->root.internal->incremental_interface->object,
+ &glyph_data );
+#endif
+
return error;
}
@@ -1353,13 +1361,13 @@
/* If this is an incrementally loaded font see if there are */
/* overriding metrics for this glyph. */
- if ( face->root.incremental_interface &&
- face->root.incremental_interface->funcs->get_glyph_metrics )
+ if ( face->root.internal->incremental_interface &&
+ face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
- FT_Basic_Glyph_Metrics m;
- FT_Error error =
- face->root.incremental_interface->funcs->get_glyph_metrics(
- face->root.incremental_interface->object,
+ FT_Incremental_MetricsRec m;
+ FT_Error error =
+ face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+ face->root.internal->incremental_interface->object,
glyph_index, TRUE, &m, &metrics_found );
@@ -1595,7 +1603,7 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Don't look for the glyph table if this is an incremental font. */
- if ( !face->root.incremental_interface )
+ if ( !face->root.internal->incremental_interface )
#endif
@@ -1656,7 +1664,7 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( face->root.incremental_interface )
+ if ( face->root.internal->incremental_interface )
loader.glyf_offset = 0;
else
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 4f1688e..39653e1 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -201,7 +201,7 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( !face->root.incremental_interface )
+ if ( !face->root.internal->incremental_interface )
error = TT_Load_Locations( face, stream );
if ( !error )
error = TT_Load_CVT ( face, stream ) ||
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 545a4e3..8eaabf5 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -70,9 +70,9 @@
/* For incremental fonts get the character data using the */
/* callback function. */
- if ( face->root.incremental_interface )
- error = face->root.incremental_interface->funcs->get_glyph_data(
- face->root.incremental_interface->object,
+ if ( face->root.internal->incremental_interface )
+ error = face->root.internal->incremental_interface->funcs->get_glyph_data(
+ face->root.internal->incremental_interface->object,
glyph_index, char_string );
else
@@ -92,15 +92,15 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
- if ( !error && face->root.incremental_interface &&
- face->root.incremental_interface->funcs->get_glyph_metrics )
+ if ( !error && face->root.internal->incremental_interface &&
+ face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
- FT_Bool found = FALSE;
- FT_Basic_Glyph_Metrics metrics;
+ FT_Bool found = FALSE;
+ FT_Incremental_MetricsRec metrics;
- error = face->root.incremental_interface->funcs->get_glyph_metrics(
- face->root.incremental_interface->object,
+ error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+ face->root.internal->incremental_interface->object,
glyph_index, FALSE, &metrics, &found );
if ( found )
{
@@ -121,10 +121,23 @@
T1_Parse_Glyph( T1_Decoder decoder,
FT_UInt glyph_index )
{
- FT_Data data;
+ FT_Data glyph_data;
+ FT_Error error = T1_Parse_Glyph_And_Get_Char_String( decoder, glyph_index, &glyph_data );
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( !error)
+ {
+ T1_Face face = (T1_Face)decoder->builder.face;
- return T1_Parse_Glyph_And_Get_Char_String( decoder, glyph_index, &data );
+
+ if ( face->root.internal->incremental_interface )
+ face->root.internal->incremental_interface->funcs->free_glyph_data(
+ face->root.internal->incremental_interface->object,
+ &glyph_data );
+ }
+#endif
+
+ return error;
}
@@ -211,7 +224,8 @@
FT_Matrix font_matrix;
FT_Vector font_offset;
- FT_Data char_string;
+ FT_Data glyph_data;
+ FT_Bool glyph_data_loaded = 0;
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@@ -247,9 +261,10 @@
/* now load the unscaled outline */
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
- &char_string );
+ &glyph_data );
if ( error )
goto Exit;
+ glyph_data_loaded = 1;
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
@@ -368,11 +383,27 @@
/* Set control data to the glyph charstrings. Note that this is */
/* _not_ zero-terminated. */
- glyph->root.control_data = (FT_Byte*)char_string.pointer;
- glyph->root.control_len = char_string.length;
+ glyph->root.control_data = (FT_Byte*)glyph_data.pointer;
+ glyph->root.control_len = glyph_data.length;
}
+
Exit:
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( glyph_data_loaded && face->root.internal->incremental_interface )
+ {
+ face->root.internal->incremental_interface->funcs->free_glyph_data(
+ face->root.internal->incremental_interface->object,
+ &glyph_data );
+
+ /* Set the control data to null - it is no longer available if */
+ /* loaded incrementally. */
+ glyph->root.control_data = 0;
+ glyph->root.control_len = 0;
+ }
+#endif
+
return error;
}