Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* cidload.c */ |
| 4 | /* */ |
| 5 | /* CID-keyed Type1 font loader (body). */ |
| 6 | /* */ |
Werner Lemberg | 415235d | 2001-06-28 17:49:10 +0000 | [diff] [blame] | 7 | /* Copyright 1996-2001 by */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 | /* */ |
| 10 | /* This file is part of the FreeType project, and may only be used, */ |
| 11 | /* modified, and distributed under the terms of the FreeType project */ |
| 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 | /* this file you indicate that you have read the license and */ |
| 14 | /* understand and accept it fully. */ |
| 15 | /* */ |
| 16 | /***************************************************************************/ |
| 17 | |
Werner Lemberg | cc069be | 2000-12-08 16:17:16 +0000 | [diff] [blame] | 18 | |
| 19 | #include <ft2build.h> |
| 20 | #include FT_INTERNAL_DEBUG_H |
| 21 | #include FT_CONFIG_CONFIG_H |
| 22 | #include FT_MULTIPLE_MASTERS_H |
| 23 | #include FT_INTERNAL_TYPE1_TYPES_H |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 24 | |
David Turner | 8d3a401 | 2001-03-20 11:14:24 +0000 | [diff] [blame] | 25 | #include "cidload.h" |
Werner Lemberg | cc069be | 2000-12-08 16:17:16 +0000 | [diff] [blame] | 26 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 27 | #include "ciderrs.h" |
| 28 | |
Werner Lemberg | cc069be | 2000-12-08 16:17:16 +0000 | [diff] [blame] | 29 | #include <stdio.h> |
| 30 | #include <ctype.h> /* for isspace(), isalnum() */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 31 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 32 | |
| 33 | /*************************************************************************/ |
| 34 | /* */ |
| 35 | /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 36 | /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 37 | /* messages during execution. */ |
| 38 | /* */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 39 | #undef FT_COMPONENT |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 40 | #define FT_COMPONENT trace_cidload |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 41 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 42 | |
Werner Lemberg | ac39ecd | 2000-06-30 22:24:36 +0000 | [diff] [blame] | 43 | /* read a single offset */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 44 | FT_LOCAL_DEF( FT_Long ) |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 45 | cid_get_offset( FT_Byte** start, |
| 46 | FT_Byte offsize ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 47 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 48 | FT_Long result; |
| 49 | FT_Byte* p = *start; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 50 | |
| 51 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 52 | for ( result = 0; offsize > 0; offsize-- ) |
Werner Lemberg | ac39ecd | 2000-06-30 22:24:36 +0000 | [diff] [blame] | 53 | { |
| 54 | result <<= 8; |
| 55 | result |= *p++; |
| 56 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 57 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 58 | *start = p; |
| 59 | return result; |
| 60 | } |
| 61 | |
| 62 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 63 | FT_LOCAL_DEF( void ) |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 64 | cid_decrypt( FT_Byte* buffer, |
| 65 | FT_Offset length, |
| 66 | FT_UShort seed ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 67 | { |
| 68 | while ( length > 0 ) |
| 69 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 70 | FT_Byte plain; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 71 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 72 | |
David Turner | 8edbcab | 2001-06-19 08:28:24 +0000 | [diff] [blame] | 73 | plain = (FT_Byte)( *buffer ^ ( seed >> 8 ) ); |
Werner Lemberg | a560a1e | 2001-07-03 12:45:24 +0000 | [diff] [blame] | 74 | seed = (FT_UShort)( ( *buffer + seed ) * 52845U + 22719 ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 75 | *buffer++ = plain; |
| 76 | length--; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 81 | /*************************************************************************/ |
| 82 | /*************************************************************************/ |
| 83 | /***** *****/ |
| 84 | /***** TYPE 1 SYMBOL PARSING *****/ |
| 85 | /***** *****/ |
| 86 | /*************************************************************************/ |
| 87 | /*************************************************************************/ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 88 | |
| 89 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 90 | static FT_Error |
| 91 | cid_load_keyword( CID_Face face, |
| 92 | CID_Loader* loader, |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 93 | const T1_Field keyword ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 94 | { |
Werner Lemberg | ac39ecd | 2000-06-30 22:24:36 +0000 | [diff] [blame] | 95 | FT_Error error; |
| 96 | CID_Parser* parser = &loader->parser; |
| 97 | FT_Byte* object; |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 98 | void* dummy_object; |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 99 | CID_FaceInfo cid = &face->cid; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 100 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 101 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 102 | /* if the keyword has a dedicated callback, call it */ |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 103 | if ( keyword->type == T1_FIELD_TYPE_CALLBACK ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 104 | { |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 105 | keyword->reader( (FT_Face)face, parser ); |
| 106 | error = parser->root.error; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 107 | goto Exit; |
| 108 | } |
| 109 | |
| 110 | /* we must now compute the address of our target object */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 111 | switch ( keyword->location ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 112 | { |
David Turner | 429978b | 2002-03-14 10:09:35 +0000 | [diff] [blame] | 113 | case T1_FIELD_LOCATION_CID_INFO: |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 114 | object = (FT_Byte*)cid; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 115 | break; |
| 116 | |
David Turner | 429978b | 2002-03-14 10:09:35 +0000 | [diff] [blame] | 117 | case T1_FIELD_LOCATION_FONT_INFO: |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 118 | object = (FT_Byte*)&cid->font_info; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 119 | break; |
| 120 | |
| 121 | default: |
| 122 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 123 | CID_FaceDict dict; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 124 | |
| 125 | |
| 126 | if ( parser->num_dict < 0 ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 127 | { |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 128 | FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n", |
| 129 | keyword->ident )); |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 130 | error = CID_Err_Syntax_Error; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 131 | goto Exit; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 132 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 133 | |
| 134 | dict = cid->font_dicts + parser->num_dict; |
| 135 | switch ( keyword->location ) |
| 136 | { |
David Turner | 429978b | 2002-03-14 10:09:35 +0000 | [diff] [blame] | 137 | case T1_FIELD_LOCATION_PRIVATE: |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 138 | object = (FT_Byte*)&dict->private_dict; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 139 | break; |
| 140 | |
| 141 | default: |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 142 | object = (FT_Byte*)dict; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 143 | } |
| 144 | } |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 145 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 146 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 147 | dummy_object = object; |
Werner Lemberg | e4b32a5 | 2000-10-31 20:42:18 +0000 | [diff] [blame] | 148 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 149 | /* now, load the keyword data in the object's field(s) */ |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 150 | if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY || |
| 151 | keyword->type == T1_FIELD_TYPE_FIXED_ARRAY ) |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 152 | error = CID_Load_Field_Table( &loader->parser, keyword, |
| 153 | &dummy_object ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 154 | else |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 155 | error = CID_Load_Field( &loader->parser, keyword, &dummy_object ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 156 | Exit: |
| 157 | return error; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 158 | } |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 159 | |
| 160 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 161 | FT_CALLBACK_DEF( FT_Error ) |
David Turner | dee7813 | 2001-06-27 09:26:46 +0000 | [diff] [blame] | 162 | parse_font_bbox( CID_Face face, |
| 163 | CID_Parser* parser ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 164 | { |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 165 | FT_Fixed temp[4]; |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 166 | FT_BBox* bbox = &face->cid.font_bbox; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 167 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 168 | |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 169 | (void)CID_ToFixedArray( parser, 4, temp, 0 ); |
| 170 | bbox->xMin = FT_RoundFix( temp[0] ); |
| 171 | bbox->yMin = FT_RoundFix( temp[1] ); |
| 172 | bbox->xMax = FT_RoundFix( temp[2] ); |
| 173 | bbox->yMax = FT_RoundFix( temp[3] ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 174 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 175 | return CID_Err_Ok; /* this is a callback function; */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 176 | /* we must return an error code */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 179 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 180 | FT_CALLBACK_DEF( FT_Error ) |
David Turner | dee7813 | 2001-06-27 09:26:46 +0000 | [diff] [blame] | 181 | parse_font_matrix( CID_Face face, |
| 182 | CID_Parser* parser ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 183 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 184 | FT_Matrix* matrix; |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 185 | FT_Vector* offset; |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 186 | CID_FaceDict dict; |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 187 | FT_Face root = (FT_Face)&face->root; |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 188 | FT_Fixed temp[6]; |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 189 | FT_Fixed temp_scale; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 190 | |
Werner Lemberg | 29bac13 | 2001-03-11 11:28:39 +0000 | [diff] [blame] | 191 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 192 | if ( parser->num_dict >= 0 ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 193 | { |
| 194 | dict = face->cid.font_dicts + parser->num_dict; |
| 195 | matrix = &dict->font_matrix; |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 196 | offset = &dict->font_offset; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 197 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 198 | (void)CID_ToFixedArray( parser, 6, temp, 3 ); |
| 199 | |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 200 | temp_scale = ABS( temp[3] ); |
| 201 | |
Werner Lemberg | 29bac13 | 2001-03-11 11:28:39 +0000 | [diff] [blame] | 202 | /* Set Units per EM based on FontMatrix values. We set the value to */ |
| 203 | /* `1000/temp_scale', because temp_scale was already multiplied by */ |
| 204 | /* 1000 (in t1_tofixed(), from psobjs.c). */ |
David Turner | 3798110 | 2001-03-19 11:34:49 +0000 | [diff] [blame] | 205 | root->units_per_EM = (FT_UShort)( FT_DivFix( 0x10000L, |
David Turner | 09d55ce | 2001-05-11 18:08:58 +0000 | [diff] [blame] | 206 | FT_DivFix( temp_scale, 1000 ) ) ); |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 207 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 208 | /* we need to scale the values by 1.0/temp[3] */ |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 209 | if ( temp_scale != 0x10000L ) |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 210 | { |
Tom Kacvinsky | 025c2f3 | 2001-03-10 19:04:41 +0000 | [diff] [blame] | 211 | temp[0] = FT_DivFix( temp[0], temp_scale ); |
| 212 | temp[1] = FT_DivFix( temp[1], temp_scale ); |
| 213 | temp[2] = FT_DivFix( temp[2], temp_scale ); |
| 214 | temp[4] = FT_DivFix( temp[4], temp_scale ); |
| 215 | temp[5] = FT_DivFix( temp[5], temp_scale ); |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 216 | temp[3] = 0x10000L; |
| 217 | } |
| 218 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 219 | matrix->xx = temp[0]; |
| 220 | matrix->yx = temp[1]; |
| 221 | matrix->xy = temp[2]; |
| 222 | matrix->yy = temp[3]; |
Werner Lemberg | e4b32a5 | 2000-10-31 20:42:18 +0000 | [diff] [blame] | 223 | |
Werner Lemberg | 6fbe4db | 2000-10-05 04:53:31 +0000 | [diff] [blame] | 224 | /* note that the font offsets are expressed in integer font units */ |
David Turner | f00a4de | 2000-10-03 22:03:09 +0000 | [diff] [blame] | 225 | offset->x = temp[4] >> 16; |
| 226 | offset->y = temp[5] >> 16; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 227 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 228 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 229 | return CID_Err_Ok; /* this is a callback function; */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 230 | /* we must return an error code */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 231 | } |
| 232 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 233 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 234 | FT_CALLBACK_DEF( FT_Error ) |
David Turner | dee7813 | 2001-06-27 09:26:46 +0000 | [diff] [blame] | 235 | parse_fd_array( CID_Face face, |
| 236 | CID_Parser* parser ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 237 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 238 | CID_FaceInfo cid = &face->cid; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 239 | FT_Memory memory = face->root.memory; |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 240 | FT_Error error = CID_Err_Ok; |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 241 | FT_Long num_dicts; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 242 | |
| 243 | |
| 244 | num_dicts = CID_ToInt( parser ); |
| 245 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 246 | if ( !cid->font_dicts ) |
| 247 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 248 | FT_Int n; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 249 | |
| 250 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 251 | if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 252 | goto Exit; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 253 | |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 254 | cid->num_dicts = (FT_UInt)num_dicts; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 255 | |
| 256 | /* don't forget to set a few defaults */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 257 | for ( n = 0; n < cid->num_dicts; n++ ) |
| 258 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 259 | CID_FaceDict dict = cid->font_dicts + n; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 260 | |
| 261 | |
| 262 | /* default value for lenIV */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 263 | dict->private_dict.lenIV = 4; |
| 264 | } |
| 265 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 266 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 267 | Exit: |
| 268 | return error; |
| 269 | } |
| 270 | |
| 271 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 272 | static |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 273 | const T1_FieldRec cid_field_records[] = |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 274 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 275 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 276 | #include "cidtoken.h" |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 277 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 278 | T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox ) |
| 279 | T1_FIELD_CALLBACK( "FDArray", parse_fd_array ) |
| 280 | T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix ) |
David Turner | 429978b | 2002-03-14 10:09:35 +0000 | [diff] [blame] | 281 | { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0 } |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
| 284 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 285 | static int |
| 286 | is_alpha( char c ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 287 | { |
Werner Lemberg | 35ca342 | 2000-07-31 12:14:27 +0000 | [diff] [blame] | 288 | return ( isalnum( (int)c ) || |
| 289 | c == '.' || |
| 290 | c == '_' ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 291 | } |
| 292 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 293 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 294 | static FT_Error |
| 295 | cid_parse_dict( CID_Face face, |
| 296 | CID_Loader* loader, |
| 297 | FT_Byte* base, |
| 298 | FT_Long size ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 299 | { |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 300 | CID_Parser* parser = &loader->parser; |
| 301 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 302 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 303 | parser->root.cursor = base; |
| 304 | parser->root.limit = base + size; |
| 305 | parser->root.error = 0; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 306 | |
| 307 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 308 | FT_Byte* cur = base; |
| 309 | FT_Byte* limit = cur + size; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 310 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 311 | |
| 312 | for ( ;cur < limit; cur++ ) |
| 313 | { |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 314 | /* look for `%ADOBeginFontDict' */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 315 | if ( *cur == '%' && cur + 20 < limit && |
| 316 | strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 ) |
| 317 | { |
| 318 | cur += 17; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 319 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 320 | /* if /FDArray was found, then cid->num_dicts is > 0, and */ |
| 321 | /* we can start increasing parser->num_dict */ |
| 322 | if ( face->cid.num_dicts > 0 ) |
| 323 | parser->num_dict++; |
| 324 | } |
| 325 | /* look for immediates */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 326 | else if ( *cur == '/' && cur + 2 < limit ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 327 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 328 | FT_Byte* cur2; |
| 329 | FT_Int len; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 330 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 331 | |
| 332 | cur++; |
| 333 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 334 | cur2 = cur; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 335 | while ( cur2 < limit && is_alpha( *cur2 ) ) |
| 336 | cur2++; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 337 | |
Werner Lemberg | 914b289 | 2001-03-10 17:07:42 +0000 | [diff] [blame] | 338 | len = (FT_Int)( cur2 - cur ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 339 | if ( len > 0 && len < 22 ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 340 | { |
Werner Lemberg | ac39ecd | 2000-06-30 22:24:36 +0000 | [diff] [blame] | 341 | /* now compare the immediate name to the keyword table */ |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 342 | T1_Field keyword = (T1_Field) cid_field_records; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 343 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 344 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 345 | for (;;) |
| 346 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 347 | FT_Byte* name; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 348 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 349 | |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 350 | name = (FT_Byte*)keyword->ident; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 351 | if ( !name ) |
| 352 | break; |
| 353 | |
| 354 | if ( cur[0] == name[0] && |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 355 | len == (FT_Int)strlen( (const char*)name ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 356 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 357 | FT_Int n; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 358 | |
| 359 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 360 | for ( n = 1; n < len; n++ ) |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 361 | if ( cur[n] != name[n] ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 362 | break; |
| 363 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 364 | if ( n >= len ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 365 | { |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 366 | /* we found it - run the parsing callback */ |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 367 | parser->root.cursor = cur2; |
| 368 | CID_Skip_Spaces( parser ); |
Werner Lemberg | d1b7475 | 2000-08-24 16:29:15 +0000 | [diff] [blame] | 369 | parser->root.error = cid_load_keyword( face, |
| 370 | loader, |
| 371 | keyword ); |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 372 | if ( parser->root.error ) |
| 373 | return parser->root.error; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 374 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 375 | cur = parser->root.cursor; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 376 | break; |
| 377 | } |
| 378 | } |
| 379 | keyword++; |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | } |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 385 | return parser->root.error; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 389 | /* read the subrmap and the subrs of each font dict */ |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 390 | static FT_Error |
| 391 | cid_read_subrs( CID_Face face ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 392 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 393 | CID_FaceInfo cid = &face->cid; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 394 | FT_Memory memory = face->root.memory; |
| 395 | FT_Stream stream = face->root.stream; |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 396 | FT_Error error; |
David Turner | a1be2dc | 2000-06-27 23:20:35 +0000 | [diff] [blame] | 397 | FT_Int n; |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 398 | CID_Subrs subr; |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 399 | FT_UInt max_offsets = 0; |
| 400 | FT_ULong* offsets = 0; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 401 | |
| 402 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 403 | if ( FT_NEW_ARRAY( face->subrs, cid->num_dicts ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 404 | goto Exit; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 405 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 406 | subr = face->subrs; |
| 407 | for ( n = 0; n < cid->num_dicts; n++, subr++ ) |
| 408 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 409 | CID_FaceDict dict = cid->font_dicts + n; |
Tom Kacvinsky | 6862113 | 2001-03-12 02:17:50 +0000 | [diff] [blame] | 410 | FT_Int lenIV = dict->private_dict.lenIV; |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 411 | FT_UInt count, num_subrs = dict->num_subrs; |
| 412 | FT_ULong data_len; |
| 413 | FT_Byte* p; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 414 | |
| 415 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 416 | /* reallocate offsets array if needed */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 417 | if ( num_subrs + 1 > max_offsets ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 418 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 419 | FT_UInt new_max = ( num_subrs + 1 + 3 ) & -4; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 420 | |
| 421 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 422 | if ( FT_RENEW_ARRAY( offsets, max_offsets, new_max ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 423 | goto Fail; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 424 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 425 | max_offsets = new_max; |
| 426 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 427 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 428 | /* read the subrmap's offsets */ |
David Turner | 7d3a264 | 2002-03-20 10:49:31 +0000 | [diff] [blame] | 429 | if ( FT_STREAM_SEEK( cid->data_offset + dict->subrmap_offset ) || |
| 430 | FT_FRAME_ENTER( ( num_subrs + 1 ) * dict->sd_bytes ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 431 | goto Fail; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 432 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 433 | p = (FT_Byte*)stream->cursor; |
| 434 | for ( count = 0; count <= num_subrs; count++ ) |
David Turner | 81bb4ad | 2000-06-28 04:19:49 +0000 | [diff] [blame] | 435 | offsets[count] = cid_get_offset( &p, (FT_Byte)dict->sd_bytes ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 436 | |
David Turner | 7d3a264 | 2002-03-20 10:49:31 +0000 | [diff] [blame] | 437 | FT_FRAME_EXIT(); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 438 | |
| 439 | /* now, compute the size of subrs charstrings, */ |
| 440 | /* allocate, and read them */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 441 | data_len = offsets[num_subrs] - offsets[0]; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 442 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 443 | if ( FT_NEW_ARRAY( subr->code, num_subrs + 1 ) || |
| 444 | FT_ALLOC( subr->code[0], data_len ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 445 | goto Fail; |
| 446 | |
David Turner | 7d3a264 | 2002-03-20 10:49:31 +0000 | [diff] [blame] | 447 | if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) || |
| 448 | FT_STREAM_READ( subr->code[0], data_len ) ) |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 449 | goto Fail; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 450 | |
| 451 | /* set up pointers */ |
| 452 | for ( count = 1; count <= num_subrs; count++ ) |
| 453 | { |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 454 | FT_UInt len; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 455 | |
| 456 | |
| 457 | len = offsets[count] - offsets[count - 1]; |
| 458 | subr->code[count] = subr->code[count - 1] + len; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 459 | } |
| 460 | |
Werner Lemberg | 9a8b536 | 2001-03-12 22:33:52 +0000 | [diff] [blame] | 461 | /* decrypt subroutines, but only if lenIV >= 0 */ |
Tom Kacvinsky | 6862113 | 2001-03-12 02:17:50 +0000 | [diff] [blame] | 462 | if ( lenIV >= 0 ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 463 | { |
Tom Kacvinsky | 6862113 | 2001-03-12 02:17:50 +0000 | [diff] [blame] | 464 | for ( count = 0; count < num_subrs; count++ ) |
| 465 | { |
| 466 | FT_UInt len; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 467 | |
| 468 | |
Tom Kacvinsky | 6862113 | 2001-03-12 02:17:50 +0000 | [diff] [blame] | 469 | len = offsets[count + 1] - offsets[count]; |
| 470 | cid_decrypt( subr->code[count], len, 4330 ); |
| 471 | } |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | subr->num_subrs = num_subrs; |
| 475 | } |
| 476 | |
| 477 | Exit: |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 478 | FT_FREE( offsets ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 479 | return error; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 480 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 481 | Fail: |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 482 | if ( face->subrs ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 483 | { |
| 484 | for ( n = 0; n < cid->num_dicts; n++ ) |
| 485 | { |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 486 | if ( face->subrs[n].code ) |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 487 | FT_FREE( face->subrs[n].code[0] ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 488 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 489 | FT_FREE( face->subrs[n].code ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 490 | } |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 491 | FT_FREE( face->subrs ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 492 | } |
| 493 | goto Exit; |
| 494 | } |
| 495 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 496 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 497 | static void |
| 498 | t1_init_loader( CID_Loader* loader, |
| 499 | CID_Face face ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 500 | { |
David Turner | c6a9220 | 2000-07-04 18:12:13 +0000 | [diff] [blame] | 501 | FT_UNUSED( face ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 502 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 503 | FT_MEM_SET( loader, 0, sizeof ( *loader ) ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 504 | } |
| 505 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 506 | |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 507 | static void |
| 508 | t1_done_loader( CID_Loader* loader ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 509 | { |
| 510 | CID_Parser* parser = &loader->parser; |
| 511 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 512 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 513 | /* finalize parser */ |
| 514 | CID_Done_Parser( parser ); |
| 515 | } |
| 516 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 517 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 518 | FT_LOCAL_DEF( FT_Error ) |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 519 | CID_Open_Face( CID_Face face ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 520 | { |
| 521 | CID_Loader loader; |
| 522 | CID_Parser* parser; |
David Turner | f9b8dec | 2000-06-16 19:34:52 +0000 | [diff] [blame] | 523 | FT_Error error; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 524 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 525 | |
| 526 | t1_init_loader( &loader, face ); |
| 527 | |
| 528 | parser = &loader.parser; |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 529 | error = CID_New_Parser( parser, face->root.stream, face->root.memory, |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 530 | (PSAux_Service)face->psaux ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 531 | if ( error ) |
| 532 | goto Exit; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 533 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 534 | error = cid_parse_dict( face, &loader, |
| 535 | parser->postscript, |
| 536 | parser->postscript_len ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 537 | if ( error ) |
| 538 | goto Exit; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 539 | |
| 540 | face->cid.data_offset = loader.parser.data_offset; |
| 541 | error = cid_read_subrs( face ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 542 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 543 | Exit: |
| 544 | t1_done_loader( &loader ); |
| 545 | return error; |
| 546 | } |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 547 | |
| 548 | |
| 549 | /* END */ |