fttypes.h 32 KB

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