• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************/
2 /*                                                                         */
3 /*  cffparse.h                                                             */
4 /*                                                                         */
5 /*    CFF token stream parser (specification)                              */
6 /*                                                                         */
7 /*  Copyright 1996-2003, 2011 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 #ifndef __CFF_PARSE_H__
20 #define __CFF_PARSE_H__
21 
22 
23 #include <ft2build.h>
24 #include "cfftypes.h"
25 #include FT_INTERNAL_OBJECTS_H
26 
27 
28 FT_BEGIN_HEADER
29 
30 
31 #define CFF_MAX_STACK_DEPTH  96
32 
33 #define CFF_CODE_TOPDICT  0x1000
34 #define CFF_CODE_PRIVATE  0x2000
35 
36 
37   typedef struct  CFF_ParserRec_
38   {
39     FT_Library library;
40     FT_Byte*   start;
41     FT_Byte*   limit;
42     FT_Byte*   cursor;
43 
44     FT_Byte*   stack[CFF_MAX_STACK_DEPTH + 1];
45     FT_Byte**  top;
46 
47     FT_UInt    object_code;
48     void*      object;
49 
50   } CFF_ParserRec, *CFF_Parser;
51 
52 
53   FT_LOCAL( void )
54   cff_parser_init( CFF_Parser  parser,
55                    FT_UInt     code,
56                    void*       object,
57                    FT_Library  library);
58 
59   FT_LOCAL( FT_Error )
60   cff_parser_run( CFF_Parser  parser,
61                   FT_Byte*    start,
62                   FT_Byte*    limit );
63 
64 
65   enum
66   {
67     cff_kind_none = 0,
68     cff_kind_num,
69     cff_kind_fixed,
70     cff_kind_fixed_thousand,
71     cff_kind_string,
72     cff_kind_bool,
73     cff_kind_delta,
74     cff_kind_callback,
75 
76     cff_kind_max  /* do not remove */
77   };
78 
79 
80   /* now generate handlers for the most simple fields */
81   typedef FT_Error  (*CFF_Field_Reader)( CFF_Parser  parser );
82 
83   typedef struct  CFF_Field_Handler_
84   {
85     int               kind;
86     int               code;
87     FT_UInt           offset;
88     FT_Byte           size;
89     CFF_Field_Reader  reader;
90     FT_UInt           array_max;
91     FT_UInt           count_offset;
92 
93 #ifdef FT_DEBUG_LEVEL_TRACE
94     const char*       id;
95 #endif
96 
97   } CFF_Field_Handler;
98 
99 
100 FT_END_HEADER
101 
102 
103 #endif /* __CFF_PARSE_H__ */
104 
105 
106 /* END */
107