1
0

psaux.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. /***************************************************************************/
  2. /* */
  3. /* psaux.h */
  4. /* */
  5. /* Auxiliary functions and data structures related to PostScript fonts */
  6. /* (specification). */
  7. /* */
  8. /* Copyright 1996-2004, 2006, 2008, 2009, 2012 by */
  9. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  10. /* */
  11. /* This file is part of the FreeType project, and may only be used, */
  12. /* modified, and distributed under the terms of the FreeType project */
  13. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /***************************************************************************/
  18. #ifndef __PSAUX_H__
  19. #define __PSAUX_H__
  20. #include <ft2build.h>
  21. #include FT_INTERNAL_OBJECTS_H
  22. #include FT_INTERNAL_TYPE1_TYPES_H
  23. #include FT_SERVICE_POSTSCRIPT_CMAPS_H
  24. FT_BEGIN_HEADER
  25. /*************************************************************************/
  26. /*************************************************************************/
  27. /***** *****/
  28. /***** T1_TABLE *****/
  29. /***** *****/
  30. /*************************************************************************/
  31. /*************************************************************************/
  32. typedef struct PS_TableRec_* PS_Table;
  33. typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs;
  34. /*************************************************************************/
  35. /* */
  36. /* <Struct> */
  37. /* PS_Table_FuncsRec */
  38. /* */
  39. /* <Description> */
  40. /* A set of function pointers to manage PS_Table objects. */
  41. /* */
  42. /* <Fields> */
  43. /* table_init :: Used to initialize a table. */
  44. /* */
  45. /* table_done :: Finalizes resp. destroy a given table. */
  46. /* */
  47. /* table_add :: Adds a new object to a table. */
  48. /* */
  49. /* table_release :: Releases table data, then finalizes it. */
  50. /* */
  51. typedef struct PS_Table_FuncsRec_
  52. {
  53. FT_Error
  54. (*init)( PS_Table table,
  55. FT_Int count,
  56. FT_Memory memory );
  57. void
  58. (*done)( PS_Table table );
  59. FT_Error
  60. (*add)( PS_Table table,
  61. FT_Int idx,
  62. void* object,
  63. FT_PtrDist length );
  64. void
  65. (*release)( PS_Table table );
  66. } PS_Table_FuncsRec;
  67. /*************************************************************************/
  68. /* */
  69. /* <Struct> */
  70. /* PS_TableRec */
  71. /* */
  72. /* <Description> */
  73. /* A PS_Table is a simple object used to store an array of objects in */
  74. /* a single memory block. */
  75. /* */
  76. /* <Fields> */
  77. /* block :: The address in memory of the growheap's block. This */
  78. /* can change between two object adds, due to */
  79. /* reallocation. */
  80. /* */
  81. /* cursor :: The current top of the grow heap within its block. */
  82. /* */
  83. /* capacity :: The current size of the heap block. Increments by */
  84. /* 1kByte chunks. */
  85. /* */
  86. /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */
  87. /* been allocated. */
  88. /* */
  89. /* max_elems :: The maximum number of elements in table. */
  90. /* */
  91. /* num_elems :: The current number of elements in table. */
  92. /* */
  93. /* elements :: A table of element addresses within the block. */
  94. /* */
  95. /* lengths :: A table of element sizes within the block. */
  96. /* */
  97. /* memory :: The object used for memory operations */
  98. /* (alloc/realloc). */
  99. /* */
  100. /* funcs :: A table of method pointers for this object. */
  101. /* */
  102. typedef struct PS_TableRec_
  103. {
  104. FT_Byte* block; /* current memory block */
  105. FT_Offset cursor; /* current cursor in memory block */
  106. FT_Offset capacity; /* current size of memory block */
  107. FT_Long init;
  108. FT_Int max_elems;
  109. FT_Int num_elems;
  110. FT_Byte** elements; /* addresses of table elements */
  111. FT_PtrDist* lengths; /* lengths of table elements */
  112. FT_Memory memory;
  113. PS_Table_FuncsRec funcs;
  114. } PS_TableRec;
  115. /*************************************************************************/
  116. /*************************************************************************/
  117. /***** *****/
  118. /***** T1 FIELDS & TOKENS *****/
  119. /***** *****/
  120. /*************************************************************************/
  121. /*************************************************************************/
  122. typedef struct PS_ParserRec_* PS_Parser;
  123. typedef struct T1_TokenRec_* T1_Token;
  124. typedef struct T1_FieldRec_* T1_Field;
  125. /* simple enumeration type used to identify token types */
  126. typedef enum T1_TokenType_
  127. {
  128. T1_TOKEN_TYPE_NONE = 0,
  129. T1_TOKEN_TYPE_ANY,
  130. T1_TOKEN_TYPE_STRING,
  131. T1_TOKEN_TYPE_ARRAY,
  132. T1_TOKEN_TYPE_KEY, /* aka `name' */
  133. /* do not remove */
  134. T1_TOKEN_TYPE_MAX
  135. } T1_TokenType;
  136. /* a simple structure used to identify tokens */
  137. typedef struct T1_TokenRec_
  138. {
  139. FT_Byte* start; /* first character of token in input stream */
  140. FT_Byte* limit; /* first character after the token */
  141. T1_TokenType type; /* type of token */
  142. } T1_TokenRec;
  143. /* enumeration type used to identify object fields */
  144. typedef enum T1_FieldType_
  145. {
  146. T1_FIELD_TYPE_NONE = 0,
  147. T1_FIELD_TYPE_BOOL,
  148. T1_FIELD_TYPE_INTEGER,
  149. T1_FIELD_TYPE_FIXED,
  150. T1_FIELD_TYPE_FIXED_1000,
  151. T1_FIELD_TYPE_STRING,
  152. T1_FIELD_TYPE_KEY,
  153. T1_FIELD_TYPE_BBOX,
  154. T1_FIELD_TYPE_MM_BBOX,
  155. T1_FIELD_TYPE_INTEGER_ARRAY,
  156. T1_FIELD_TYPE_FIXED_ARRAY,
  157. T1_FIELD_TYPE_CALLBACK,
  158. /* do not remove */
  159. T1_FIELD_TYPE_MAX
  160. } T1_FieldType;
  161. typedef enum T1_FieldLocation_
  162. {
  163. T1_FIELD_LOCATION_CID_INFO,
  164. T1_FIELD_LOCATION_FONT_DICT,
  165. T1_FIELD_LOCATION_FONT_EXTRA,
  166. T1_FIELD_LOCATION_FONT_INFO,
  167. T1_FIELD_LOCATION_PRIVATE,
  168. T1_FIELD_LOCATION_BBOX,
  169. T1_FIELD_LOCATION_LOADER,
  170. T1_FIELD_LOCATION_FACE,
  171. T1_FIELD_LOCATION_BLEND,
  172. /* do not remove */
  173. T1_FIELD_LOCATION_MAX
  174. } T1_FieldLocation;
  175. typedef void
  176. (*T1_Field_ParseFunc)( FT_Face face,
  177. FT_Pointer parser );
  178. /* structure type used to model object fields */
  179. typedef struct T1_FieldRec_
  180. {
  181. const char* ident; /* field identifier */
  182. T1_FieldLocation location;
  183. T1_FieldType type; /* type of field */
  184. T1_Field_ParseFunc reader;
  185. FT_UInt offset; /* offset of field in object */
  186. FT_Byte size; /* size of field in bytes */
  187. FT_UInt array_max; /* maximum number of elements for */
  188. /* array */
  189. FT_UInt count_offset; /* offset of element count for */
  190. /* arrays; must not be zero if in */
  191. /* use -- in other words, a */
  192. /* `num_FOO' element must not */
  193. /* start the used structure if we */
  194. /* parse a `FOO' array */
  195. FT_UInt dict; /* where we expect it */
  196. } T1_FieldRec;
  197. #define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */
  198. #define T1_FIELD_DICT_PRIVATE ( 1 << 1 )
  199. #define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \
  200. { \
  201. _ident, T1CODE, _type, \
  202. 0, \
  203. FT_FIELD_OFFSET( _fname ), \
  204. FT_FIELD_SIZE( _fname ), \
  205. 0, 0, \
  206. _dict \
  207. },
  208. #define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \
  209. { \
  210. _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \
  211. (T1_Field_ParseFunc)_reader, \
  212. 0, 0, \
  213. 0, 0, \
  214. _dict \
  215. },
  216. #define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \
  217. { \
  218. _ident, T1CODE, _type, \
  219. 0, \
  220. FT_FIELD_OFFSET( _fname ), \
  221. FT_FIELD_SIZE_DELTA( _fname ), \
  222. _max, \
  223. FT_FIELD_OFFSET( num_ ## _fname ), \
  224. _dict \
  225. },
  226. #define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \
  227. { \
  228. _ident, T1CODE, _type, \
  229. 0, \
  230. FT_FIELD_OFFSET( _fname ), \
  231. FT_FIELD_SIZE_DELTA( _fname ), \
  232. _max, 0, \
  233. _dict \
  234. },
  235. #define T1_FIELD_BOOL( _ident, _fname, _dict ) \
  236. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict )
  237. #define T1_FIELD_NUM( _ident, _fname, _dict ) \
  238. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict )
  239. #define T1_FIELD_FIXED( _ident, _fname, _dict ) \
  240. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict )
  241. #define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \
  242. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \
  243. _dict )
  244. #define T1_FIELD_STRING( _ident, _fname, _dict ) \
  245. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict )
  246. #define T1_FIELD_KEY( _ident, _fname, _dict ) \
  247. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict )
  248. #define T1_FIELD_BBOX( _ident, _fname, _dict ) \
  249. T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict )
  250. #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \
  251. T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
  252. _fname, _fmax, _dict )
  253. #define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \
  254. T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
  255. _fname, _fmax, _dict )
  256. #define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \
  257. T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
  258. _fname, _fmax, _dict )
  259. #define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \
  260. T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
  261. _fname, _fmax, _dict )
  262. #define T1_FIELD_CALLBACK( _ident, _name, _dict ) \
  263. T1_NEW_CALLBACK_FIELD( _ident, _name, _dict )
  264. /*************************************************************************/
  265. /*************************************************************************/
  266. /***** *****/
  267. /***** T1 PARSER *****/
  268. /***** *****/
  269. /*************************************************************************/
  270. /*************************************************************************/
  271. typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs;
  272. typedef struct PS_Parser_FuncsRec_
  273. {
  274. void
  275. (*init)( PS_Parser parser,
  276. FT_Byte* base,
  277. FT_Byte* limit,
  278. FT_Memory memory );
  279. void
  280. (*done)( PS_Parser parser );
  281. void
  282. (*skip_spaces)( PS_Parser parser );
  283. void
  284. (*skip_PS_token)( PS_Parser parser );
  285. FT_Long
  286. (*to_int)( PS_Parser parser );
  287. FT_Fixed
  288. (*to_fixed)( PS_Parser parser,
  289. FT_Int power_ten );
  290. FT_Error
  291. (*to_bytes)( PS_Parser parser,
  292. FT_Byte* bytes,
  293. FT_Offset max_bytes,
  294. FT_Long* pnum_bytes,
  295. FT_Bool delimiters );
  296. FT_Int
  297. (*to_coord_array)( PS_Parser parser,
  298. FT_Int max_coords,
  299. FT_Short* coords );
  300. FT_Int
  301. (*to_fixed_array)( PS_Parser parser,
  302. FT_Int max_values,
  303. FT_Fixed* values,
  304. FT_Int power_ten );
  305. void
  306. (*to_token)( PS_Parser parser,
  307. T1_Token token );
  308. void
  309. (*to_token_array)( PS_Parser parser,
  310. T1_Token tokens,
  311. FT_UInt max_tokens,
  312. FT_Int* pnum_tokens );
  313. FT_Error
  314. (*load_field)( PS_Parser parser,
  315. const T1_Field field,
  316. void** objects,
  317. FT_UInt max_objects,
  318. FT_ULong* pflags );
  319. FT_Error
  320. (*load_field_table)( PS_Parser parser,
  321. const T1_Field field,
  322. void** objects,
  323. FT_UInt max_objects,
  324. FT_ULong* pflags );
  325. } PS_Parser_FuncsRec;
  326. /*************************************************************************/
  327. /* */
  328. /* <Struct> */
  329. /* PS_ParserRec */
  330. /* */
  331. /* <Description> */
  332. /* A PS_Parser is an object used to parse a Type 1 font very quickly. */
  333. /* */
  334. /* <Fields> */
  335. /* cursor :: The current position in the text. */
  336. /* */
  337. /* base :: Start of the processed text. */
  338. /* */
  339. /* limit :: End of the processed text. */
  340. /* */
  341. /* error :: The last error returned. */
  342. /* */
  343. /* memory :: The object used for memory operations (alloc/realloc). */
  344. /* */
  345. /* funcs :: A table of functions for the parser. */
  346. /* */
  347. typedef struct PS_ParserRec_
  348. {
  349. FT_Byte* cursor;
  350. FT_Byte* base;
  351. FT_Byte* limit;
  352. FT_Error error;
  353. FT_Memory memory;
  354. PS_Parser_FuncsRec funcs;
  355. } PS_ParserRec;
  356. /*************************************************************************/
  357. /*************************************************************************/
  358. /***** *****/
  359. /***** T1 BUILDER *****/
  360. /***** *****/
  361. /*************************************************************************/
  362. /*************************************************************************/
  363. typedef struct T1_BuilderRec_* T1_Builder;
  364. typedef FT_Error
  365. (*T1_Builder_Check_Points_Func)( T1_Builder builder,
  366. FT_Int count );
  367. typedef void
  368. (*T1_Builder_Add_Point_Func)( T1_Builder builder,
  369. FT_Pos x,
  370. FT_Pos y,
  371. FT_Byte flag );
  372. typedef FT_Error
  373. (*T1_Builder_Add_Point1_Func)( T1_Builder builder,
  374. FT_Pos x,
  375. FT_Pos y );
  376. typedef FT_Error
  377. (*T1_Builder_Add_Contour_Func)( T1_Builder builder );
  378. typedef FT_Error
  379. (*T1_Builder_Start_Point_Func)( T1_Builder builder,
  380. FT_Pos x,
  381. FT_Pos y );
  382. typedef void
  383. (*T1_Builder_Close_Contour_Func)( T1_Builder builder );
  384. typedef const struct T1_Builder_FuncsRec_* T1_Builder_Funcs;
  385. typedef struct T1_Builder_FuncsRec_
  386. {
  387. void
  388. (*init)( T1_Builder builder,
  389. FT_Face face,
  390. FT_Size size,
  391. FT_GlyphSlot slot,
  392. FT_Bool hinting );
  393. void
  394. (*done)( T1_Builder builder );
  395. T1_Builder_Check_Points_Func check_points;
  396. T1_Builder_Add_Point_Func add_point;
  397. T1_Builder_Add_Point1_Func add_point1;
  398. T1_Builder_Add_Contour_Func add_contour;
  399. T1_Builder_Start_Point_Func start_point;
  400. T1_Builder_Close_Contour_Func close_contour;
  401. } T1_Builder_FuncsRec;
  402. /* an enumeration type to handle charstring parsing states */
  403. typedef enum T1_ParseState_
  404. {
  405. T1_Parse_Start,
  406. T1_Parse_Have_Width,
  407. T1_Parse_Have_Moveto,
  408. T1_Parse_Have_Path
  409. } T1_ParseState;
  410. /*************************************************************************/
  411. /* */
  412. /* <Structure> */
  413. /* T1_BuilderRec */
  414. /* */
  415. /* <Description> */
  416. /* A structure used during glyph loading to store its outline. */
  417. /* */
  418. /* <Fields> */
  419. /* memory :: The current memory object. */
  420. /* */
  421. /* face :: The current face object. */
  422. /* */
  423. /* glyph :: The current glyph slot. */
  424. /* */
  425. /* loader :: XXX */
  426. /* */
  427. /* base :: The base glyph outline. */
  428. /* */
  429. /* current :: The current glyph outline. */
  430. /* */
  431. /* max_points :: maximum points in builder outline */
  432. /* */
  433. /* max_contours :: Maximum number of contours in builder outline. */
  434. /* */
  435. /* pos_x :: The horizontal translation (if composite glyph). */
  436. /* */
  437. /* pos_y :: The vertical translation (if composite glyph). */
  438. /* */
  439. /* left_bearing :: The left side bearing point. */
  440. /* */
  441. /* advance :: The horizontal advance vector. */
  442. /* */
  443. /* bbox :: Unused. */
  444. /* */
  445. /* parse_state :: An enumeration which controls the charstring */
  446. /* parsing state. */
  447. /* */
  448. /* load_points :: If this flag is not set, no points are loaded. */
  449. /* */
  450. /* no_recurse :: Set but not used. */
  451. /* */
  452. /* metrics_only :: A boolean indicating that we only want to compute */
  453. /* the metrics of a given glyph, not load all of its */
  454. /* points. */
  455. /* */
  456. /* funcs :: An array of function pointers for the builder. */
  457. /* */
  458. typedef struct T1_BuilderRec_
  459. {
  460. FT_Memory memory;
  461. FT_Face face;
  462. FT_GlyphSlot glyph;
  463. FT_GlyphLoader loader;
  464. FT_Outline* base;
  465. FT_Outline* current;
  466. FT_Pos pos_x;
  467. FT_Pos pos_y;
  468. FT_Vector left_bearing;
  469. FT_Vector advance;
  470. FT_BBox bbox; /* bounding box */
  471. T1_ParseState parse_state;
  472. FT_Bool load_points;
  473. FT_Bool no_recurse;
  474. FT_Bool metrics_only;
  475. void* hints_funcs; /* hinter-specific */
  476. void* hints_globals; /* hinter-specific */
  477. T1_Builder_FuncsRec funcs;
  478. } T1_BuilderRec;
  479. /*************************************************************************/
  480. /*************************************************************************/
  481. /***** *****/
  482. /***** T1 DECODER *****/
  483. /***** *****/
  484. /*************************************************************************/
  485. /*************************************************************************/
  486. #if 0
  487. /*************************************************************************/
  488. /* */
  489. /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
  490. /* calls during glyph loading. */
  491. /* */
  492. #define T1_MAX_SUBRS_CALLS 8
  493. /*************************************************************************/
  494. /* */
  495. /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
  496. /* minimum of 16 is required. */
  497. /* */
  498. #define T1_MAX_CHARSTRINGS_OPERANDS 32
  499. #endif /* 0 */
  500. typedef struct T1_Decoder_ZoneRec_
  501. {
  502. FT_Byte* cursor;
  503. FT_Byte* base;
  504. FT_Byte* limit;
  505. } T1_Decoder_ZoneRec, *T1_Decoder_Zone;
  506. typedef struct T1_DecoderRec_* T1_Decoder;
  507. typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs;
  508. typedef FT_Error
  509. (*T1_Decoder_Callback)( T1_Decoder decoder,
  510. FT_UInt glyph_index );
  511. typedef struct T1_Decoder_FuncsRec_
  512. {
  513. FT_Error
  514. (*init)( T1_Decoder decoder,
  515. FT_Face face,
  516. FT_Size size,
  517. FT_GlyphSlot slot,
  518. FT_Byte** glyph_names,
  519. PS_Blend blend,
  520. FT_Bool hinting,
  521. FT_Render_Mode hint_mode,
  522. T1_Decoder_Callback callback );
  523. void
  524. (*done)( T1_Decoder decoder );
  525. FT_Error
  526. (*parse_charstrings)( T1_Decoder decoder,
  527. FT_Byte* base,
  528. FT_UInt len );
  529. } T1_Decoder_FuncsRec;
  530. typedef struct T1_DecoderRec_
  531. {
  532. T1_BuilderRec builder;
  533. FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS];
  534. FT_Long* top;
  535. T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1];
  536. T1_Decoder_Zone zone;
  537. FT_Service_PsCMaps psnames; /* for seac */
  538. FT_UInt num_glyphs;
  539. FT_Byte** glyph_names;
  540. FT_Int lenIV; /* internal for sub routine calls */
  541. FT_UInt num_subrs;
  542. FT_Byte** subrs;
  543. FT_PtrDist* subrs_len; /* array of subrs length (optional) */
  544. FT_Matrix font_matrix;
  545. FT_Vector font_offset;
  546. FT_Int flex_state;
  547. FT_Int num_flex_vectors;
  548. FT_Vector flex_vectors[7];
  549. PS_Blend blend; /* for multiple master support */
  550. FT_Render_Mode hint_mode;
  551. T1_Decoder_Callback parse_callback;
  552. T1_Decoder_FuncsRec funcs;
  553. FT_Long* buildchar;
  554. FT_UInt len_buildchar;
  555. FT_Bool seac;
  556. } T1_DecoderRec;
  557. /*************************************************************************/
  558. /*************************************************************************/
  559. /***** *****/
  560. /***** AFM PARSER *****/
  561. /***** *****/
  562. /*************************************************************************/
  563. /*************************************************************************/
  564. typedef struct AFM_ParserRec_* AFM_Parser;
  565. typedef struct AFM_Parser_FuncsRec_
  566. {
  567. FT_Error
  568. (*init)( AFM_Parser parser,
  569. FT_Memory memory,
  570. FT_Byte* base,
  571. FT_Byte* limit );
  572. void
  573. (*done)( AFM_Parser parser );
  574. FT_Error
  575. (*parse)( AFM_Parser parser );
  576. } AFM_Parser_FuncsRec;
  577. typedef struct AFM_StreamRec_* AFM_Stream;
  578. /*************************************************************************/
  579. /* */
  580. /* <Struct> */
  581. /* AFM_ParserRec */
  582. /* */
  583. /* <Description> */
  584. /* An AFM_Parser is a parser for the AFM files. */
  585. /* */
  586. /* <Fields> */
  587. /* memory :: The object used for memory operations (alloc and */
  588. /* realloc). */
  589. /* */
  590. /* stream :: This is an opaque object. */
  591. /* */
  592. /* FontInfo :: The result will be stored here. */
  593. /* */
  594. /* get_index :: A user provided function to get a glyph index by its */
  595. /* name. */
  596. /* */
  597. typedef struct AFM_ParserRec_
  598. {
  599. FT_Memory memory;
  600. AFM_Stream stream;
  601. AFM_FontInfo FontInfo;
  602. FT_Int
  603. (*get_index)( const char* name,
  604. FT_Offset len,
  605. void* user_data );
  606. void* user_data;
  607. } AFM_ParserRec;
  608. /*************************************************************************/
  609. /*************************************************************************/
  610. /***** *****/
  611. /***** TYPE1 CHARMAPS *****/
  612. /***** *****/
  613. /*************************************************************************/
  614. /*************************************************************************/
  615. typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes;
  616. typedef struct T1_CMap_ClassesRec_
  617. {
  618. FT_CMap_Class standard;
  619. FT_CMap_Class expert;
  620. FT_CMap_Class custom;
  621. FT_CMap_Class unicode;
  622. } T1_CMap_ClassesRec;
  623. /*************************************************************************/
  624. /*************************************************************************/
  625. /***** *****/
  626. /***** PSAux Module Interface *****/
  627. /***** *****/
  628. /*************************************************************************/
  629. /*************************************************************************/
  630. typedef struct PSAux_ServiceRec_
  631. {
  632. /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */
  633. const PS_Table_FuncsRec* ps_table_funcs;
  634. const PS_Parser_FuncsRec* ps_parser_funcs;
  635. const T1_Builder_FuncsRec* t1_builder_funcs;
  636. const T1_Decoder_FuncsRec* t1_decoder_funcs;
  637. void
  638. (*t1_decrypt)( FT_Byte* buffer,
  639. FT_Offset length,
  640. FT_UShort seed );
  641. T1_CMap_Classes t1_cmap_classes;
  642. /* fields after this comment line were added after version 2.1.10 */
  643. const AFM_Parser_FuncsRec* afm_parser_funcs;
  644. } PSAux_ServiceRec, *PSAux_Service;
  645. /* backwards-compatible type definition */
  646. typedef PSAux_ServiceRec PSAux_Interface;
  647. /*************************************************************************/
  648. /*************************************************************************/
  649. /***** *****/
  650. /***** Some convenience functions *****/
  651. /***** *****/
  652. /*************************************************************************/
  653. /*************************************************************************/
  654. #define IS_PS_NEWLINE( ch ) \
  655. ( (ch) == '\r' || \
  656. (ch) == '\n' )
  657. #define IS_PS_SPACE( ch ) \
  658. ( (ch) == ' ' || \
  659. IS_PS_NEWLINE( ch ) || \
  660. (ch) == '\t' || \
  661. (ch) == '\f' || \
  662. (ch) == '\0' )
  663. #define IS_PS_SPECIAL( ch ) \
  664. ( (ch) == '/' || \
  665. (ch) == '(' || (ch) == ')' || \
  666. (ch) == '<' || (ch) == '>' || \
  667. (ch) == '[' || (ch) == ']' || \
  668. (ch) == '{' || (ch) == '}' || \
  669. (ch) == '%' )
  670. #define IS_PS_DELIM( ch ) \
  671. ( IS_PS_SPACE( ch ) || \
  672. IS_PS_SPECIAL( ch ) )
  673. #define IS_PS_DIGIT( ch ) \
  674. ( (ch) >= '0' && (ch) <= '9' )
  675. #define IS_PS_XDIGIT( ch ) \
  676. ( IS_PS_DIGIT( ch ) || \
  677. ( (ch) >= 'A' && (ch) <= 'F' ) || \
  678. ( (ch) >= 'a' && (ch) <= 'f' ) )
  679. #define IS_PS_BASE85( ch ) \
  680. ( (ch) >= '!' && (ch) <= 'u' )
  681. #define IS_PS_TOKEN( cur, limit, token ) \
  682. ( (char)(cur)[0] == (token)[0] && \
  683. ( (cur) + sizeof ( (token) ) == (limit) || \
  684. ( (cur) + sizeof( (token) ) < (limit) && \
  685. IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \
  686. ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 )
  687. FT_END_HEADER
  688. #endif /* __PSAUX_H__ */
  689. /* END */