fttypes.h 35 KB

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