ReactOS 0.4.16-dev-981-g80eb313
cidload.c
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * cidload.c
4 *
5 * CID-keyed Type1 font loader (body).
6 *
7 * Copyright (C) 1996-2019 by
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
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
24#include FT_INTERNAL_POSTSCRIPT_AUX_H
25
26#include "cidload.h"
27
28#include "ciderrs.h"
29
30
31 /**************************************************************************
32 *
33 * The macro FT_COMPONENT is used in trace mode. It is an implicit
34 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
35 * messages during execution.
36 */
37#undef FT_COMPONENT
38#define FT_COMPONENT cidload
39
40
41 /* read a single offset */
44 FT_Byte offsize )
45 {
47 FT_Byte* p = *start;
48
49
50 for ( result = 0; offsize > 0; offsize-- )
51 {
52 result <<= 8;
53 result |= *p++;
54 }
55
56 *start = p;
57 return result;
58 }
59
60
61 /*************************************************************************/
62 /*************************************************************************/
63 /***** *****/
64 /***** TYPE 1 SYMBOL PARSING *****/
65 /***** *****/
66 /*************************************************************************/
67 /*************************************************************************/
68
69
70 static FT_Error
72 CID_Loader* loader,
73 const T1_Field keyword )
74 {
76 CID_Parser* parser = &loader->parser;
78 void* dummy_object;
79 CID_FaceInfo cid = &face->cid;
80
81
82 /* if the keyword has a dedicated callback, call it */
83 if ( keyword->type == T1_FIELD_TYPE_CALLBACK )
84 {
85 FT_TRACE4(( " %s", keyword->ident ));
86
87 keyword->reader( (FT_Face)face, parser );
88 error = parser->root.error;
89 goto Exit;
90 }
91
92 /* we must now compute the address of our target object */
93 switch ( keyword->location )
94 {
96 object = (FT_Byte*)cid;
97 break;
98
100 object = (FT_Byte*)&cid->font_info;
101 break;
102
104 object = (FT_Byte*)&face->font_extra;
105 break;
106
108 object = (FT_Byte*)&cid->font_bbox;
109 break;
110
111 default:
112 {
113 CID_FaceDict dict;
114
115
116 if ( parser->num_dict < 0 || parser->num_dict >= cid->num_dicts )
117 {
118 FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
119 keyword->ident ));
120 error = FT_THROW( Syntax_Error );
121 goto Exit;
122 }
123
124 dict = cid->font_dicts + parser->num_dict;
125 switch ( keyword->location )
126 {
128 object = (FT_Byte*)&dict->private_dict;
129 break;
130
131 default:
132 object = (FT_Byte*)dict;
133 }
134 }
135 }
136
137 FT_TRACE4(( " %s", keyword->ident ));
138
139 dummy_object = object;
140
141 /* now, load the keyword data in the object's field(s) */
142 if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
144 error = cid_parser_load_field_table( &loader->parser, keyword,
145 &dummy_object );
146 else
147 error = cid_parser_load_field( &loader->parser,
148 keyword, &dummy_object );
149
150 FT_TRACE4(( "\n" ));
151
152 Exit:
153 return error;
154 }
155
156
157 FT_CALLBACK_DEF( void )
160 {
161 CID_FaceDict dict;
162 FT_Face root = (FT_Face)&face->root;
163 FT_Fixed temp[6];
164 FT_Fixed temp_scale;
165
166
167 if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
168 {
172
173
174 dict = face->cid.font_dicts + parser->num_dict;
175 matrix = &dict->font_matrix;
176 offset = &dict->font_offset;
177
178 /* input is scaled by 1000 to accommodate default FontMatrix */
180
181 if ( result < 6 )
182 {
183 FT_ERROR(( "cid_parse_font_matrix: not enough matrix elements\n" ));
184 goto Exit;
185 }
186
187 FT_TRACE4(( " [%f %f %f %f %f %f]\n",
188 (double)temp[0] / 65536 / 1000,
189 (double)temp[1] / 65536 / 1000,
190 (double)temp[2] / 65536 / 1000,
191 (double)temp[3] / 65536 / 1000,
192 (double)temp[4] / 65536 / 1000,
193 (double)temp[5] / 65536 / 1000 ));
194
195 temp_scale = FT_ABS( temp[3] );
196
197 if ( temp_scale == 0 )
198 {
199 FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" ));
200 goto Exit;
201 }
202
203 /* atypical case */
204 if ( temp_scale != 0x10000L )
205 {
206 /* set units per EM based on FontMatrix values */
207 root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
208
209 temp[0] = FT_DivFix( temp[0], temp_scale );
210 temp[1] = FT_DivFix( temp[1], temp_scale );
211 temp[2] = FT_DivFix( temp[2], temp_scale );
212 temp[4] = FT_DivFix( temp[4], temp_scale );
213 temp[5] = FT_DivFix( temp[5], temp_scale );
214 temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
215 }
216
217 matrix->xx = temp[0];
218 matrix->yx = temp[1];
219 matrix->xy = temp[2];
220 matrix->yy = temp[3];
221
222 if ( !FT_Matrix_Check( matrix ) )
223 {
224 FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
225 parser->root.error = FT_THROW( Invalid_File_Format );
226 goto Exit;
227 }
228
229 /* note that the font offsets are expressed in integer font units */
230 offset->x = temp[4] >> 16;
231 offset->y = temp[5] >> 16;
232 }
233
234 Exit:
235 return;
236 }
237
238
239 FT_CALLBACK_DEF( void )
242 {
243 CID_FaceInfo cid = &face->cid;
244 FT_Memory memory = face->root.memory;
245 FT_Stream stream = parser->stream;
247 FT_Long num_dicts;
248
249
250 num_dicts = cid_parser_to_int( parser );
251 if ( num_dicts < 0 )
252 {
253 FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
254 goto Exit;
255 }
256
257 FT_TRACE4(( " %d\n", num_dicts ));
258
259 /*
260 * A single entry in the FDArray must (at least) contain the following
261 * structure elements.
262 *
263 * %ADOBeginFontDict 18
264 * X dict begin 13
265 * /FontMatrix [X X X X] 22
266 * /Private X dict begin 22
267 * end 4
268 * end 4
269 * %ADOEndFontDict 16
270 *
271 * This needs 18+13+22+22+4+4+16=99 bytes or more. Normally, you also
272 * need a `dup X' at the very beginning and a `put' at the end, so a
273 * rough guess using 100 bytes as the minimum is justified.
274 */
275 if ( (FT_ULong)num_dicts > stream->size / 100 )
276 {
277 FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
278 " (from %d to %d)\n",
279 num_dicts,
280 stream->size / 100 ));
281 num_dicts = (FT_Long)( stream->size / 100 );
282 }
283
284 if ( !cid->font_dicts )
285 {
286 FT_Int n;
287
288
289 if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )
290 goto Exit;
291
292 cid->num_dicts = num_dicts;
293
294 /* set some default values (the same as for Type 1 fonts) */
295 for ( n = 0; n < cid->num_dicts; n++ )
296 {
297 CID_FaceDict dict = cid->font_dicts + n;
298
299
300 dict->private_dict.blue_shift = 7;
301 dict->private_dict.blue_fuzz = 1;
302 dict->private_dict.lenIV = 4;
303 dict->private_dict.expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
305 0.039625 * 0x10000L * 1000 );
306 }
307 }
308
309 Exit:
310 return;
311 }
312
313
314 /* By mistake, `expansion_factor' appears both in PS_PrivateRec */
315 /* and CID_FaceDictRec (both are public header files and can't */
316 /* changed). We simply copy the value. */
317
318 FT_CALLBACK_DEF( void )
321 {
322 CID_FaceDict dict;
323
324
325 if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
326 {
327 dict = face->cid.font_dicts + parser->num_dict;
328
331
332 FT_TRACE4(( "%d\n", dict->expansion_factor ));
333 }
334
335 return;
336 }
337
338
339 /* By mistake, `CID_FaceDictRec' doesn't contain a field for the */
340 /* `FontName' keyword. FreeType doesn't need it, but it is nice */
341 /* to catch it for producing better trace output. */
342
343 FT_CALLBACK_DEF( void )
346 {
347#ifdef FT_DEBUG_LEVEL_TRACE
348 if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
349 {
351 FT_UInt len;
352
353
355
356 len = (FT_UInt)( token.limit - token.start );
357 if ( len )
358 FT_TRACE4(( " %.*s\n", len, token.start ));
359 else
360 FT_TRACE4(( " <no value>\n" ));
361 }
362#else
363 FT_UNUSED( face );
364 FT_UNUSED( parser );
365#endif
366
367 return;
368 }
369
370
371 static
373 {
374
375#include "cidtoken.h"
376
377 T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 )
378 T1_FIELD_CALLBACK( "FontMatrix", cid_parse_font_matrix, 0 )
379 T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 )
380 T1_FIELD_CALLBACK( "FontName", parse_font_name, 0 )
381
382 { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 }
383 };
384
385
386 static FT_Error
388 CID_Loader* loader,
389 FT_Byte* base,
390 FT_ULong size )
391 {
392 CID_Parser* parser = &loader->parser;
393
394
395 parser->root.cursor = base;
396 parser->root.limit = base + size;
397 parser->root.error = FT_Err_Ok;
398
399 {
400 FT_Byte* cur = base;
401 FT_Byte* limit = cur + size;
402
403
404 for (;;)
405 {
406 FT_Byte* newlimit;
407
408
409 parser->root.cursor = cur;
411
412 if ( parser->root.cursor >= limit )
413 newlimit = limit - 1 - 17;
414 else
415 newlimit = parser->root.cursor - 17;
416
417 /* look for `%ADOBeginFontDict' */
418 for ( ; cur < newlimit; cur++ )
419 {
420 if ( *cur == '%' &&
421 ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
422 {
423 /* if /FDArray was found, then cid->num_dicts is > 0, and */
424 /* we can start increasing parser->num_dict */
425 if ( face->cid.num_dicts > 0 )
426 {
427 parser->num_dict++;
428
429#ifdef FT_DEBUG_LEVEL_TRACE
430 FT_TRACE4(( " FontDict %d", parser->num_dict ));
431 if ( parser->num_dict > face->cid.num_dicts )
432 FT_TRACE4(( " (ignored)" ));
433 FT_TRACE4(( "\n" ));
434#endif
435 }
436 }
437 }
438
439 cur = parser->root.cursor;
440 /* no error can occur in cid_parser_skip_spaces */
441 if ( cur >= limit )
442 break;
443
445 if ( parser->root.cursor >= limit || parser->root.error )
446 break;
447
448 /* look for immediates */
449 if ( *cur == '/' && cur + 2 < limit )
450 {
451 FT_UInt len;
452
453
454 cur++;
455 len = (FT_UInt)( parser->root.cursor - cur );
456
457 if ( len > 0 && len < 22 )
458 {
459 /* now compare the immediate name to the keyword table */
461
462
463 for (;;)
464 {
465 FT_Byte* name;
466
467
468 name = (FT_Byte*)keyword->ident;
469 if ( !name )
470 break;
471
472 if ( cur[0] == name[0] &&
473 len == ft_strlen( (const char*)name ) )
474 {
475 FT_UInt n;
476
477
478 for ( n = 1; n < len; n++ )
479 if ( cur[n] != name[n] )
480 break;
481
482 if ( n >= len )
483 {
484 /* we found it - run the parsing callback */
486 loader,
487 keyword );
488 if ( parser->root.error )
489 return parser->root.error;
490 break;
491 }
492 }
493 keyword++;
494 }
495 }
496 }
497
498 cur = parser->root.cursor;
499 }
500
501 if ( !face->cid.num_dicts )
502 {
503 FT_ERROR(( "cid_parse_dict: No font dictionary found\n" ));
504 return FT_THROW( Invalid_File_Format );
505 }
506 }
507
508 return parser->root.error;
509 }
510
511
512 /* read the subrmap and the subrs of each font dict */
513 static FT_Error
515 {
516 CID_FaceInfo cid = &face->cid;
517 FT_Memory memory = face->root.memory;
518 FT_Stream stream = face->cid_stream;
520 FT_Int n;
521 CID_Subrs subr;
522 FT_UInt max_offsets = 0;
524 PSAux_Service psaux = (PSAux_Service)face->psaux;
525
526
527 if ( FT_NEW_ARRAY( face->subrs, cid->num_dicts ) )
528 goto Exit;
529
530 subr = face->subrs;
531 for ( n = 0; n < cid->num_dicts; n++, subr++ )
532 {
533 CID_FaceDict dict = cid->font_dicts + n;
535 FT_UInt count, num_subrs = dict->num_subrs;
536 FT_ULong data_len;
537 FT_Byte* p;
538
539
540 if ( !num_subrs )
541 continue;
542
543 /* reallocate offsets array if needed */
544 if ( num_subrs + 1 > max_offsets )
545 {
546 FT_UInt new_max = FT_PAD_CEIL( num_subrs + 1, 4 );
547
548
549 if ( new_max <= max_offsets )
550 {
551 error = FT_THROW( Syntax_Error );
552 goto Fail;
553 }
554
555 if ( FT_RENEW_ARRAY( offsets, max_offsets, new_max ) )
556 goto Fail;
557
558 max_offsets = new_max;
559 }
560
561 /* read the subrmap's offsets */
562 if ( FT_STREAM_SEEK( cid->data_offset + dict->subrmap_offset ) ||
563 FT_FRAME_ENTER( ( num_subrs + 1 ) * (FT_UInt)dict->sd_bytes ) )
564 goto Fail;
565
566 p = (FT_Byte*)stream->cursor;
567 for ( count = 0; count <= num_subrs; count++ )
569
571
572 /* offsets must be ordered */
573 for ( count = 1; count <= num_subrs; count++ )
574 if ( offsets[count - 1] > offsets[count] )
575 {
576 FT_ERROR(( "cid_read_subrs: offsets are not ordered\n" ));
577 error = FT_THROW( Invalid_File_Format );
578 goto Fail;
579 }
580
581 if ( offsets[num_subrs] > stream->size - cid->data_offset )
582 {
583 FT_ERROR(( "cid_read_subrs: too large `subrs' offsets\n" ));
584 error = FT_THROW( Invalid_File_Format );
585 goto Fail;
586 }
587
588 /* now, compute the size of subrs charstrings, */
589 /* allocate, and read them */
590 data_len = offsets[num_subrs] - offsets[0];
591
592 if ( FT_NEW_ARRAY( subr->code, num_subrs + 1 ) ||
593 FT_ALLOC( subr->code[0], data_len ) )
594 goto Fail;
595
596 if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) ||
597 FT_STREAM_READ( subr->code[0], data_len ) )
598 goto Fail;
599
600 /* set up pointers */
601 for ( count = 1; count <= num_subrs; count++ )
602 {
604
605
606 len = offsets[count] - offsets[count - 1];
607 subr->code[count] = subr->code[count - 1] + len;
608 }
609
610 /* decrypt subroutines, but only if lenIV >= 0 */
611 if ( lenIV >= 0 )
612 {
613 for ( count = 0; count < num_subrs; count++ )
614 {
616
617
618 len = offsets[count + 1] - offsets[count];
619 psaux->t1_decrypt( subr->code[count], len, 4330 );
620 }
621 }
622
623 subr->num_subrs = (FT_Int)num_subrs;
624 }
625
626 Exit:
627 FT_FREE( offsets );
628 return error;
629
630 Fail:
631 if ( face->subrs )
632 {
633 for ( n = 0; n < cid->num_dicts; n++ )
634 {
635 if ( face->subrs[n].code )
636 FT_FREE( face->subrs[n].code[0] );
637
638 FT_FREE( face->subrs[n].code );
639 }
640 FT_FREE( face->subrs );
641 }
642 goto Exit;
643 }
644
645
646 static void
648 CID_Face face )
649 {
650 FT_UNUSED( face );
651
652 FT_ZERO( loader );
653 }
654
655
656 static void
658 {
659 CID_Parser* parser = &loader->parser;
660
661
662 /* finalize parser */
664 }
665
666
667 static FT_Error
669 FT_ULong data_len,
671 CID_Face face )
672 {
673 FT_Stream stream = face->root.stream;
675
676 FT_Byte buffer[256];
677 FT_Byte *p, *plimit;
678 FT_Byte *d, *dlimit;
679 FT_Byte val;
680
681 FT_Bool upper_nibble, done;
682
683
684 if ( FT_STREAM_SEEK( offset ) )
685 goto Exit;
686
687 d = data;
688 dlimit = d + data_len;
689 p = buffer;
690 plimit = p;
691
692 upper_nibble = 1;
693 done = 0;
694
695 while ( d < dlimit )
696 {
697 if ( p >= plimit )
698 {
699 FT_ULong oldpos = FT_STREAM_POS();
700 FT_ULong size = stream->size - oldpos;
701
702
703 if ( size == 0 )
704 {
705 error = FT_THROW( Syntax_Error );
706 goto Exit;
707 }
708
709 if ( FT_STREAM_READ( buffer, 256 > size ? size : 256 ) )
710 goto Exit;
711 p = buffer;
712 plimit = p + FT_STREAM_POS() - oldpos;
713 }
714
715 if ( ft_isdigit( *p ) )
716 val = (FT_Byte)( *p - '0' );
717 else if ( *p >= 'a' && *p <= 'f' )
718 val = (FT_Byte)( *p - 'a' );
719 else if ( *p >= 'A' && *p <= 'F' )
720 val = (FT_Byte)( *p - 'A' + 10 );
721 else if ( *p == ' ' ||
722 *p == '\t' ||
723 *p == '\r' ||
724 *p == '\n' ||
725 *p == '\f' ||
726 *p == '\0' )
727 {
728 p++;
729 continue;
730 }
731 else if ( *p == '>' )
732 {
733 val = 0;
734 done = 1;
735 }
736 else
737 {
738 error = FT_THROW( Syntax_Error );
739 goto Exit;
740 }
741
742 if ( upper_nibble )
743 *d = (FT_Byte)( val << 4 );
744 else
745 {
746 *d = (FT_Byte)( *d + val );
747 d++;
748 }
749
750 upper_nibble = (FT_Byte)( 1 - upper_nibble );
751
752 if ( done )
753 break;
754
755 p++;
756 }
757
759
760 Exit:
761 return error;
762 }
763
764
767 FT_Int face_index )
768 {
769 CID_Loader loader;
771 FT_Memory memory = face->root.memory;
773 FT_Int n;
774
775 CID_FaceInfo cid = &face->cid;
776
777 FT_ULong binary_length;
778 FT_ULong entry_len;
779
780
781 cid_init_loader( &loader, face );
782
783 parser = &loader.parser;
784 error = cid_parser_new( parser, face->root.stream, face->root.memory,
785 (PSAux_Service)face->psaux );
786 if ( error )
787 goto Exit;
788
789 error = cid_parse_dict( face, &loader,
790 parser->postscript,
791 parser->postscript_len );
792 if ( error )
793 goto Exit;
794
795 if ( face_index < 0 )
796 goto Exit;
797
798 if ( FT_NEW( face->cid_stream ) )
799 goto Exit;
800
801 if ( parser->binary_length )
802 {
803 if ( parser->binary_length >
804 face->root.stream->size - parser->data_offset )
805 {
806 FT_TRACE0(( "cid_face_open: adjusting length of binary data\n"
807 " (from %d to %d bytes)\n",
808 parser->binary_length,
809 face->root.stream->size - parser->data_offset ));
810 parser->binary_length = face->root.stream->size -
811 parser->data_offset;
812 }
813
814 /* we must convert the data section from hexadecimal to binary */
815 if ( FT_ALLOC( face->binary_data, parser->binary_length ) ||
816 FT_SET_ERROR( cid_hex_to_binary( face->binary_data,
817 parser->binary_length,
818 parser->data_offset,
819 face ) ) )
820 goto Exit;
821
822 FT_Stream_OpenMemory( face->cid_stream,
823 face->binary_data, parser->binary_length );
824 cid->data_offset = 0;
825 }
826 else
827 {
828 *face->cid_stream = *face->root.stream;
829 cid->data_offset = loader.parser.data_offset;
830 }
831
832 /* sanity tests */
833
834 if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 )
835 {
836 FT_ERROR(( "cid_face_open:"
837 " Invalid `FDBytes' or `GDBytes' value\n" ));
838 error = FT_THROW( Invalid_File_Format );
839 goto Exit;
840 }
841
842 /* allow at most 32bit offsets */
843 if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 )
844 {
845 FT_ERROR(( "cid_face_open:"
846 " Values of `FDBytes' or `GDBytes' larger than 4\n"
847 " "
848 " are not supported\n" ));
849 error = FT_THROW( Invalid_File_Format );
850 goto Exit;
851 }
852
853 binary_length = face->cid_stream->size - cid->data_offset;
854 entry_len = (FT_ULong)( cid->fd_bytes + cid->gd_bytes );
855
856 for ( n = 0; n < cid->num_dicts; n++ )
857 {
858 CID_FaceDict dict = cid->font_dicts + n;
859
860
861 /* the upper limits are ad-hoc values */
862 if ( dict->private_dict.blue_shift > 1000 ||
863 dict->private_dict.blue_shift < 0 )
864 {
865 FT_TRACE2(( "cid_face_open:"
866 " setting unlikely BlueShift value %d to default (7)\n",
867 dict->private_dict.blue_shift ));
868 dict->private_dict.blue_shift = 7;
869 }
870
871 if ( dict->private_dict.blue_fuzz > 1000 ||
872 dict->private_dict.blue_fuzz < 0 )
873 {
874 FT_TRACE2(( "cid_face_open:"
875 " setting unlikely BlueFuzz value %d to default (1)\n",
876 dict->private_dict.blue_fuzz ));
877 dict->private_dict.blue_fuzz = 1;
878 }
879
880 if ( dict->sd_bytes < 0 ||
881 ( dict->num_subrs && dict->sd_bytes < 1 ) )
882 {
883 FT_ERROR(( "cid_face_open: Invalid `SDBytes' value\n" ));
884 error = FT_THROW( Invalid_File_Format );
885 goto Exit;
886 }
887
888 if ( dict->sd_bytes > 4 )
889 {
890 FT_ERROR(( "cid_face_open:"
891 " Values of `SDBytes' larger than 4"
892 " are not supported\n" ));
893 error = FT_THROW( Invalid_File_Format );
894 goto Exit;
895 }
896
897 if ( dict->subrmap_offset > binary_length )
898 {
899 FT_ERROR(( "cid_face_open: Invalid `SubrMapOffset' value\n" ));
900 error = FT_THROW( Invalid_File_Format );
901 goto Exit;
902 }
903
904 /* `num_subrs' is scanned as a signed integer */
905 if ( (FT_Int)dict->num_subrs < 0 ||
906 ( dict->sd_bytes &&
907 dict->num_subrs > ( binary_length - dict->subrmap_offset ) /
908 (FT_UInt)dict->sd_bytes ) )
909 {
910 FT_ERROR(( "cid_face_open: Invalid `SubrCount' value\n" ));
911 error = FT_THROW( Invalid_File_Format );
912 goto Exit;
913 }
914 }
915
916 if ( cid->cidmap_offset > binary_length )
917 {
918 FT_ERROR(( "cid_face_open: Invalid `CIDMapOffset' value\n" ));
919 error = FT_THROW( Invalid_File_Format );
920 goto Exit;
921 }
922
923 if ( entry_len &&
924 cid->cid_count >
925 ( binary_length - cid->cidmap_offset ) / entry_len )
926 {
927 FT_ERROR(( "cid_face_open: Invalid `CIDCount' value\n" ));
928 error = FT_THROW( Invalid_File_Format );
929 goto Exit;
930 }
931
932 /* we can now safely proceed */
934
935 Exit:
936 cid_done_loader( &loader );
937 return error;
938 }
939
940
941/* END */
parse_fd_array(CID_Face face, CID_Parser *parser)
Definition: cidload.c:240
static FT_Error cid_read_subrs(CID_Face face)
Definition: cidload.c:514
static void cid_init_loader(CID_Loader *loader, CID_Face face)
Definition: cidload.c:647
cid_get_offset(FT_Byte **start, FT_Byte offsize)
Definition: cidload.c:43
parse_font_name(CID_Face face, CID_Parser *parser)
Definition: cidload.c:344
static void cid_done_loader(CID_Loader *loader)
Definition: cidload.c:657
static FT_Error cid_load_keyword(CID_Face face, CID_Loader *loader, const T1_Field keyword)
Definition: cidload.c:71
parse_expansion_factor(CID_Face face, CID_Parser *parser)
Definition: cidload.c:319
cid_face_open(CID_Face face, FT_Int face_index)
Definition: cidload.c:766
static FT_Error cid_hex_to_binary(FT_Byte *data, FT_ULong data_len, FT_ULong offset, CID_Face face)
Definition: cidload.c:668
static const T1_FieldRec cid_field_records[]
Definition: cidload.c:372
static FT_Error cid_parse_dict(CID_Face face, CID_Loader *loader, FT_Byte *base, FT_ULong size)
Definition: cidload.c:387
cid_parse_font_matrix(CID_Face face, CID_Parser *parser)
Definition: cidload.c:158
FT_BEGIN_HEADER struct CID_Loader_ CID_Loader
cid_parser_new(CID_Parser *parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux)
Definition: cidparse.c:57
cid_parser_done(CID_Parser *parser)
Definition: cidparse.c:263
#define cid_parser_skip_PS_token(p)
Definition: cidparse.h:105
FT_BEGIN_HEADER struct CID_Parser_ CID_Parser
#define cid_parser_to_fixed_array(p, m, f, t)
Definition: cidparse.h:113
#define cid_parser_load_field(p, f, o)
Definition: cidparse.h:120
#define cid_parser_load_field_table(p, f, o)
Definition: cidparse.h:122
#define cid_parser_to_int(p)
Definition: cidparse.h:108
#define cid_parser_skip_spaces(p)
Definition: cidparse.h:103
#define cid_parser_to_fixed(p, t)
Definition: cidparse.h:109
#define cid_parser_to_token(p, t)
Definition: cidparse.h:115
#define NULL
Definition: types.h:112
int Fail
Definition: ehthrow.cxx:24
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:608
struct FT_FaceRec_ * FT_Face
Definition: freetype.h:499
return FT_Err_Ok
Definition: ftbbox.c:527
FT_Matrix_Check(const FT_Matrix *matrix)
Definition: ftcalc.c:751
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:544
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:387
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_TRACE0(varformat)
Definition: ftdebug.h:185
#define FT_ERROR(varformat)
Definition: ftdebug.h:209
#define FT_THROW(e)
Definition: ftdebug.h:241
#define FT_TRACE2(varformat)
Definition: ftdebug.h:187
#define FT_TRACE4(varformat)
Definition: ftdebug.h:189
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:332
#define FT_NEW(ptr)
Definition: ftmemory.h:330
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:42
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:302
#define FT_FREE(ptr)
Definition: ftmemory.h:328
#define FT_ZERO(p)
Definition: ftmemory.h:237
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:335
#define FT_ABS(a)
Definition: ftobjs.h:73
#define ft_isdigit(x)
Definition: ftobjs.h:116
#define FT_PAD_CEIL(x, n)
Definition: ftobjs.h:89
#define ft_strncmp
Definition: ftstdlib.h:89
#define ft_strlen
Definition: ftstdlib.h:88
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:537
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:514
#define FT_STREAM_POS()
Definition: ftstream.h:511
#define FT_FRAME_EXIT()
Definition: ftstream.h:542
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:522
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
Definition: ftstream.c:35
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned char FT_Byte
Definition: fttypes.h:154
signed long FT_Fixed
Definition: fttypes.h:287
int FT_Error
Definition: fttypes.h:299
signed long FT_Long
Definition: fttypes.h:242
unsigned short FT_UShort
Definition: fttypes.h:209
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
static const FxOffsetAndName offsets[]
FxCollectionEntry * cur
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLint limit
Definition: glext.h:10326
GLuint GLenum matrix
Definition: glext.h:9407
GLuint GLfloat * val
Definition: glext.h:7180
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define d
Definition: ke_i.h:81
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
#define for
Definition: utility.h:88
static char memory[1024 *256]
Definition: process.c:116
static TfClientId cid
struct PSAux_ServiceRec_ * PSAux_Service
@ T1_FIELD_TYPE_INTEGER_ARRAY
Definition: psaux.h:221
@ T1_FIELD_TYPE_NONE
Definition: psaux.h:212
@ T1_FIELD_TYPE_CALLBACK
Definition: psaux.h:223
@ T1_FIELD_TYPE_FIXED_ARRAY
Definition: psaux.h:222
#define T1_FIELD_CALLBACK(_ident, _name, _dict)
Definition: psaux.h:359
@ T1_FIELD_LOCATION_FONT_EXTRA
Definition: psaux.h:235
@ T1_FIELD_LOCATION_CID_INFO
Definition: psaux.h:233
@ T1_FIELD_LOCATION_BBOX
Definition: psaux.h:238
@ T1_FIELD_LOCATION_PRIVATE
Definition: psaux.h:237
@ T1_FIELD_LOCATION_FONT_INFO
Definition: psaux.h:236
struct T1_FieldRec_ * T1_Field
Definition: psaux.h:181
static calc_node_t temp
Definition: rpn_ieee.c:38
static void Exit(void)
Definition: sock.c:1330
FT_ULong subrmap_offset
Definition: t1tables.h:363
FT_UInt num_subrs
Definition: t1tables.h:362
PS_PrivateRec private_dict
Definition: t1tables.h:350
FT_Matrix font_matrix
Definition: t1tables.h:359
FT_Vector font_offset
Definition: t1tables.h:360
FT_Fixed expansion_factor
Definition: t1tables.h:355
FT_Int sd_bytes
Definition: t1tables.h:364
FT_Byte ** code
Definition: t1types.h:136
FT_Int num_subrs
Definition: t1types.h:135
void(* t1_decrypt)(FT_Byte *buffer, FT_Offset length, FT_UShort seed)
Definition: psaux.h:1354
FT_Int blue_fuzz
Definition: t1tables.h:155
FT_Fixed expansion_factor
Definition: t1tables.h:168
FT_Int lenIV
Definition: t1tables.h:140
FT_Int blue_shift
Definition: t1tables.h:154
FT_Fixed blue_scale
Definition: t1tables.h:153
Definition: name.c:39
Definition: import.c:81
unsigned int error
Definition: inffile.c:97
Definition: parse.h:23
unsigned int size
Definition: parse.h:27
lenIV
Definition: t1tokens.h:60