/src/freetype/include/freetype/internal/psaux.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 873 lines · 440 code · 188 blank · 245 comment · 44 complexity · 552f2a91c920ed475a51e11ffdbca213 MD5 · raw file

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