Added support for incrementally loaded Type 1 faces.
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
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 6bf71cf..9ae4937 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -53,21 +53,62 @@
/*************************************************************************/
- FT_CALLBACK_DEF( FT_Error )
- T1_Parse_Glyph( T1_Decoder decoder,
- FT_UInt glyph_index )
+FT_LOCAL_DEF(FT_Error) T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
+ FT_UInt glyph_index,
+ FT_Data* char_string )
{
- T1_Face face = (T1_Face)decoder->builder.face;
- T1_Font type1 = &face->type1;
-
+ T1_Face face = (T1_Face)decoder->builder.face;
+ T1_Font type1 = &face->type1;
+ FT_Error error = 0;
decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset;
- return decoder->funcs.parse_charstrings(
- decoder,
- type1->charstrings [glyph_index],
- type1->charstrings_len[glyph_index] );
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ /* 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,
+ glyph_index,char_string);
+ else
+#endif
+
+ /* For ordinary fonts get the character data stored in the face record. */
+ {
+ char_string->pointer = type1->charstrings[glyph_index];
+ char_string->length = type1->charstrings_len[glyph_index];
+ }
+
+ if (!error)
+ error = decoder->funcs.parse_charstrings(decoder,(FT_Byte*)char_string->pointer,char_string->length);
+
+#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)
+ {
+ FT_Bool found = FALSE;
+ FT_Basic_Glyph_Metrics metrics;
+ error = face->root.incremental_interface->funcs->get_glyph_metrics(face->root.incremental_interface->object,
+ glyph_index,FALSE,&metrics,&found);
+ if (found)
+ {
+ decoder->builder.left_bearing.x = metrics.bearing_x;
+ decoder->builder.left_bearing.y = metrics.bearing_y;
+ decoder->builder.advance.x = metrics.advance;
+ decoder->builder.advance.y = 0;
+ }
+ }
+#endif
+
+ return error;
+ }
+
+
+ FT_CALLBACK_DEF( FT_Error )
+ T1_Parse_Glyph( T1_Decoder decoder,
+ FT_UInt glyph_index )
+ {
+ FT_Data data;
+ return T1_Parse_Glyph_And_Get_Char_String(decoder,glyph_index,&data);
}
@@ -154,7 +195,7 @@
FT_Matrix font_matrix;
FT_Vector font_offset;
-
+ FT_Data char_string;
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@@ -188,9 +229,8 @@
decoder.subrs = type1->subrs;
decoder.subrs_len = type1->subrs_len;
-
/* now load the unscaled outline */
- error = T1_Parse_Glyph( &decoder, glyph_index );
+ error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index, &char_string );
if ( error )
goto Exit;
@@ -311,8 +351,8 @@
/* Set control data to the glyph charstrings. Note that this is */
/* _not_ zero-terminated. */
- glyph->root.control_data = type1->charstrings [glyph_index];
- glyph->root.control_len = type1->charstrings_len[glyph_index];
+ glyph->root.control_data = (FT_Byte*)char_string.pointer;
+ glyph->root.control_len = char_string.length;
}
Exit: