t1tables.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /***************************************************************************/
  2. /* */
  3. /* t1tables.h */
  4. /* */
  5. /* Basic Type 1/Type 2 tables definitions and interface (specification */
  6. /* only). */
  7. /* */
  8. /* Copyright 1996-2004, 2006, 2008, 2009, 2011 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 __T1TABLES_H__
  19. #define __T1TABLES_H__
  20. #include <ft2build.h>
  21. #include FT_FREETYPE_H
  22. #ifdef FREETYPE_H
  23. #error "freetype.h of FreeType 1 has been loaded!"
  24. #error "Please fix the directory search order for header files"
  25. #error "so that freetype.h of FreeType 2 is found first."
  26. #endif
  27. FT_BEGIN_HEADER
  28. /*************************************************************************/
  29. /* */
  30. /* <Section> */
  31. /* type1_tables */
  32. /* */
  33. /* <Title> */
  34. /* Type 1 Tables */
  35. /* */
  36. /* <Abstract> */
  37. /* Type~1 (PostScript) specific font tables. */
  38. /* */
  39. /* <Description> */
  40. /* This section contains the definition of Type 1-specific tables, */
  41. /* including structures related to other PostScript font formats. */
  42. /* */
  43. /*************************************************************************/
  44. /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
  45. /* structures in order to support Multiple Master fonts. */
  46. /*************************************************************************/
  47. /* */
  48. /* <Struct> */
  49. /* PS_FontInfoRec */
  50. /* */
  51. /* <Description> */
  52. /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */
  53. /* Note that for Multiple Master fonts, each instance has its own */
  54. /* FontInfo dictionary. */
  55. /* */
  56. typedef struct PS_FontInfoRec_
  57. {
  58. FT_String* version;
  59. FT_String* notice;
  60. FT_String* full_name;
  61. FT_String* family_name;
  62. FT_String* weight;
  63. FT_Long italic_angle;
  64. FT_Bool is_fixed_pitch;
  65. FT_Short underline_position;
  66. FT_UShort underline_thickness;
  67. } PS_FontInfoRec;
  68. /*************************************************************************/
  69. /* */
  70. /* <Struct> */
  71. /* PS_FontInfo */
  72. /* */
  73. /* <Description> */
  74. /* A handle to a @PS_FontInfoRec structure. */
  75. /* */
  76. typedef struct PS_FontInfoRec_* PS_FontInfo;
  77. /*************************************************************************/
  78. /* */
  79. /* <Struct> */
  80. /* T1_FontInfo */
  81. /* */
  82. /* <Description> */
  83. /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */
  84. /* kept to maintain source compatibility between various versions of */
  85. /* FreeType. */
  86. /* */
  87. typedef PS_FontInfoRec T1_FontInfo;
  88. /*************************************************************************/
  89. /* */
  90. /* <Struct> */
  91. /* PS_PrivateRec */
  92. /* */
  93. /* <Description> */
  94. /* A structure used to model a Type~1 or Type~2 private dictionary. */
  95. /* Note that for Multiple Master fonts, each instance has its own */
  96. /* Private dictionary. */
  97. /* */
  98. typedef struct PS_PrivateRec_
  99. {
  100. FT_Int unique_id;
  101. FT_Int lenIV;
  102. FT_Byte num_blue_values;
  103. FT_Byte num_other_blues;
  104. FT_Byte num_family_blues;
  105. FT_Byte num_family_other_blues;
  106. FT_Short blue_values[14];
  107. FT_Short other_blues[10];
  108. FT_Short family_blues [14];
  109. FT_Short family_other_blues[10];
  110. FT_Fixed blue_scale;
  111. FT_Int blue_shift;
  112. FT_Int blue_fuzz;
  113. FT_UShort standard_width[1];
  114. FT_UShort standard_height[1];
  115. FT_Byte num_snap_widths;
  116. FT_Byte num_snap_heights;
  117. FT_Bool force_bold;
  118. FT_Bool round_stem_up;
  119. FT_Short snap_widths [13]; /* including std width */
  120. FT_Short snap_heights[13]; /* including std height */
  121. FT_Fixed expansion_factor;
  122. FT_Long language_group;
  123. FT_Long password;
  124. FT_Short min_feature[2];
  125. } PS_PrivateRec;
  126. /*************************************************************************/
  127. /* */
  128. /* <Struct> */
  129. /* PS_Private */
  130. /* */
  131. /* <Description> */
  132. /* A handle to a @PS_PrivateRec structure. */
  133. /* */
  134. typedef struct PS_PrivateRec_* PS_Private;
  135. /*************************************************************************/
  136. /* */
  137. /* <Struct> */
  138. /* T1_Private */
  139. /* */
  140. /* <Description> */
  141. /* This type is equivalent to @PS_PrivateRec. It is deprecated but */
  142. /* kept to maintain source compatibility between various versions of */
  143. /* FreeType. */
  144. /* */
  145. typedef PS_PrivateRec T1_Private;
  146. /*************************************************************************/
  147. /* */
  148. /* <Enum> */
  149. /* T1_Blend_Flags */
  150. /* */
  151. /* <Description> */
  152. /* A set of flags used to indicate which fields are present in a */
  153. /* given blend dictionary (font info or private). Used to support */
  154. /* Multiple Masters fonts. */
  155. /* */
  156. typedef enum T1_Blend_Flags_
  157. {
  158. /*# required fields in a FontInfo blend dictionary */
  159. T1_BLEND_UNDERLINE_POSITION = 0,
  160. T1_BLEND_UNDERLINE_THICKNESS,
  161. T1_BLEND_ITALIC_ANGLE,
  162. /*# required fields in a Private blend dictionary */
  163. T1_BLEND_BLUE_VALUES,
  164. T1_BLEND_OTHER_BLUES,
  165. T1_BLEND_STANDARD_WIDTH,
  166. T1_BLEND_STANDARD_HEIGHT,
  167. T1_BLEND_STEM_SNAP_WIDTHS,
  168. T1_BLEND_STEM_SNAP_HEIGHTS,
  169. T1_BLEND_BLUE_SCALE,
  170. T1_BLEND_BLUE_SHIFT,
  171. T1_BLEND_FAMILY_BLUES,
  172. T1_BLEND_FAMILY_OTHER_BLUES,
  173. T1_BLEND_FORCE_BOLD,
  174. /*# never remove */
  175. T1_BLEND_MAX
  176. } T1_Blend_Flags;
  177. /* */
  178. /*# backwards compatible definitions */
  179. #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
  180. #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
  181. #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
  182. #define t1_blend_blue_values T1_BLEND_BLUE_VALUES
  183. #define t1_blend_other_blues T1_BLEND_OTHER_BLUES
  184. #define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
  185. #define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
  186. #define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
  187. #define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
  188. #define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
  189. #define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
  190. #define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
  191. #define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
  192. #define t1_blend_force_bold T1_BLEND_FORCE_BOLD
  193. #define t1_blend_max T1_BLEND_MAX
  194. /* maximum number of Multiple Masters designs, as defined in the spec */
  195. #define T1_MAX_MM_DESIGNS 16
  196. /* maximum number of Multiple Masters axes, as defined in the spec */
  197. #define T1_MAX_MM_AXIS 4
  198. /* maximum number of elements in a design map */
  199. #define T1_MAX_MM_MAP_POINTS 20
  200. /* this structure is used to store the BlendDesignMap entry for an axis */
  201. typedef struct PS_DesignMap_
  202. {
  203. FT_Byte num_points;
  204. FT_Long* design_points;
  205. FT_Fixed* blend_points;
  206. } PS_DesignMapRec, *PS_DesignMap;
  207. /* backwards-compatible definition */
  208. typedef PS_DesignMapRec T1_DesignMap;
  209. typedef struct PS_BlendRec_
  210. {
  211. FT_UInt num_designs;
  212. FT_UInt num_axis;
  213. FT_String* axis_names[T1_MAX_MM_AXIS];
  214. FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
  215. PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
  216. FT_Fixed* weight_vector;
  217. FT_Fixed* default_weight_vector;
  218. PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
  219. PS_Private privates [T1_MAX_MM_DESIGNS + 1];
  220. FT_ULong blend_bitflags;
  221. FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
  222. /* since 2.3.0 */
  223. /* undocumented, optional: the default design instance; */
  224. /* corresponds to default_weight_vector -- */
  225. /* num_default_design_vector == 0 means it is not present */
  226. /* in the font and associated metrics files */
  227. FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
  228. FT_UInt num_default_design_vector;
  229. } PS_BlendRec, *PS_Blend;
  230. /* backwards-compatible definition */
  231. typedef PS_BlendRec T1_Blend;
  232. /*************************************************************************/
  233. /* */
  234. /* <Struct> */
  235. /* CID_FaceDictRec */
  236. /* */
  237. /* <Description> */
  238. /* A structure used to represent data in a CID top-level dictionary. */
  239. /* */
  240. typedef struct CID_FaceDictRec_
  241. {
  242. PS_PrivateRec private_dict;
  243. FT_UInt len_buildchar;
  244. FT_Fixed forcebold_threshold;
  245. FT_Pos stroke_width;
  246. FT_Fixed expansion_factor;
  247. FT_Byte paint_type;
  248. FT_Byte font_type;
  249. FT_Matrix font_matrix;
  250. FT_Vector font_offset;
  251. FT_UInt num_subrs;
  252. FT_ULong subrmap_offset;
  253. FT_Int sd_bytes;
  254. } CID_FaceDictRec;
  255. /*************************************************************************/
  256. /* */
  257. /* <Struct> */
  258. /* CID_FaceDict */
  259. /* */
  260. /* <Description> */
  261. /* A handle to a @CID_FaceDictRec structure. */
  262. /* */
  263. typedef struct CID_FaceDictRec_* CID_FaceDict;
  264. /* */
  265. /* backwards-compatible definition */
  266. typedef CID_FaceDictRec CID_FontDict;
  267. /*************************************************************************/
  268. /* */
  269. /* <Struct> */
  270. /* CID_FaceInfoRec */
  271. /* */
  272. /* <Description> */
  273. /* A structure used to represent CID Face information. */
  274. /* */
  275. typedef struct CID_FaceInfoRec_
  276. {
  277. FT_String* cid_font_name;
  278. FT_Fixed cid_version;
  279. FT_Int cid_font_type;
  280. FT_String* registry;
  281. FT_String* ordering;
  282. FT_Int supplement;
  283. PS_FontInfoRec font_info;
  284. FT_BBox font_bbox;
  285. FT_ULong uid_base;
  286. FT_Int num_xuid;
  287. FT_ULong xuid[16];
  288. FT_ULong cidmap_offset;
  289. FT_Int fd_bytes;
  290. FT_Int gd_bytes;
  291. FT_ULong cid_count;
  292. FT_Int num_dicts;
  293. CID_FaceDict font_dicts;
  294. FT_ULong data_offset;
  295. } CID_FaceInfoRec;
  296. /*************************************************************************/
  297. /* */
  298. /* <Struct> */
  299. /* CID_FaceInfo */
  300. /* */
  301. /* <Description> */
  302. /* A handle to a @CID_FaceInfoRec structure. */
  303. /* */
  304. typedef struct CID_FaceInfoRec_* CID_FaceInfo;
  305. /*************************************************************************/
  306. /* */
  307. /* <Struct> */
  308. /* CID_Info */
  309. /* */
  310. /* <Description> */
  311. /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */
  312. /* kept to maintain source compatibility between various versions of */
  313. /* FreeType. */
  314. /* */
  315. typedef CID_FaceInfoRec CID_Info;
  316. /************************************************************************
  317. *
  318. * @function:
  319. * FT_Has_PS_Glyph_Names
  320. *
  321. * @description:
  322. * Return true if a given face provides reliable PostScript glyph
  323. * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
  324. * except that certain fonts (mostly TrueType) contain incorrect
  325. * glyph name tables.
  326. *
  327. * When this function returns true, the caller is sure that the glyph
  328. * names returned by @FT_Get_Glyph_Name are reliable.
  329. *
  330. * @input:
  331. * face ::
  332. * face handle
  333. *
  334. * @return:
  335. * Boolean. True if glyph names are reliable.
  336. *
  337. */
  338. FT_EXPORT( FT_Int )
  339. FT_Has_PS_Glyph_Names( FT_Face face );
  340. /************************************************************************
  341. *
  342. * @function:
  343. * FT_Get_PS_Font_Info
  344. *
  345. * @description:
  346. * Retrieve the @PS_FontInfoRec structure corresponding to a given
  347. * PostScript font.
  348. *
  349. * @input:
  350. * face ::
  351. * PostScript face handle.
  352. *
  353. * @output:
  354. * afont_info ::
  355. * Output font info structure pointer.
  356. *
  357. * @return:
  358. * FreeType error code. 0~means success.
  359. *
  360. * @note:
  361. * The string pointers within the font info structure are owned by
  362. * the face and don't need to be freed by the caller.
  363. *
  364. * If the font's format is not PostScript-based, this function will
  365. * return the `FT_Err_Invalid_Argument' error code.
  366. *
  367. */
  368. FT_EXPORT( FT_Error )
  369. FT_Get_PS_Font_Info( FT_Face face,
  370. PS_FontInfo afont_info );
  371. /************************************************************************
  372. *
  373. * @function:
  374. * FT_Get_PS_Font_Private
  375. *
  376. * @description:
  377. * Retrieve the @PS_PrivateRec structure corresponding to a given
  378. * PostScript font.
  379. *
  380. * @input:
  381. * face ::
  382. * PostScript face handle.
  383. *
  384. * @output:
  385. * afont_private ::
  386. * Output private dictionary structure pointer.
  387. *
  388. * @return:
  389. * FreeType error code. 0~means success.
  390. *
  391. * @note:
  392. * The string pointers within the @PS_PrivateRec structure are owned by
  393. * the face and don't need to be freed by the caller.
  394. *
  395. * If the font's format is not PostScript-based, this function returns
  396. * the `FT_Err_Invalid_Argument' error code.
  397. *
  398. */
  399. FT_EXPORT( FT_Error )
  400. FT_Get_PS_Font_Private( FT_Face face,
  401. PS_Private afont_private );
  402. /*************************************************************************/
  403. /* */
  404. /* <Enum> */
  405. /* T1_EncodingType */
  406. /* */
  407. /* <Description> */
  408. /* An enumeration describing the `Encoding' entry in a Type 1 */
  409. /* dictionary. */
  410. /* */
  411. typedef enum T1_EncodingType_
  412. {
  413. T1_ENCODING_TYPE_NONE = 0,
  414. T1_ENCODING_TYPE_ARRAY,
  415. T1_ENCODING_TYPE_STANDARD,
  416. T1_ENCODING_TYPE_ISOLATIN1,
  417. T1_ENCODING_TYPE_EXPERT
  418. } T1_EncodingType;
  419. /*************************************************************************/
  420. /* */
  421. /* <Enum> */
  422. /* PS_Dict_Keys */
  423. /* */
  424. /* <Description> */
  425. /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */
  426. /* the Type~1 dictionary entry to retrieve. */
  427. /* */
  428. typedef enum PS_Dict_Keys_
  429. {
  430. /* conventionally in the font dictionary */
  431. PS_DICT_FONT_TYPE, /* FT_Byte */
  432. PS_DICT_FONT_MATRIX, /* FT_Fixed */
  433. PS_DICT_FONT_BBOX, /* FT_Fixed */
  434. PS_DICT_PAINT_TYPE, /* FT_Byte */
  435. PS_DICT_FONT_NAME, /* FT_String* */
  436. PS_DICT_UNIQUE_ID, /* FT_Int */
  437. PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
  438. PS_DICT_CHAR_STRING_KEY, /* FT_String* */
  439. PS_DICT_CHAR_STRING, /* FT_String* */
  440. PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
  441. PS_DICT_ENCODING_ENTRY, /* FT_String* */
  442. /* conventionally in the font Private dictionary */
  443. PS_DICT_NUM_SUBRS, /* FT_Int */
  444. PS_DICT_SUBR, /* FT_String* */
  445. PS_DICT_STD_HW, /* FT_UShort */
  446. PS_DICT_STD_VW, /* FT_UShort */
  447. PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
  448. PS_DICT_BLUE_VALUE, /* FT_Short */
  449. PS_DICT_BLUE_FUZZ, /* FT_Int */
  450. PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
  451. PS_DICT_OTHER_BLUE, /* FT_Short */
  452. PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
  453. PS_DICT_FAMILY_BLUE, /* FT_Short */
  454. PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
  455. PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
  456. PS_DICT_BLUE_SCALE, /* FT_Fixed */
  457. PS_DICT_BLUE_SHIFT, /* FT_Int */
  458. PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
  459. PS_DICT_STEM_SNAP_H, /* FT_Short */
  460. PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
  461. PS_DICT_STEM_SNAP_V, /* FT_Short */
  462. PS_DICT_FORCE_BOLD, /* FT_Bool */
  463. PS_DICT_RND_STEM_UP, /* FT_Bool */
  464. PS_DICT_MIN_FEATURE, /* FT_Short */
  465. PS_DICT_LEN_IV, /* FT_Int */
  466. PS_DICT_PASSWORD, /* FT_Long */
  467. PS_DICT_LANGUAGE_GROUP, /* FT_Long */
  468. /* conventionally in the font FontInfo dictionary */
  469. PS_DICT_VERSION, /* FT_String* */
  470. PS_DICT_NOTICE, /* FT_String* */
  471. PS_DICT_FULL_NAME, /* FT_String* */
  472. PS_DICT_FAMILY_NAME, /* FT_String* */
  473. PS_DICT_WEIGHT, /* FT_String* */
  474. PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
  475. PS_DICT_UNDERLINE_POSITION, /* FT_Short */
  476. PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
  477. PS_DICT_FS_TYPE, /* FT_UShort */
  478. PS_DICT_ITALIC_ANGLE, /* FT_Long */
  479. PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
  480. } PS_Dict_Keys;
  481. /************************************************************************
  482. *
  483. * @function:
  484. * FT_Get_PS_Font_Value
  485. *
  486. * @description:
  487. * Retrieve the value for the supplied key from a PostScript font.
  488. *
  489. * @input:
  490. * face ::
  491. * PostScript face handle.
  492. *
  493. * key ::
  494. * An enumeration value representing the dictionary key to retrieve.
  495. *
  496. * idx ::
  497. * For array values, this specifies the index to be returned.
  498. *
  499. * value ::
  500. * A pointer to memory into which to write the value.
  501. *
  502. * valen_len ::
  503. * The size, in bytes, of the memory supplied for the value.
  504. *
  505. * @output:
  506. * value ::
  507. * The value matching the above key, if it exists.
  508. *
  509. * @return:
  510. * The amount of memory (in bytes) required to hold the requested
  511. * value (if it exists, -1 otherwise).
  512. *
  513. * @note:
  514. * The values returned are not pointers into the internal structures of
  515. * the face, but are `fresh' copies, so that the memory containing them
  516. * belongs to the calling application. This also enforces the
  517. * `read-only' nature of these values, i.e., this function cannot be
  518. * used to manipulate the face.
  519. *
  520. * `value' is a void pointer because the values returned can be of
  521. * various types.
  522. *
  523. * If either `value' is NULL or `value_len' is too small, just the
  524. * required memory size for the requested entry is returned.
  525. *
  526. * The `idx' parameter is used, not only to retrieve elements of, for
  527. * example, the FontMatrix or FontBBox, but also to retrieve name keys
  528. * from the CharStrings dictionary, and the charstrings themselves. It
  529. * is ignored for atomic values.
  530. *
  531. * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To
  532. * get the value as in the font stream, you need to divide by
  533. * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale).
  534. *
  535. * IMPORTANT: Only key/value pairs read by the FreeType interpreter can
  536. * be retrieved. So, for example, PostScript procedures such as NP,
  537. * ND, and RD are not available. Arbitrary keys are, obviously, not be
  538. * available either.
  539. *
  540. * If the font's format is not PostScript-based, this function returns
  541. * the `FT_Err_Invalid_Argument' error code.
  542. *
  543. */
  544. FT_EXPORT( FT_Long )
  545. FT_Get_PS_Font_Value( FT_Face face,
  546. PS_Dict_Keys key,
  547. FT_UInt idx,
  548. void *value,
  549. FT_Long value_len );
  550. /* */
  551. FT_END_HEADER
  552. #endif /* __T1TABLES_H__ */
  553. /* END */