2000-12-08 03:42:29 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* cffload.c */
|
|
|
|
/* */
|
|
|
|
/* OpenType and CFF data/program tables loader (body) */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996-2000 by */
|
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
* builds/win32/detekt.mk: Fix .PHONY target for Intel compiler.
Renamed "ftnames.h" to "ftsnames.h", and FT_NAMES_H to
FT_SFNT_NAMES_H.
* docs/docmaker.py: Added generation of INDEX link in table of
contents.
* INSTALL, docs/BUILD: Updated documentation to indicate that the
compilation process has changed slightly (no more `src' required in
* builds/*/*-def.mk: Changed the objects directory from "obj" to
"objs".
* include/freetype/config/ftheader.h: Removed obsolete macros like
FT_SOURCE_FILE, etc. and added cache-specific macro definitions that
were previously defined in <freetype/ftcache.h>. Added comments to
be included in a new API Reference section.
* src/*/*: Removed the use of FT_SOURCE_FILE, etc. Now, each
component needs to add its own directory to the include path at
compile time. Modified all "rules.mk" and "descrip.mms"
accordingly.
* src/cid/cidobjs.c, src/cid/cidload.c, src/pcf/pcfread.c,
src/type1/t1load.c, src/type1/t1objs.c: Added a few casts to remove
compiler warnings in pedantic modes.
* include/config/ft2build.h, include/config/ftheader.h: The file
top-level <ft2build.h>.
* include/config/ftheader.h: Added new section describing the #include
macros.
the Type 2 glyph charstring (used by conversion programs).
* docs/docmaker.py: Added cross-references generation as well as
seac emulation provided by the Type 2 endchar operator.
* src/cid/cidafm.c, src/cid/cidafm.h: removed un-needed files,
Added support for clipped direct rendering in the smooth renderer.
* src/cff/t2objs.c (T2_Init_Face): For pure CFF fonts, set
2001-03-20 23:58:56 +01:00
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
2000-12-08 03:42:29 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
|
|
|
|
#include FT_TRUETYPE_TAGS_H
|
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "cffload.h"
|
|
|
|
#include "cffparse.h"
|
2000-12-08 03:42:29 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "cfferrs.h"
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
2001-01-03 01:21:59 +01:00
|
|
|
#define FT_COMPONENT trace_cffload
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
|
|
|
const FT_UShort cff_isoadobe_charset[229] =
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
0,
|
|
|
|
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,
|
|
|
|
109,
|
|
|
|
110,
|
|
|
|
111,
|
|
|
|
112,
|
|
|
|
113,
|
|
|
|
114,
|
|
|
|
115,
|
|
|
|
116,
|
|
|
|
117,
|
|
|
|
118,
|
|
|
|
119,
|
|
|
|
120,
|
|
|
|
121,
|
|
|
|
122,
|
|
|
|
123,
|
|
|
|
124,
|
|
|
|
125,
|
|
|
|
126,
|
|
|
|
127,
|
|
|
|
128,
|
|
|
|
129,
|
|
|
|
130,
|
|
|
|
131,
|
|
|
|
132,
|
|
|
|
133,
|
|
|
|
134,
|
|
|
|
135,
|
|
|
|
136,
|
|
|
|
137,
|
|
|
|
138,
|
|
|
|
139,
|
|
|
|
140,
|
|
|
|
141,
|
|
|
|
142,
|
|
|
|
143,
|
|
|
|
144,
|
|
|
|
145,
|
|
|
|
146,
|
|
|
|
147,
|
|
|
|
148,
|
|
|
|
149,
|
|
|
|
150,
|
|
|
|
151,
|
|
|
|
152,
|
|
|
|
153,
|
|
|
|
154,
|
|
|
|
155,
|
|
|
|
156,
|
|
|
|
157,
|
|
|
|
158,
|
|
|
|
159,
|
|
|
|
160,
|
|
|
|
161,
|
|
|
|
162,
|
|
|
|
163,
|
|
|
|
164,
|
|
|
|
165,
|
|
|
|
166,
|
|
|
|
167,
|
|
|
|
168,
|
|
|
|
169,
|
|
|
|
170,
|
|
|
|
171,
|
|
|
|
172,
|
|
|
|
173,
|
|
|
|
174,
|
|
|
|
175,
|
|
|
|
176,
|
|
|
|
177,
|
|
|
|
178,
|
|
|
|
179,
|
|
|
|
180,
|
|
|
|
181,
|
|
|
|
182,
|
|
|
|
183,
|
|
|
|
184,
|
|
|
|
185,
|
|
|
|
186,
|
|
|
|
187,
|
|
|
|
188,
|
|
|
|
189,
|
|
|
|
190,
|
|
|
|
191,
|
|
|
|
192,
|
|
|
|
193,
|
|
|
|
194,
|
|
|
|
195,
|
|
|
|
196,
|
|
|
|
197,
|
|
|
|
198,
|
|
|
|
199,
|
|
|
|
200,
|
|
|
|
201,
|
|
|
|
202,
|
|
|
|
203,
|
|
|
|
204,
|
|
|
|
205,
|
|
|
|
206,
|
|
|
|
207,
|
|
|
|
208,
|
|
|
|
209,
|
|
|
|
210,
|
|
|
|
211,
|
|
|
|
212,
|
|
|
|
213,
|
|
|
|
214,
|
|
|
|
215,
|
|
|
|
216,
|
|
|
|
217,
|
|
|
|
218,
|
|
|
|
219,
|
|
|
|
220,
|
|
|
|
221,
|
|
|
|
222,
|
|
|
|
223,
|
|
|
|
224,
|
|
|
|
225,
|
|
|
|
226,
|
|
|
|
227,
|
|
|
|
228
|
|
|
|
};
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
const FT_UShort cff_expert_charset[166] =
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
229,
|
|
|
|
230,
|
|
|
|
231,
|
|
|
|
232,
|
|
|
|
233,
|
|
|
|
234,
|
|
|
|
235,
|
|
|
|
236,
|
|
|
|
237,
|
|
|
|
238,
|
|
|
|
13,
|
|
|
|
14,
|
|
|
|
15,
|
|
|
|
99,
|
|
|
|
239,
|
|
|
|
240,
|
|
|
|
241,
|
|
|
|
242,
|
|
|
|
243,
|
|
|
|
244,
|
|
|
|
245,
|
|
|
|
246,
|
|
|
|
247,
|
|
|
|
248,
|
|
|
|
27,
|
|
|
|
28,
|
|
|
|
249,
|
|
|
|
250,
|
|
|
|
251,
|
|
|
|
252,
|
|
|
|
253,
|
|
|
|
254,
|
|
|
|
255,
|
|
|
|
256,
|
|
|
|
257,
|
|
|
|
258,
|
|
|
|
259,
|
|
|
|
260,
|
|
|
|
261,
|
|
|
|
262,
|
|
|
|
263,
|
|
|
|
264,
|
|
|
|
265,
|
|
|
|
266,
|
|
|
|
109,
|
|
|
|
110,
|
|
|
|
267,
|
|
|
|
268,
|
|
|
|
269,
|
|
|
|
270,
|
|
|
|
271,
|
|
|
|
272,
|
|
|
|
273,
|
|
|
|
274,
|
|
|
|
275,
|
|
|
|
276,
|
|
|
|
277,
|
|
|
|
278,
|
|
|
|
279,
|
|
|
|
280,
|
|
|
|
281,
|
|
|
|
282,
|
|
|
|
283,
|
|
|
|
284,
|
|
|
|
285,
|
|
|
|
286,
|
|
|
|
287,
|
|
|
|
288,
|
|
|
|
289,
|
|
|
|
290,
|
|
|
|
291,
|
|
|
|
292,
|
|
|
|
293,
|
|
|
|
294,
|
|
|
|
295,
|
|
|
|
296,
|
|
|
|
297,
|
|
|
|
298,
|
|
|
|
299,
|
|
|
|
300,
|
|
|
|
301,
|
|
|
|
302,
|
|
|
|
303,
|
|
|
|
304,
|
|
|
|
305,
|
|
|
|
306,
|
|
|
|
307,
|
|
|
|
308,
|
|
|
|
309,
|
|
|
|
310,
|
|
|
|
311,
|
|
|
|
312,
|
|
|
|
313,
|
|
|
|
314,
|
|
|
|
315,
|
|
|
|
316,
|
|
|
|
317,
|
|
|
|
318,
|
|
|
|
158,
|
|
|
|
155,
|
|
|
|
163,
|
|
|
|
319,
|
|
|
|
320,
|
|
|
|
321,
|
|
|
|
322,
|
|
|
|
323,
|
|
|
|
324,
|
|
|
|
325,
|
|
|
|
326,
|
|
|
|
150,
|
|
|
|
164,
|
|
|
|
169,
|
|
|
|
327,
|
|
|
|
328,
|
|
|
|
329,
|
|
|
|
330,
|
|
|
|
331,
|
|
|
|
332,
|
|
|
|
333,
|
|
|
|
334,
|
|
|
|
335,
|
|
|
|
336,
|
|
|
|
337,
|
|
|
|
338,
|
|
|
|
339,
|
|
|
|
340,
|
|
|
|
341,
|
|
|
|
342,
|
|
|
|
343,
|
|
|
|
344,
|
|
|
|
345,
|
|
|
|
346,
|
|
|
|
347,
|
|
|
|
348,
|
|
|
|
349,
|
|
|
|
350,
|
|
|
|
351,
|
|
|
|
352,
|
|
|
|
353,
|
|
|
|
354,
|
|
|
|
355,
|
|
|
|
356,
|
|
|
|
357,
|
|
|
|
358,
|
|
|
|
359,
|
|
|
|
360,
|
|
|
|
361,
|
|
|
|
362,
|
|
|
|
363,
|
|
|
|
364,
|
|
|
|
365,
|
|
|
|
366,
|
|
|
|
367,
|
|
|
|
368,
|
|
|
|
369,
|
|
|
|
370,
|
|
|
|
371,
|
|
|
|
372,
|
|
|
|
373,
|
|
|
|
374,
|
|
|
|
375,
|
|
|
|
376,
|
|
|
|
377,
|
|
|
|
378
|
|
|
|
};
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
const FT_UShort cff_expertsubset_charset[87] =
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
231,
|
|
|
|
232,
|
|
|
|
235,
|
|
|
|
236,
|
|
|
|
237,
|
|
|
|
238,
|
|
|
|
13,
|
|
|
|
14,
|
|
|
|
15,
|
|
|
|
99,
|
|
|
|
239,
|
|
|
|
240,
|
|
|
|
241,
|
|
|
|
242,
|
|
|
|
243,
|
|
|
|
244,
|
|
|
|
245,
|
|
|
|
246,
|
|
|
|
247,
|
|
|
|
248,
|
|
|
|
27,
|
|
|
|
28,
|
|
|
|
249,
|
|
|
|
250,
|
|
|
|
251,
|
|
|
|
253,
|
|
|
|
254,
|
|
|
|
255,
|
|
|
|
256,
|
|
|
|
257,
|
|
|
|
258,
|
|
|
|
259,
|
|
|
|
260,
|
|
|
|
261,
|
|
|
|
262,
|
|
|
|
263,
|
|
|
|
264,
|
|
|
|
265,
|
|
|
|
266,
|
|
|
|
109,
|
|
|
|
110,
|
|
|
|
267,
|
|
|
|
268,
|
|
|
|
269,
|
|
|
|
270,
|
|
|
|
272,
|
|
|
|
300,
|
|
|
|
301,
|
|
|
|
302,
|
|
|
|
305,
|
|
|
|
314,
|
|
|
|
315,
|
|
|
|
158,
|
|
|
|
155,
|
|
|
|
163,
|
|
|
|
320,
|
|
|
|
321,
|
|
|
|
322,
|
|
|
|
323,
|
|
|
|
324,
|
|
|
|
325,
|
|
|
|
326,
|
|
|
|
150,
|
|
|
|
164,
|
|
|
|
169,
|
|
|
|
327,
|
|
|
|
328,
|
|
|
|
329,
|
|
|
|
330,
|
|
|
|
331,
|
|
|
|
332,
|
|
|
|
333,
|
|
|
|
334,
|
|
|
|
335,
|
|
|
|
336,
|
|
|
|
337,
|
|
|
|
338,
|
|
|
|
339,
|
|
|
|
340,
|
|
|
|
341,
|
|
|
|
342,
|
|
|
|
343,
|
|
|
|
344,
|
|
|
|
345,
|
|
|
|
346
|
|
|
|
};
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
const FT_UShort cff_standard_encoding[256] =
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
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,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
96,
|
|
|
|
97,
|
|
|
|
98,
|
|
|
|
99,
|
|
|
|
100,
|
|
|
|
101,
|
|
|
|
102,
|
|
|
|
103,
|
|
|
|
104,
|
|
|
|
105,
|
|
|
|
106,
|
|
|
|
107,
|
|
|
|
108,
|
|
|
|
109,
|
|
|
|
110,
|
|
|
|
0,
|
|
|
|
111,
|
|
|
|
112,
|
|
|
|
113,
|
|
|
|
114,
|
|
|
|
0,
|
|
|
|
115,
|
|
|
|
116,
|
|
|
|
117,
|
|
|
|
118,
|
|
|
|
119,
|
|
|
|
120,
|
|
|
|
121,
|
|
|
|
122,
|
|
|
|
0,
|
|
|
|
123,
|
|
|
|
0,
|
|
|
|
124,
|
|
|
|
125,
|
|
|
|
126,
|
|
|
|
127,
|
|
|
|
128,
|
|
|
|
129,
|
|
|
|
130,
|
|
|
|
131,
|
|
|
|
0,
|
|
|
|
132,
|
|
|
|
133,
|
|
|
|
0,
|
|
|
|
134,
|
|
|
|
135,
|
|
|
|
136,
|
|
|
|
137,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
138,
|
|
|
|
0,
|
|
|
|
139,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
140,
|
|
|
|
141,
|
|
|
|
142,
|
|
|
|
143,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
144,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
145,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
146,
|
|
|
|
147,
|
|
|
|
148,
|
|
|
|
149,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
const FT_UShort cff_expert_encoding[256] =
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
229,
|
|
|
|
230,
|
|
|
|
0,
|
|
|
|
231,
|
|
|
|
232,
|
|
|
|
233,
|
|
|
|
234,
|
|
|
|
235,
|
|
|
|
236,
|
|
|
|
237,
|
|
|
|
238,
|
|
|
|
13,
|
|
|
|
14,
|
|
|
|
15,
|
|
|
|
99,
|
|
|
|
239,
|
|
|
|
240,
|
|
|
|
241,
|
|
|
|
242,
|
|
|
|
243,
|
|
|
|
244,
|
|
|
|
245,
|
|
|
|
246,
|
|
|
|
247,
|
|
|
|
248,
|
|
|
|
27,
|
|
|
|
28,
|
|
|
|
249,
|
|
|
|
250,
|
|
|
|
251,
|
|
|
|
252,
|
|
|
|
0,
|
|
|
|
253,
|
|
|
|
254,
|
|
|
|
255,
|
|
|
|
256,
|
|
|
|
257,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
258,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
259,
|
|
|
|
260,
|
|
|
|
261,
|
|
|
|
262,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
263,
|
|
|
|
264,
|
|
|
|
265,
|
|
|
|
0,
|
|
|
|
266,
|
|
|
|
109,
|
|
|
|
110,
|
|
|
|
267,
|
|
|
|
268,
|
|
|
|
269,
|
|
|
|
0,
|
|
|
|
270,
|
|
|
|
271,
|
|
|
|
272,
|
|
|
|
273,
|
|
|
|
274,
|
|
|
|
275,
|
|
|
|
276,
|
|
|
|
277,
|
|
|
|
278,
|
|
|
|
279,
|
|
|
|
280,
|
|
|
|
281,
|
|
|
|
282,
|
|
|
|
283,
|
|
|
|
284,
|
|
|
|
285,
|
|
|
|
286,
|
|
|
|
287,
|
|
|
|
288,
|
|
|
|
289,
|
|
|
|
290,
|
|
|
|
291,
|
|
|
|
292,
|
|
|
|
293,
|
|
|
|
294,
|
|
|
|
295,
|
|
|
|
296,
|
|
|
|
297,
|
|
|
|
298,
|
|
|
|
299,
|
|
|
|
300,
|
|
|
|
301,
|
|
|
|
302,
|
|
|
|
303,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
304,
|
|
|
|
305,
|
|
|
|
306,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
307,
|
|
|
|
308,
|
|
|
|
309,
|
|
|
|
310,
|
|
|
|
311,
|
|
|
|
0,
|
|
|
|
312,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
312,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
314,
|
|
|
|
315,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
316,
|
|
|
|
317,
|
|
|
|
318,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
158,
|
|
|
|
155,
|
|
|
|
163,
|
|
|
|
319,
|
|
|
|
320,
|
|
|
|
321,
|
|
|
|
322,
|
|
|
|
323,
|
|
|
|
324,
|
|
|
|
325,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
326,
|
|
|
|
150,
|
|
|
|
164,
|
|
|
|
169,
|
|
|
|
327,
|
|
|
|
328,
|
|
|
|
329,
|
|
|
|
330,
|
|
|
|
331,
|
|
|
|
332,
|
|
|
|
333,
|
|
|
|
334,
|
|
|
|
335,
|
|
|
|
336,
|
|
|
|
337,
|
|
|
|
338,
|
|
|
|
339,
|
|
|
|
340,
|
|
|
|
341,
|
|
|
|
342,
|
|
|
|
343,
|
|
|
|
344,
|
|
|
|
345,
|
|
|
|
346,
|
|
|
|
347,
|
|
|
|
348,
|
|
|
|
349,
|
|
|
|
350,
|
|
|
|
351,
|
|
|
|
352,
|
|
|
|
353,
|
|
|
|
354,
|
|
|
|
355,
|
|
|
|
356,
|
|
|
|
357,
|
|
|
|
358,
|
|
|
|
359,
|
|
|
|
360,
|
|
|
|
361,
|
|
|
|
362,
|
|
|
|
363,
|
|
|
|
364,
|
|
|
|
365,
|
|
|
|
366,
|
|
|
|
367,
|
|
|
|
368,
|
|
|
|
369,
|
|
|
|
370,
|
|
|
|
371,
|
|
|
|
372,
|
|
|
|
373,
|
|
|
|
374,
|
|
|
|
375,
|
|
|
|
376,
|
|
|
|
377,
|
|
|
|
378
|
|
|
|
};
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
/* read a CFF offset from memory */
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
FT_ULong cff_get_offset( FT_Byte* p,
|
|
|
|
FT_Byte off_size )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_ULong result;
|
|
|
|
|
|
|
|
|
|
|
|
for ( result = 0; off_size > 0; off_size-- )
|
|
|
|
{
|
|
|
|
result <<= 8;
|
|
|
|
result |= *p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
FT_Error cff_new_index( CFF_Index* index,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_Bool load )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_UShort count;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
MEM_Set( index, 0, sizeof ( *index ) );
|
|
|
|
|
|
|
|
index->stream = stream;
|
|
|
|
if ( !READ_UShort( count ) &&
|
|
|
|
count > 0 )
|
|
|
|
{
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_Byte offsize;
|
|
|
|
FT_ULong data_size;
|
|
|
|
FT_ULong* poff;
|
|
|
|
|
|
|
|
|
|
|
|
/* there is at least one element; read the offset size, */
|
|
|
|
/* then access the offset table to compute the index's total size */
|
|
|
|
if ( READ_Byte( offsize ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
index->stream = stream;
|
|
|
|
index->count = count;
|
|
|
|
index->off_size = offsize;
|
|
|
|
data_size = (FT_ULong)( count + 1 ) * offsize;
|
|
|
|
|
|
|
|
if ( ALLOC_ARRAY( index->offsets, count + 1, FT_ULong ) ||
|
|
|
|
ACCESS_Frame( data_size ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
poff = index->offsets;
|
|
|
|
p = (FT_Byte*)stream->cursor;
|
|
|
|
|
|
|
|
for ( ; (FT_Short)count >= 0; count-- )
|
|
|
|
{
|
|
|
|
poff[0] = cff_get_offset( p, offsize );
|
|
|
|
poff++;
|
|
|
|
p += offsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORGET_Frame();
|
|
|
|
|
|
|
|
index->data_offset = FILE_Pos();
|
|
|
|
data_size = poff[-1] - 1;
|
|
|
|
|
|
|
|
if ( load )
|
|
|
|
{
|
|
|
|
/* load the data */
|
|
|
|
if ( EXTRACT_Frame( data_size, index->bytes ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* skip the data */
|
|
|
|
if ( FILE_Skip( data_size ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if ( error )
|
|
|
|
FREE( index->offsets );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
void cff_done_index( CFF_Index* index )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
if ( index->stream )
|
|
|
|
{
|
|
|
|
FT_Stream stream = index->stream;
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
|
|
|
|
|
|
|
if ( index->bytes )
|
|
|
|
RELEASE_Frame( index->bytes );
|
|
|
|
|
|
|
|
FREE( index->offsets );
|
|
|
|
MEM_Set( index, 0, sizeof ( *index ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
FT_Error cff_explicit_index( CFF_Index* index,
|
|
|
|
FT_Byte*** table )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Error error = 0;
|
|
|
|
FT_Memory memory = index->stream->memory;
|
|
|
|
FT_UInt n, offset, old_offset;
|
|
|
|
FT_Byte** t;
|
|
|
|
|
|
|
|
|
|
|
|
*table = 0;
|
|
|
|
|
|
|
|
if ( index->count > 0 && !ALLOC_ARRAY( t, index->count + 1, FT_Byte* ) )
|
|
|
|
{
|
|
|
|
old_offset = 1;
|
|
|
|
for ( n = 0; n <= index->count; n++ )
|
|
|
|
{
|
|
|
|
offset = index->offsets[n];
|
|
|
|
if ( !offset )
|
|
|
|
offset = old_offset;
|
|
|
|
|
|
|
|
t[n] = index->bytes + offset - 1;
|
|
|
|
|
|
|
|
old_offset = offset;
|
|
|
|
}
|
|
|
|
*table = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
FT_Error CFF_Access_Element( CFF_Index* index,
|
|
|
|
FT_UInt element,
|
|
|
|
FT_Byte** pbytes,
|
|
|
|
FT_ULong* pbyte_len )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Error error = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ( index && index->count > element )
|
|
|
|
{
|
|
|
|
/* compute start and end offsets */
|
|
|
|
FT_ULong off1, off2 = 0;
|
|
|
|
|
|
|
|
|
|
|
|
off1 = index->offsets[element];
|
|
|
|
if ( off1 )
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
element++;
|
|
|
|
off2 = index->offsets[element];
|
|
|
|
|
|
|
|
} while ( off2 == 0 && element < index->count );
|
|
|
|
|
|
|
|
if ( !off2 )
|
|
|
|
off1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* access element */
|
|
|
|
if ( off1 )
|
|
|
|
{
|
|
|
|
*pbyte_len = off2 - off1;
|
|
|
|
|
|
|
|
if ( index->bytes )
|
|
|
|
{
|
|
|
|
/* this index was completely loaded in memory, that's easy */
|
|
|
|
*pbytes = index->bytes + off1 - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this index is still on disk/file, access it through a frame */
|
|
|
|
FT_Stream stream = index->stream;
|
|
|
|
|
|
|
|
|
|
|
|
if ( FILE_Seek( index->data_offset + off1 - 1 ) ||
|
|
|
|
EXTRACT_Frame( off2 - off1, *pbytes ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* empty index element */
|
|
|
|
*pbytes = 0;
|
|
|
|
*pbyte_len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-01-03 01:21:59 +01:00
|
|
|
error = CFF_Err_Invalid_Argument;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
void CFF_Forget_Element( CFF_Index* index,
|
|
|
|
FT_Byte** pbytes )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
if ( index->bytes == 0 )
|
|
|
|
{
|
|
|
|
FT_Stream stream = index->stream;
|
|
|
|
|
|
|
|
|
|
|
|
RELEASE_Frame( *pbytes );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
FT_String* CFF_Get_Name( CFF_Index* index,
|
|
|
|
FT_UInt element )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory = index->stream->memory;
|
|
|
|
FT_Byte* bytes;
|
|
|
|
FT_ULong byte_len;
|
|
|
|
FT_Error error;
|
|
|
|
FT_String* name = 0;
|
|
|
|
|
|
|
|
|
|
|
|
error = CFF_Access_Element( index, element, &bytes, &byte_len );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( !ALLOC( name, byte_len + 1 ) )
|
|
|
|
{
|
|
|
|
MEM_Copy( name, bytes, byte_len );
|
|
|
|
name[byte_len] = 0;
|
|
|
|
}
|
|
|
|
CFF_Forget_Element( index, &bytes );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
FT_String* CFF_Get_String( CFF_Index* index,
|
|
|
|
FT_UInt sid,
|
|
|
|
PSNames_Interface* interface )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
/* if it is not a standard string, return it */
|
|
|
|
if ( sid > 390 )
|
|
|
|
return CFF_Get_Name( index, sid - 391 );
|
|
|
|
|
|
|
|
/* that's a standard string, fetch a copy from the PSName module */
|
|
|
|
{
|
|
|
|
FT_String* name = 0;
|
|
|
|
const char* adobe_name = interface->adobe_std_strings( sid );
|
|
|
|
FT_UInt len;
|
|
|
|
|
|
|
|
|
|
|
|
if ( adobe_name )
|
|
|
|
{
|
|
|
|
FT_Memory memory = index->stream->memory;
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
|
|
|
|
len = (FT_UInt)strlen( adobe_name );
|
|
|
|
if ( !ALLOC( name, len + 1 ) )
|
|
|
|
{
|
|
|
|
MEM_Copy( name, adobe_name, len );
|
|
|
|
name[len] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*** ***/
|
|
|
|
/*** FD Select table support ***/
|
|
|
|
/*** ***/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
void CFF_Done_FD_Select( CFF_FD_Select* select,
|
|
|
|
FT_Stream stream )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
if ( select->data )
|
|
|
|
RELEASE_Frame( select->data );
|
|
|
|
|
|
|
|
select->data_size = 0;
|
|
|
|
select->format = 0;
|
|
|
|
select->range_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
FT_Error CFF_Load_FD_Select( CFF_FD_Select* select,
|
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong offset )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Byte format;
|
|
|
|
FT_UInt num_ranges;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* read format */
|
|
|
|
if ( FILE_Seek( offset ) || READ_Byte( format ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
select->format = format;
|
|
|
|
select->cache_count = 0; /* clear cache */
|
|
|
|
|
|
|
|
switch ( format )
|
|
|
|
{
|
|
|
|
case 0: /* format 0, that's simple */
|
|
|
|
select->data_size = num_glyphs;
|
|
|
|
goto Load_Data;
|
|
|
|
|
|
|
|
case 3: /* format 3, a tad more complex */
|
|
|
|
if ( READ_UShort( num_ranges ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
select->data_size = num_ranges * 3 + 2;
|
|
|
|
|
|
|
|
Load_Data:
|
|
|
|
if ( EXTRACT_Frame( select->data_size, select->data ) )
|
|
|
|
goto Exit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* hmm... that's wrong */
|
2001-01-03 01:21:59 +01:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
FT_Byte CFF_Get_FD( CFF_FD_Select* select,
|
|
|
|
FT_UInt glyph_index )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Byte fd = 0;
|
|
|
|
|
|
|
|
|
|
|
|
switch ( select->format )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
fd = select->data[glyph_index];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
/* first, compare to cache */
|
|
|
|
if ( (FT_UInt)(glyph_index-select->cache_first) < select->cache_count )
|
|
|
|
{
|
|
|
|
fd = select->cache_fd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then, lookup the ranges array */
|
|
|
|
{
|
|
|
|
FT_Byte* p = select->data;
|
|
|
|
FT_Byte* p_limit = p + select->data_size;
|
|
|
|
FT_Byte fd2;
|
|
|
|
FT_UInt first, limit;
|
|
|
|
|
|
|
|
|
|
|
|
first = NEXT_UShort( p );
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( glyph_index < first )
|
|
|
|
break;
|
|
|
|
|
|
|
|
fd2 = *p++;
|
|
|
|
limit = NEXT_UShort( p );
|
|
|
|
|
|
|
|
if ( glyph_index < limit )
|
|
|
|
{
|
|
|
|
fd = fd2;
|
|
|
|
|
|
|
|
/* update cache */
|
|
|
|
select->cache_first = first;
|
|
|
|
select->cache_count = limit-first;
|
|
|
|
select->cache_fd = fd2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
first = limit;
|
|
|
|
|
|
|
|
} while ( p < p_limit );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*** ***/
|
|
|
|
/*** CFF font support ***/
|
|
|
|
/*** ***/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
void CFF_Done_Encoding( CFF_Encoding* encoding,
|
|
|
|
FT_Stream stream )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
FREE( encoding->codes );
|
|
|
|
FREE( encoding->sids );
|
2000-12-08 03:42:29 +01:00
|
|
|
encoding->format = 0;
|
|
|
|
encoding->offset = 0;
|
2000-12-30 01:37:14 +01:00
|
|
|
encoding->codes = 0;
|
|
|
|
encoding->sids = 0;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
void CFF_Done_Charset( CFF_Charset* charset,
|
|
|
|
FT_Stream stream )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
FREE( charset->sids );
|
2000-12-08 03:42:29 +01:00
|
|
|
charset->format = 0;
|
|
|
|
charset->offset = 0;
|
2000-12-30 01:37:14 +01:00
|
|
|
charset->sids = 0;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_Error CFF_Load_Charset( CFF_Charset* charset,
|
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong base_offset,
|
|
|
|
FT_ULong offset )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_Error error = 0;
|
|
|
|
FT_UShort glyph_sid;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
charset->offset = base_offset + offset;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Get the format of the table. */
|
|
|
|
if ( FILE_Seek( charset->offset ) ||
|
|
|
|
READ_Byte( charset->format ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* If the the offset is greater than 2, we have to parse the */
|
|
|
|
/* charset table. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( offset > 2 )
|
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_UInt j;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Allocate memory for sids. */
|
2000-12-30 23:14:58 +01:00
|
|
|
if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* assign the .notdef glyph */
|
|
|
|
charset->sids[0] = 0;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
switch ( charset->format )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
case 0:
|
2000-12-30 01:37:14 +01:00
|
|
|
for ( j = 1; j < num_glyphs; j++ )
|
2000-12-08 17:17:16 +01:00
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( READ_UShort( glyph_sid ) )
|
|
|
|
goto Exit;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
charset->sids[j] = glyph_sid;
|
2000-12-08 17:17:16 +01:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
case 1:
|
2000-12-08 17:17:16 +01:00
|
|
|
case 2:
|
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_UInt nleft;
|
|
|
|
FT_UInt i;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
j = 1;
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
while ( j < num_glyphs )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
/* Read the first glyph sid of the range. */
|
|
|
|
if ( READ_UShort( glyph_sid ) )
|
2000-12-08 17:17:16 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Read the number of glyphs in the range. */
|
|
|
|
if ( charset->format == 2 )
|
|
|
|
{
|
|
|
|
if ( READ_UShort( nleft ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( READ_Byte( nleft ) )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in the range of sids -- `nleft + 1' glyphs. */
|
|
|
|
for ( i = 0; i <= nleft; i++, j++, glyph_sid++ )
|
|
|
|
charset->sids[j] = glyph_sid;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
default:
|
|
|
|
FT_ERROR(( "CFF_Load_Charset: invalid table format!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-08 17:17:16 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Parse default tables corresponding to offset == 0, 1, or 2. */
|
|
|
|
/* CFF specification intimates the following: */
|
|
|
|
/* */
|
|
|
|
/* In order to use a predefined charset, the following must be */
|
2000-12-30 23:14:58 +01:00
|
|
|
/* true: The charset constructed for the glyphs in the font's */
|
2000-12-30 01:37:14 +01:00
|
|
|
/* charstrings dictionary must match the predefined charset in */
|
|
|
|
/* the first num_glyphs, and hence must match the predefined */
|
|
|
|
/* charset *exactly*. */
|
|
|
|
|
|
|
|
switch ( offset )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if ( num_glyphs != 229 )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_ERROR(("CFF_Load_Charset: implicit charset not equal to\n"
|
|
|
|
"predefined charset (Adobe ISO-Latin)!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for sids. */
|
2000-12-30 23:14:58 +01:00
|
|
|
if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Copy the predefined charset into the allocated memory. */
|
2000-12-30 01:37:14 +01:00
|
|
|
MEM_Copy( charset->sids, cff_isoadobe_charset,
|
2000-12-30 23:14:58 +01:00
|
|
|
num_glyphs * sizeof ( FT_UShort ) );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if ( num_glyphs != 166 )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_ERROR(( "CFF_Load_Charset: implicit charset not equal to\n"
|
|
|
|
"predefined charset (Adobe Expert)!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for sids. */
|
2000-12-30 23:14:58 +01:00
|
|
|
if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Copy the predefined charset into the allocated memory. */
|
|
|
|
MEM_Copy( charset->sids, cff_expert_charset,
|
2000-12-30 23:14:58 +01:00
|
|
|
num_glyphs * sizeof ( FT_UShort ) );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if ( num_glyphs != 87 )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_ERROR(( "CFF_Load_Charset: implicit charset not equal to\n"
|
|
|
|
"predefined charset (Adobe Expert Subset)!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for sids. */
|
2000-12-30 23:14:58 +01:00
|
|
|
if ( ALLOC( charset->sids, num_glyphs * sizeof ( FT_UShort ) ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Copy the predefined charset into the allocated memory. */
|
|
|
|
MEM_Copy( charset->sids, cff_expertsubset_charset,
|
2000-12-30 23:14:58 +01:00
|
|
|
num_glyphs * sizeof ( FT_UShort ) );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
2000-12-30 01:37:14 +01:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
/* Clean up if there was an error. */
|
|
|
|
if ( error )
|
|
|
|
if ( charset->sids )
|
|
|
|
{
|
|
|
|
if ( charset->sids )
|
|
|
|
FREE( charset->sids );
|
|
|
|
charset->format = 0;
|
|
|
|
charset->offset = 0;
|
|
|
|
charset->sids = 0;
|
|
|
|
}
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
FT_Error CFF_Load_Encoding( CFF_Encoding* encoding,
|
2000-12-30 01:37:14 +01:00
|
|
|
CFF_Charset* charset,
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_UInt num_glyphs,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong base_offset,
|
|
|
|
FT_ULong offset )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_Error error = 0;
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_UInt count;
|
|
|
|
FT_UInt j;
|
|
|
|
FT_UShort glyph_sid;
|
|
|
|
FT_Byte glyph_code;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
|
|
|
/* Check for charset->sids. If we do not have this, we fail. */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( !charset->sids )
|
|
|
|
{
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Allocate memory for sids/codes -- there are at most 256 sids/codes */
|
|
|
|
/* for an encoding. */
|
2000-12-30 23:14:58 +01:00
|
|
|
if ( ALLOC( encoding->sids, 256 * sizeof ( FT_UShort ) ) ||
|
|
|
|
ALLOC( encoding->codes, 256 * sizeof ( FT_UShort ) ) )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Zero out the code to gid/sid mappings. */
|
2000-12-30 01:37:14 +01:00
|
|
|
for ( j = 0; j < 255; j++ )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
encoding->sids [j] = 0;
|
|
|
|
encoding->codes[j] = 0;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Note: The encoding table in a CFF font is indexed by glyph index, */
|
2000-12-30 01:37:14 +01:00
|
|
|
/* where the first encoded glyph index is 1. Hence, we read the char */
|
|
|
|
/* code (`glyph_code') at index j and make the assignment: */
|
|
|
|
/* */
|
|
|
|
/* encoding->codes[glyph_code] = j + 1 */
|
|
|
|
/* */
|
|
|
|
/* We also make the assignment: */
|
|
|
|
/* */
|
|
|
|
/* encoding->sids[glyph_code] = charset->sids[j + 1] */
|
|
|
|
/* */
|
|
|
|
/* This gives us both a code to GID and a code to SID mapping. */
|
|
|
|
|
|
|
|
if ( offset > 1 )
|
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
encoding->offset = base_offset + offset;
|
|
|
|
|
|
|
|
/* we need to parse the table to determine its size */
|
|
|
|
if ( FILE_Seek( encoding->offset ) ||
|
|
|
|
READ_Byte( encoding->format ) ||
|
|
|
|
READ_Byte( count ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
switch ( encoding->format & 0x7F )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-08 17:17:16 +01:00
|
|
|
case 0:
|
2000-12-30 01:37:14 +01:00
|
|
|
for ( j = 1; j <= count; j++ )
|
|
|
|
{
|
|
|
|
if ( READ_Byte( glyph_code ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Make sure j is not too big. */
|
|
|
|
if ( j > num_glyphs )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Assign code to GID mapping. */
|
|
|
|
encoding->codes[glyph_code] = j;
|
|
|
|
|
|
|
|
/* Assign code to SID mapping. */
|
|
|
|
encoding->sids[glyph_code] = charset->sids[j];
|
|
|
|
}
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
break;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
case 1:
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
FT_Byte nleft;
|
|
|
|
FT_Byte i = 1;
|
|
|
|
FT_Byte k;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Parse the Format1 ranges. */
|
|
|
|
for ( j = 0; j < count; j++, i += nleft )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read the first glyph code of the range. */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( READ_Byte( glyph_code ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read the number of codes in the range. */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( READ_Byte( nleft ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Increment nleft, so we read `nleft + 1' codes/sids. */
|
|
|
|
nleft++;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Fill in the range of codes/sids. */
|
2000-12-30 01:37:14 +01:00
|
|
|
for ( k = i; k < nleft + i; k++, glyph_code++ )
|
|
|
|
{
|
|
|
|
/* Make sure k is not too big. */
|
2001-03-20 12:14:24 +01:00
|
|
|
if ( (FT_UInt)k > num_glyphs )
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* Assign code to GID mapping. */
|
|
|
|
encoding->codes[glyph_code] = k;
|
|
|
|
|
|
|
|
/* Assign code to SID mapping. */
|
|
|
|
encoding->sids[glyph_code] = charset->sids[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-12-08 17:17:16 +01:00
|
|
|
break;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
default:
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_ERROR(( "CFF_Load_Encoding: invalid table format!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-08 17:17:16 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* Parse supplemental encodings, if any. */
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( encoding->format & 0x80 )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2000-12-30 01:37:14 +01:00
|
|
|
FT_UInt glyph_id;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
/* count supplements */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( READ_Byte( count ) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
for ( j = 0; j < count; j++ )
|
|
|
|
{
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read supplemental glyph code. */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( READ_Byte( glyph_code ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Read the SID associated with this glyph code. */
|
2000-12-30 01:37:14 +01:00
|
|
|
if ( READ_UShort( glyph_sid ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Assign code to SID mapping. */
|
2000-12-30 01:37:14 +01:00
|
|
|
encoding->sids[glyph_code] = glyph_sid;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* First, lookup GID which has been assigned to */
|
2000-12-30 01:37:14 +01:00
|
|
|
/* SID glyph_sid. */
|
|
|
|
for ( glyph_id = 0; glyph_id < num_glyphs; glyph_id++ )
|
|
|
|
{
|
|
|
|
if ( charset->sids[glyph_id] == glyph_sid )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
/* Now, make the assignment. */
|
2000-12-30 01:37:14 +01:00
|
|
|
encoding->codes[glyph_code] = glyph_id;
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-12-30 01:37:14 +01:00
|
|
|
{
|
|
|
|
FT_UInt i;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-30 01:37:14 +01:00
|
|
|
/* We take into account the fact a CFF font can use a predefined */
|
|
|
|
/* encoding without containing all of the glyphs encoded by this */
|
|
|
|
/* encoding (see the note at the end of section 12 in the CFF */
|
|
|
|
/* specification). */
|
|
|
|
|
|
|
|
switch ( offset )
|
|
|
|
{
|
|
|
|
case 0:
|
2000-12-30 23:14:58 +01:00
|
|
|
/* First, copy the code to SID mapping. */
|
2000-12-30 01:37:14 +01:00
|
|
|
MEM_Copy( encoding->sids, cff_standard_encoding,
|
2000-12-30 23:14:58 +01:00
|
|
|
256 * sizeof ( FT_UShort ) );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
/* Construct code to GID mapping from code */
|
|
|
|
/* to SID mapping and charset. */
|
|
|
|
for ( j = 0; j < 256; j++ )
|
|
|
|
{
|
|
|
|
/* If j is encoded, find the GID for it. */
|
|
|
|
if ( encoding->sids[j] )
|
|
|
|
{
|
|
|
|
for ( i = 1; i < num_glyphs; i++ )
|
|
|
|
/* We matched, so break. */
|
|
|
|
if ( charset->sids[i] == encoding->sids[j] )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* i will be equal to num_glyphs if we exited the above */
|
|
|
|
/* loop without a match. In this case, we also have to */
|
|
|
|
/* fix the code to SID mapping. */
|
|
|
|
if ( i == num_glyphs )
|
|
|
|
{
|
|
|
|
encoding->codes[j] = 0;
|
|
|
|
encoding->sids [j] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
encoding->codes[j] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
/* First, copy the code to SID mapping. */
|
|
|
|
MEM_Copy( encoding->sids, cff_expert_encoding,
|
2000-12-30 23:14:58 +01:00
|
|
|
256 * sizeof ( FT_UShort ) );
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
/* Construct code to GID mapping from code to SID mapping */
|
|
|
|
/* and charset. */
|
|
|
|
for ( j = 0; j < 256; j++ )
|
|
|
|
{
|
|
|
|
/* If j is encoded, find the GID for it. */
|
|
|
|
if ( encoding->sids[j] )
|
|
|
|
{
|
|
|
|
for ( i = 1; i < num_glyphs; i++ )
|
|
|
|
/* We matched, so break. */
|
|
|
|
if ( charset->sids[i] == encoding->sids[j] )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* i will be equal to num_glyphs if we exited the above */
|
|
|
|
/* loop without a match. In this case, we also have to */
|
|
|
|
/* fix the code to SID mapping. */
|
|
|
|
if ( i == num_glyphs )
|
|
|
|
{
|
|
|
|
encoding->codes[j] = 0;
|
|
|
|
encoding->sids [j] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
encoding->codes[j] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2000-12-30 23:14:58 +01:00
|
|
|
FT_ERROR(( "CFF_Load_Encoding: invalid table format!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Invalid_File_Format;
|
2000-12-30 01:37:14 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Exit:
|
2000-12-30 01:37:14 +01:00
|
|
|
|
|
|
|
/* Clean up if there was an error. */
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
if ( encoding->sids || encoding->codes )
|
|
|
|
{
|
|
|
|
if ( encoding->sids )
|
|
|
|
FREE( encoding->sids );
|
|
|
|
|
|
|
|
if ( encoding->codes )
|
|
|
|
FREE( encoding->codes );
|
|
|
|
|
|
|
|
charset->format = 0;
|
|
|
|
charset->offset = 0;
|
|
|
|
charset->sids = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
FT_Error CFF_Load_SubFont( CFF_SubFont* font,
|
|
|
|
CFF_Index* index,
|
|
|
|
FT_UInt font_index,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_ULong base_offset )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
2000-12-08 17:17:16 +01:00
|
|
|
CFF_Parser parser;
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_Byte* dict;
|
|
|
|
FT_ULong dict_len;
|
|
|
|
CFF_Font_Dict* top = &font->font_dict;
|
|
|
|
CFF_Private* priv = &font->private_dict;
|
|
|
|
|
|
|
|
|
|
|
|
CFF_Parser_Init( &parser, CFF_CODE_TOPDICT, &font->font_dict );
|
|
|
|
|
|
|
|
/* set defaults */
|
|
|
|
MEM_Set( top, 0, sizeof ( *top ) );
|
|
|
|
|
|
|
|
top->underline_position = -100;
|
|
|
|
top->underline_thickness = 50;
|
|
|
|
top->charstring_type = 2;
|
|
|
|
top->font_matrix.xx = 0x10000L;
|
|
|
|
top->font_matrix.yy = 0x10000L;
|
|
|
|
top->cid_count = 8720;
|
|
|
|
|
|
|
|
error = CFF_Access_Element( index, font_index, &dict, &dict_len ) ||
|
|
|
|
CFF_Parser_Run( &parser, dict, dict + dict_len );
|
|
|
|
|
|
|
|
CFF_Forget_Element( index, &dict );
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* if it is a CID font, we stop there */
|
|
|
|
if ( top->cid_registry )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* parse the private dictionary, if any */
|
|
|
|
if ( top->private_offset && top->private_size )
|
|
|
|
{
|
|
|
|
/* set defaults */
|
|
|
|
MEM_Set( priv, 0, sizeof ( *priv ) );
|
|
|
|
|
|
|
|
priv->blue_shift = 7;
|
|
|
|
priv->blue_fuzz = 1;
|
|
|
|
priv->lenIV = -1;
|
|
|
|
priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L;
|
|
|
|
priv->blue_scale = (FT_Fixed)0.039625 * 0x10000L;
|
|
|
|
|
|
|
|
CFF_Parser_Init( &parser, CFF_CODE_PRIVATE, priv );
|
|
|
|
|
|
|
|
if ( FILE_Seek( base_offset + font->font_dict.private_offset ) ||
|
|
|
|
ACCESS_Frame( font->font_dict.private_size ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
error = CFF_Parser_Run( &parser,
|
|
|
|
(FT_Byte*)stream->cursor,
|
|
|
|
(FT_Byte*)stream->limit );
|
|
|
|
FORGET_Frame();
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read the local subrs, if any */
|
|
|
|
if ( priv->local_subrs_offset )
|
|
|
|
{
|
|
|
|
if ( FILE_Seek( base_offset + top->private_offset +
|
|
|
|
priv->local_subrs_offset ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
error = cff_new_index( &font->local_subrs_index, stream, 1 );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
font->num_local_subrs = font->local_subrs_index.count;
|
|
|
|
error = cff_explicit_index( &font->local_subrs_index,
|
|
|
|
&font->local_subrs );
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( error )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
static
|
|
|
|
void CFF_Done_SubFont( FT_Memory memory,
|
|
|
|
CFF_SubFont* subfont )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
if ( subfont )
|
|
|
|
{
|
|
|
|
cff_done_index( &subfont->local_subrs_index );
|
|
|
|
FREE( subfont->local_subrs );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
FT_Error CFF_Load_Font( FT_Stream stream,
|
|
|
|
FT_Int face_index,
|
|
|
|
CFF_Font* font )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
static const FT_Frame_Field cff_header_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE CFF_Font
|
|
|
|
|
|
|
|
FT_FRAME_START( 4 ),
|
|
|
|
FT_FRAME_BYTE( version_major ),
|
|
|
|
FT_FRAME_BYTE( version_minor ),
|
|
|
|
FT_FRAME_BYTE( header_size ),
|
|
|
|
FT_FRAME_BYTE( absolute_offsize ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_ULong base_offset;
|
|
|
|
CFF_Font_Dict* dict;
|
|
|
|
|
|
|
|
|
|
|
|
MEM_Set( font, 0, sizeof ( *font ) );
|
|
|
|
|
|
|
|
font->stream = stream;
|
|
|
|
font->memory = memory;
|
|
|
|
dict = &font->top_font.font_dict;
|
|
|
|
base_offset = FILE_Pos();
|
|
|
|
|
|
|
|
/* read CFF font header */
|
|
|
|
if ( READ_Fields( cff_header_fields, font ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* check format */
|
|
|
|
if ( font->version_major != 1 ||
|
|
|
|
font->header_size < 4 ||
|
|
|
|
font->absolute_offsize > 4 )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "[not a CFF font header!]\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Unknown_File_Format;
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip the rest of the header */
|
|
|
|
if ( FILE_Skip( font->header_size - 4 ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* read the name, top dict, string and global subrs index */
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( FT_SET_ERROR( cff_new_index( &font->name_index, stream, 0 )) ||
|
|
|
|
FT_SET_ERROR( cff_new_index( &font->font_dict_index, stream, 0 )) ||
|
|
|
|
FT_SET_ERROR( cff_new_index( &font->string_index, stream, 0 )) ||
|
|
|
|
FT_SET_ERROR( cff_new_index( &font->global_subrs_index, stream, 1 )) )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* well, we don't really forget the `disabled' fonts... */
|
|
|
|
font->num_faces = font->name_index.count;
|
|
|
|
if ( face_index >= (FT_Int)font->num_faces )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "CFF_Load_Font: incorrect face index = %d\n",
|
|
|
|
face_index ));
|
2001-01-03 01:21:59 +01:00
|
|
|
error = CFF_Err_Invalid_Argument;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* in case of a font format check, simply exit now */
|
|
|
|
if ( face_index < 0 )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* now, parse the top-level font dictionary */
|
|
|
|
error = CFF_Load_SubFont( &font->top_font,
|
|
|
|
&font->font_dict_index,
|
|
|
|
face_index,
|
|
|
|
stream,
|
|
|
|
base_offset );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* now, check for a CID font */
|
|
|
|
if ( dict->cid_registry )
|
|
|
|
{
|
|
|
|
CFF_Index fd_index;
|
|
|
|
CFF_SubFont* sub;
|
|
|
|
FT_UInt index;
|
|
|
|
|
|
|
|
|
|
|
|
/* this is a CID-keyed font, we must now allocate a table of */
|
|
|
|
/* sub-fonts, then load each of them separately */
|
|
|
|
if ( FILE_Seek( base_offset + dict->cid_fd_array_offset ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
error = cff_new_index( &fd_index, stream, 0 );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( fd_index.count > CFF_MAX_CID_FONTS )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "CFF_Load_Font: FD array too large in CID font\n" ));
|
|
|
|
goto Fail_CID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate & read each font dict independently */
|
|
|
|
font->num_subfonts = fd_index.count;
|
|
|
|
if ( ALLOC_ARRAY( sub, fd_index.count, CFF_SubFont ) )
|
|
|
|
goto Fail_CID;
|
|
|
|
|
|
|
|
/* setup pointer table */
|
|
|
|
for ( index = 0; index < fd_index.count; index++ )
|
|
|
|
font->subfonts[index] = sub + index;
|
|
|
|
|
|
|
|
/* now load each sub font independently */
|
|
|
|
for ( index = 0; index < fd_index.count; index++ )
|
|
|
|
{
|
|
|
|
sub = font->subfonts[index];
|
|
|
|
error = CFF_Load_SubFont( sub, &fd_index, index,
|
|
|
|
stream, base_offset );
|
|
|
|
if ( error )
|
|
|
|
goto Fail_CID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now load the FD Select array */
|
|
|
|
error = CFF_Load_FD_Select( &font->fd_select,
|
|
|
|
dict->cid_count,
|
|
|
|
stream,
|
|
|
|
base_offset + dict->cid_fd_select_offset );
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
Fail_CID:
|
2000-12-08 03:42:29 +01:00
|
|
|
cff_done_index( &fd_index );
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
font->num_subfonts = 0;
|
|
|
|
|
|
|
|
/* read the charstrings index now */
|
|
|
|
if ( dict->charstrings_offset == 0 )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "CFF_Load_Font: no charstrings offset!\n" ));
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = CFF_Err_Unknown_File_Format;
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FILE_Seek( base_offset + dict->charstrings_offset ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
error = cff_new_index( &font->charstrings_index, stream, 0 );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* explicit the global subrs */
|
|
|
|
font->num_global_subrs = font->global_subrs_index.count;
|
|
|
|
font->num_glyphs = font->charstrings_index.count;
|
|
|
|
|
|
|
|
error = cff_explicit_index( &font->global_subrs_index,
|
|
|
|
&font->global_subrs ) ;
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* read the Charset and Encoding tables when available */
|
|
|
|
error = CFF_Load_Charset( &font->charset, font->num_glyphs, stream,
|
|
|
|
base_offset, dict->charset_offset );
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( error )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
error = CFF_Load_Encoding( &font->encoding,
|
|
|
|
&font->charset,
|
|
|
|
font->num_glyphs,
|
|
|
|
stream,
|
|
|
|
base_offset,
|
|
|
|
dict->encoding_offset );
|
2000-12-08 17:17:16 +01:00
|
|
|
if ( error )
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* get the font name */
|
|
|
|
font->font_name = CFF_Get_Name( &font->name_index, face_index );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_LOCAL_DEF
|
|
|
|
void CFF_Done_Font( CFF_Font* font )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory = font->memory;
|
|
|
|
FT_UInt index;
|
|
|
|
|
|
|
|
|
|
|
|
cff_done_index( &font->global_subrs_index );
|
|
|
|
cff_done_index( &font->string_index );
|
|
|
|
cff_done_index( &font->font_dict_index );
|
|
|
|
cff_done_index( &font->name_index );
|
|
|
|
cff_done_index( &font->charstrings_index );
|
|
|
|
|
|
|
|
/* release font dictionaries */
|
|
|
|
for ( index = 0; index < font->num_subfonts; index++ )
|
|
|
|
CFF_Done_SubFont( memory, font->subfonts[index] );
|
|
|
|
|
|
|
|
CFF_Done_Encoding( &font->encoding, font->stream );
|
|
|
|
CFF_Done_Charset( &font->charset, font->stream );
|
|
|
|
|
|
|
|
CFF_Done_SubFont( memory, &font->top_font );
|
|
|
|
|
|
|
|
CFF_Done_FD_Select( &font->fd_select, font->stream );
|
|
|
|
|
|
|
|
FREE( font->global_subrs );
|
|
|
|
FREE( font->font_name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|