fttypes.h 34 KB

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