fttypes.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /***************************************************************************/
  2. /* */
  3. /* fttypes.h */
  4. /* */
  5. /* FreeType simple types definitions (specification only). */
  6. /* */
  7. /* Copyright 1996-2002, 2004, 2006-2009, 2012, 2013 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #ifndef __FTTYPES_H__
  18. #define __FTTYPES_H__
  19. #include <ft2build.h>
  20. #include FT_CONFIG_CONFIG_H
  21. #include FT_SYSTEM_H
  22. #include FT_IMAGE_H
  23. #include <stddef.h>
  24. FT_BEGIN_HEADER
  25. /*************************************************************************/
  26. /* */
  27. /* <Section> */
  28. /* basic_types */
  29. /* */
  30. /* <Title> */
  31. /* Basic Data Types */
  32. /* */
  33. /* <Abstract> */
  34. /* The basic data types defined by the library. */
  35. /* */
  36. /* <Description> */
  37. /* This section contains the basic data types defined by FreeType~2, */
  38. /* ranging from simple scalar types to bitmap descriptors. More */
  39. /* font-specific structures are defined in a different section. */
  40. /* */
  41. /* <Order> */
  42. /* FT_Byte */
  43. /* FT_Bytes */
  44. /* FT_Char */
  45. /* FT_Int */
  46. /* FT_UInt */
  47. /* FT_Int16 */
  48. /* FT_UInt16 */
  49. /* FT_Int32 */
  50. /* FT_UInt32 */
  51. /* FT_Short */
  52. /* FT_UShort */
  53. /* FT_Long */
  54. /* FT_ULong */
  55. /* FT_Bool */
  56. /* FT_Offset */
  57. /* FT_PtrDist */
  58. /* FT_String */
  59. /* FT_Tag */
  60. /* FT_Error */
  61. /* FT_Fixed */
  62. /* FT_Pointer */
  63. /* FT_Pos */
  64. /* FT_Vector */
  65. /* FT_BBox */
  66. /* FT_Matrix */
  67. /* FT_FWord */
  68. /* FT_UFWord */
  69. /* FT_F2Dot14 */
  70. /* FT_UnitVector */
  71. /* FT_F26Dot6 */
  72. /* */
  73. /* */
  74. /* FT_Generic */
  75. /* FT_Generic_Finalizer */
  76. /* */
  77. /* FT_Bitmap */
  78. /* FT_Pixel_Mode */
  79. /* FT_Palette_Mode */
  80. /* FT_Glyph_Format */
  81. /* FT_IMAGE_TAG */
  82. /* */
  83. /*************************************************************************/
  84. /*************************************************************************/
  85. /* */
  86. /* <Type> */
  87. /* FT_Bool */
  88. /* */
  89. /* <Description> */
  90. /* A typedef of unsigned char, used for simple booleans. As usual, */
  91. /* values 1 and~0 represent true and false, respectively. */
  92. /* */
  93. typedef unsigned char FT_Bool;
  94. /*************************************************************************/
  95. /* */
  96. /* <Type> */
  97. /* FT_FWord */
  98. /* */
  99. /* <Description> */
  100. /* A signed 16-bit integer used to store a distance in original font */
  101. /* units. */
  102. /* */
  103. typedef signed short FT_FWord; /* distance in FUnits */
  104. /*************************************************************************/
  105. /* */
  106. /* <Type> */
  107. /* FT_UFWord */
  108. /* */
  109. /* <Description> */
  110. /* An unsigned 16-bit integer used to store a distance in original */
  111. /* font units. */
  112. /* */
  113. typedef unsigned short FT_UFWord; /* unsigned distance */
  114. /*************************************************************************/
  115. /* */
  116. /* <Type> */
  117. /* FT_Char */
  118. /* */
  119. /* <Description> */
  120. /* A simple typedef for the _signed_ char type. */
  121. /* */
  122. typedef signed char FT_Char;
  123. /*************************************************************************/
  124. /* */
  125. /* <Type> */
  126. /* FT_Byte */
  127. /* */
  128. /* <Description> */
  129. /* A simple typedef for the _unsigned_ char type. */
  130. /* */
  131. typedef unsigned char FT_Byte;
  132. /*************************************************************************/
  133. /* */
  134. /* <Type> */
  135. /* FT_Bytes */
  136. /* */
  137. /* <Description> */
  138. /* A typedef for constant memory areas. */
  139. /* */
  140. typedef const FT_Byte* FT_Bytes;
  141. /*************************************************************************/
  142. /* */
  143. /* <Type> */
  144. /* FT_Tag */
  145. /* */
  146. /* <Description> */
  147. /* A typedef for 32-bit tags (as used in the SFNT format). */
  148. /* */
  149. typedef FT_UInt32 FT_Tag;
  150. /*************************************************************************/
  151. /* */
  152. /* <Type> */
  153. /* FT_String */
  154. /* */
  155. /* <Description> */
  156. /* A simple typedef for the char type, usually used for strings. */
  157. /* */
  158. typedef char FT_String;
  159. /*************************************************************************/
  160. /* */
  161. /* <Type> */
  162. /* FT_Short */
  163. /* */
  164. /* <Description> */
  165. /* A typedef for signed short. */
  166. /* */
  167. typedef signed short FT_Short;
  168. /*************************************************************************/
  169. /* */
  170. /* <Type> */
  171. /* FT_UShort */
  172. /* */
  173. /* <Description> */
  174. /* A typedef for unsigned short. */
  175. /* */
  176. typedef unsigned short FT_UShort;
  177. /*************************************************************************/
  178. /* */
  179. /* <Type> */
  180. /* FT_Int */
  181. /* */
  182. /* <Description> */
  183. /* A typedef for the int type. */
  184. /* */
  185. typedef signed int FT_Int;
  186. /*************************************************************************/
  187. /* */
  188. /* <Type> */
  189. /* FT_UInt */
  190. /* */
  191. /* <Description> */
  192. /* A typedef for the unsigned int type. */
  193. /* */
  194. typedef unsigned int FT_UInt;
  195. /*************************************************************************/
  196. /* */
  197. /* <Type> */
  198. /* FT_Long */
  199. /* */
  200. /* <Description> */
  201. /* A typedef for signed long. */
  202. /* */
  203. typedef signed long FT_Long;
  204. /*************************************************************************/
  205. /* */
  206. /* <Type> */
  207. /* FT_ULong */
  208. /* */
  209. /* <Description> */
  210. /* A typedef for unsigned long. */
  211. /* */
  212. typedef unsigned long FT_ULong;
  213. /*************************************************************************/
  214. /* */
  215. /* <Type> */
  216. /* FT_F2Dot14 */
  217. /* */
  218. /* <Description> */
  219. /* A signed 2.14 fixed-point type used for unit vectors. */
  220. /* */
  221. typedef signed short FT_F2Dot14;
  222. /*************************************************************************/
  223. /* */
  224. /* <Type> */
  225. /* FT_F26Dot6 */
  226. /* */
  227. /* <Description> */
  228. /* A signed 26.6 fixed-point type used for vectorial pixel */
  229. /* coordinates. */
  230. /* */
  231. typedef signed long FT_F26Dot6;
  232. /*************************************************************************/
  233. /* */
  234. /* <Type> */
  235. /* FT_Fixed */
  236. /* */
  237. /* <Description> */
  238. /* This type is used to store 16.16 fixed-point values, like scaling */
  239. /* values or matrix coefficients. */
  240. /* */
  241. typedef signed long FT_Fixed;
  242. /*************************************************************************/
  243. /* */
  244. /* <Type> */
  245. /* FT_Error */
  246. /* */
  247. /* <Description> */
  248. /* The FreeType error code type. A value of~0 is always interpreted */
  249. /* as a successful operation. */
  250. /* */
  251. typedef int FT_Error;
  252. /*************************************************************************/
  253. /* */
  254. /* <Type> */
  255. /* FT_Pointer */
  256. /* */
  257. /* <Description> */
  258. /* A simple typedef for a typeless pointer. */
  259. /* */
  260. typedef void* FT_Pointer;
  261. /*************************************************************************/
  262. /* */
  263. /* <Type> */
  264. /* FT_Offset */
  265. /* */
  266. /* <Description> */
  267. /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */
  268. /* _unsigned_ integer type used to express a file size or position, */
  269. /* or a memory block size. */
  270. /* */
  271. typedef size_t FT_Offset;
  272. /*************************************************************************/
  273. /* */
  274. /* <Type> */
  275. /* FT_PtrDist */
  276. /* */
  277. /* <Description> */
  278. /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */
  279. /* largest _signed_ integer type used to express the distance */
  280. /* between two pointers. */
  281. /* */
  282. typedef ft_ptrdiff_t FT_PtrDist;
  283. /*************************************************************************/
  284. /* */
  285. /* <Struct> */
  286. /* FT_UnitVector */
  287. /* */
  288. /* <Description> */
  289. /* A simple structure used to store a 2D vector unit vector. Uses */
  290. /* FT_F2Dot14 types. */
  291. /* */
  292. /* <Fields> */
  293. /* x :: Horizontal coordinate. */
  294. /* */
  295. /* y :: Vertical coordinate. */
  296. /* */
  297. typedef struct FT_UnitVector_
  298. {
  299. FT_F2Dot14 x;
  300. FT_F2Dot14 y;
  301. } FT_UnitVector;
  302. /*************************************************************************/
  303. /* */
  304. /* <Struct> */
  305. /* FT_Matrix */
  306. /* */
  307. /* <Description> */
  308. /* A simple structure used to store a 2x2 matrix. Coefficients are */
  309. /* in 16.16 fixed-point format. The computation performed is: */
  310. /* */
  311. /* { */
  312. /* x' = x*xx + y*xy */
  313. /* y' = x*yx + y*yy */
  314. /* } */
  315. /* */
  316. /* <Fields> */
  317. /* xx :: Matrix coefficient. */
  318. /* */
  319. /* xy :: Matrix coefficient. */
  320. /* */
  321. /* yx :: Matrix coefficient. */
  322. /* */
  323. /* yy :: Matrix coefficient. */
  324. /* */
  325. typedef struct FT_Matrix_
  326. {
  327. FT_Fixed xx, xy;
  328. FT_Fixed yx, yy;
  329. } FT_Matrix;
  330. /*************************************************************************/
  331. /* */
  332. /* <Struct> */
  333. /* FT_Data */
  334. /* */
  335. /* <Description> */
  336. /* Read-only binary data represented as a pointer and a length. */
  337. /* */
  338. /* <Fields> */
  339. /* pointer :: The data. */
  340. /* */
  341. /* length :: The length of the data in bytes. */
  342. /* */
  343. typedef struct FT_Data_
  344. {
  345. const FT_Byte* pointer;
  346. FT_Int length;
  347. } FT_Data;
  348. /*************************************************************************/
  349. /* */
  350. /* <FuncType> */
  351. /* FT_Generic_Finalizer */
  352. /* */
  353. /* <Description> */
  354. /* Describe a function used to destroy the `client' data of any */
  355. /* FreeType object. See the description of the @FT_Generic type for */
  356. /* details of usage. */
  357. /* */
  358. /* <Input> */
  359. /* The address of the FreeType object that is under finalization. */
  360. /* Its client data is accessed through its `generic' field. */
  361. /* */
  362. typedef void (*FT_Generic_Finalizer)(void* object);
  363. /*************************************************************************/
  364. /* */
  365. /* <Struct> */
  366. /* FT_Generic */
  367. /* */
  368. /* <Description> */
  369. /* Client applications often need to associate their own data to a */
  370. /* variety of FreeType core objects. For example, a text layout API */
  371. /* might want to associate a glyph cache to a given size object. */
  372. /* */
  373. /* Some FreeType object contains a `generic' field, of type */
  374. /* FT_Generic, which usage is left to client applications and font */
  375. /* servers. */
  376. /* */
  377. /* It can be used to store a pointer to client-specific data, as well */
  378. /* as the address of a `finalizer' function, which will be called by */
  379. /* FreeType when the object is destroyed (for example, the previous */
  380. /* client example would put the address of the glyph cache destructor */
  381. /* in the `finalizer' field). */
  382. /* */
  383. /* <Fields> */
  384. /* data :: A typeless pointer to any client-specified data. This */
  385. /* field is completely ignored by the FreeType library. */
  386. /* */
  387. /* finalizer :: A pointer to a `generic finalizer' function, which */
  388. /* will be called when the object is destroyed. If this */
  389. /* field is set to NULL, no code will be called. */
  390. /* */
  391. typedef struct FT_Generic_
  392. {
  393. void* data;
  394. FT_Generic_Finalizer finalizer;
  395. } FT_Generic;
  396. /*************************************************************************/
  397. /* */
  398. /* <Macro> */
  399. /* FT_MAKE_TAG */
  400. /* */
  401. /* <Description> */
  402. /* This macro converts four-letter tags that are used to label */
  403. /* TrueType tables into an unsigned long, to be used within FreeType. */
  404. /* */
  405. /* <Note> */
  406. /* The produced values *must* be 32-bit integers. Don't redefine */
  407. /* this macro. */
  408. /* */
  409. #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
  410. (FT_Tag) \
  411. ( ( (FT_ULong)_x1 << 24 ) | \
  412. ( (FT_ULong)_x2 << 16 ) | \
  413. ( (FT_ULong)_x3 << 8 ) | \
  414. (FT_ULong)_x4 )
  415. /*************************************************************************/
  416. /*************************************************************************/
  417. /* */
  418. /* L I S T M A N A G E M E N T */
  419. /* */
  420. /*************************************************************************/
  421. /*************************************************************************/
  422. /*************************************************************************/
  423. /* */
  424. /* <Section> */
  425. /* list_processing */
  426. /* */
  427. /*************************************************************************/
  428. /*************************************************************************/
  429. /* */
  430. /* <Type> */
  431. /* FT_ListNode */
  432. /* */
  433. /* <Description> */
  434. /* Many elements and objects in FreeType are listed through an */
  435. /* @FT_List record (see @FT_ListRec). As its name suggests, an */
  436. /* FT_ListNode is a handle to a single list element. */
  437. /* */
  438. typedef struct FT_ListNodeRec_* FT_ListNode;
  439. /*************************************************************************/
  440. /* */
  441. /* <Type> */
  442. /* FT_List */
  443. /* */
  444. /* <Description> */
  445. /* A handle to a list record (see @FT_ListRec). */
  446. /* */
  447. typedef struct FT_ListRec_* FT_List;
  448. /*************************************************************************/
  449. /* */
  450. /* <Struct> */
  451. /* FT_ListNodeRec */
  452. /* */
  453. /* <Description> */
  454. /* A structure used to hold a single list element. */
  455. /* */
  456. /* <Fields> */
  457. /* prev :: The previous element in the list. NULL if first. */
  458. /* */
  459. /* next :: The next element in the list. NULL if last. */
  460. /* */
  461. /* data :: A typeless pointer to the listed object. */
  462. /* */
  463. typedef struct FT_ListNodeRec_
  464. {
  465. FT_ListNode prev;
  466. FT_ListNode next;
  467. void* data;
  468. } FT_ListNodeRec;
  469. /*************************************************************************/
  470. /* */
  471. /* <Struct> */
  472. /* FT_ListRec */
  473. /* */
  474. /* <Description> */
  475. /* A structure used to hold a simple doubly-linked list. These are */
  476. /* used in many parts of FreeType. */
  477. /* */
  478. /* <Fields> */
  479. /* head :: The head (first element) of doubly-linked list. */
  480. /* */
  481. /* tail :: The tail (last element) of doubly-linked list. */
  482. /* */
  483. typedef struct FT_ListRec_
  484. {
  485. FT_ListNode head;
  486. FT_ListNode tail;
  487. } FT_ListRec;
  488. /* */
  489. #define FT_IS_EMPTY( list ) ( (list).head == 0 )
  490. #define FT_BOOL( x ) ( (FT_Bool)( x ) )
  491. /* concatenate C tokens */
  492. #define FT_ERR_XCAT( x, y ) x ## y
  493. #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
  494. /* see `ftmoderr.h' for descriptions of the following macros */
  495. #define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
  496. #define FT_ERROR_BASE( x ) ( (x) & 0xFF )
  497. #define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
  498. #define FT_ERR_EQ( x, e ) \
  499. ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) )
  500. #define FT_ERR_NEQ( x, e ) \
  501. ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) )
  502. FT_END_HEADER
  503. #endif /* __FTTYPES_H__ */
  504. /* END */