sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
cffparse.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * cffparse.h
4 *
5 * CFF token stream parser (specification)
6 *
7 * Copyright (C) 1996-2025 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
23#ifndef CFFPARSE_H_
24#define CFFPARSE_H_
25
26
29
30
31FT_BEGIN_HEADER
32
33
34 /* CFF uses constant parser stack size; */
35 /* CFF2 can increase from default 193 */
36#define CFF_MAX_STACK_DEPTH 96
37
38 /*
39 * There are plans to remove the `maxstack' operator in a forthcoming
40 * revision of the CFF2 specification, increasing the (then static) stack
41 * size to 513. By making the default stack size equal to the maximum
42 * stack size, the operator is essentially disabled, which has the
43 * desired effect in FreeType.
44 */
45#define CFF2_MAX_STACK 513
46#define CFF2_DEFAULT_STACK 513
47
48#define CFF_CODE_TOPDICT 0x1000
49#define CFF_CODE_PRIVATE 0x2000
50#define CFF2_CODE_TOPDICT 0x3000
51#define CFF2_CODE_FONTDICT 0x4000
52#define CFF2_CODE_PRIVATE 0x5000
53
54
55 typedef struct CFF_ParserRec_
56 {
57 FT_Library library;
58 FT_Byte* start;
59 FT_Byte* limit;
60 FT_Byte* cursor;
61
62 FT_Byte** stack;
63 FT_Byte** top;
64 FT_UInt stackSize; /* allocated size */
65
66#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
67 FT_ListRec t2_strings;
68#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
69
70 FT_UInt object_code;
71 void* object;
72
73 FT_UShort num_designs; /* a copy of `CFF_FontRecDict->num_designs' */
74 FT_UShort num_axes; /* a copy of `CFF_FontRecDict->num_axes' */
75
76 } CFF_ParserRec, *CFF_Parser;
77
78
79 FT_LOCAL( FT_Long )
80 cff_parse_num( CFF_Parser parser,
81 FT_Byte** d );
82
83 FT_LOCAL( FT_Fixed )
84 cff_parse_fixed( CFF_Parser parser,
85 FT_Byte** d );
86
87 FT_LOCAL( FT_Error )
88 cff_parser_init( CFF_Parser parser,
89 FT_UInt code,
90 void* object,
91 FT_Library library,
92 FT_UInt stackSize,
93 FT_UShort num_designs,
94 FT_UShort num_axes );
95
96 FT_LOCAL( void )
97 cff_parser_done( CFF_Parser parser );
98
99 FT_LOCAL( FT_Error )
100 cff_parser_run( CFF_Parser parser,
101 FT_Byte* start,
102 FT_Byte* limit );
103
104
105 enum
106 {
107 cff_kind_none = 0,
108 cff_kind_num,
109 cff_kind_fixed,
110 cff_kind_fixed_thousand,
111 cff_kind_string,
112 cff_kind_bool,
113 cff_kind_delta,
114 cff_kind_delta_fixed,
115 cff_kind_callback,
116 cff_kind_blend,
117
118 cff_kind_max /* do not remove */
119 };
120
121
122 /* now generate handlers for the most simple fields */
123 typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser );
124
125 typedef struct CFF_Field_Handler_
126 {
127 int kind;
128 int code;
129 FT_UInt offset;
130 FT_Byte size;
131 CFF_Field_Reader reader;
132 FT_UInt array_max;
133 FT_UInt count_offset;
134
135#ifdef FT_DEBUG_LEVEL_TRACE
136 const char* id;
137#endif
138
139 } CFF_Field_Handler;
140
141
142FT_END_HEADER
143
144
145#endif /* CFFPARSE_H_ */
146
147
148/* END */