ftmoderr.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /****************************************************************************
  2. *
  3. * ftmoderr.h
  4. *
  5. * FreeType module error offsets (specification).
  6. *
  7. * Copyright (C) 2001-2023 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. /**************************************************************************
  18. *
  19. * This file is used to define the FreeType module error codes.
  20. *
  21. * If the macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` in `ftoption.h` is
  22. * set, the lower byte of an error value identifies the error code as
  23. * usual. In addition, the higher byte identifies the module. For
  24. * example, the error `FT_Err_Invalid_File_Format` has value 0x0003, the
  25. * error `TT_Err_Invalid_File_Format` has value 0x1303, the error
  26. * `T1_Err_Invalid_File_Format` has value 0x1403, etc.
  27. *
  28. * Note that `FT_Err_Ok`, `TT_Err_Ok`, etc. are always equal to zero,
  29. * including the high byte.
  30. *
  31. * If `FT_CONFIG_OPTION_USE_MODULE_ERRORS` isn't set, the higher byte of an
  32. * error value is set to zero.
  33. *
  34. * To hide the various `XXX_Err_` prefixes in the source code, FreeType
  35. * provides some macros in `fttypes.h`.
  36. *
  37. * FT_ERR( err )
  38. *
  39. * Add current error module prefix (as defined with the `FT_ERR_PREFIX`
  40. * macro) to `err`. For example, in the BDF module the line
  41. *
  42. * ```
  43. * error = FT_ERR( Invalid_Outline );
  44. * ```
  45. *
  46. * expands to
  47. *
  48. * ```
  49. * error = BDF_Err_Invalid_Outline;
  50. * ```
  51. *
  52. * For simplicity, you can always use `FT_Err_Ok` directly instead of
  53. * `FT_ERR( Ok )`.
  54. *
  55. * FT_ERR_EQ( errcode, err )
  56. * FT_ERR_NEQ( errcode, err )
  57. *
  58. * Compare error code `errcode` with the error `err` for equality and
  59. * inequality, respectively. Example:
  60. *
  61. * ```
  62. * if ( FT_ERR_EQ( error, Invalid_Outline ) )
  63. * ...
  64. * ```
  65. *
  66. * Using this macro you don't have to think about error prefixes. Of
  67. * course, if module errors are not active, the above example is the
  68. * same as
  69. *
  70. * ```
  71. * if ( error == FT_Err_Invalid_Outline )
  72. * ...
  73. * ```
  74. *
  75. * FT_ERROR_BASE( errcode )
  76. * FT_ERROR_MODULE( errcode )
  77. *
  78. * Get base error and module error code, respectively.
  79. *
  80. * It can also be used to create a module error message table easily with
  81. * something like
  82. *
  83. * ```
  84. * #undef FTMODERR_H_
  85. * #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s },
  86. * #define FT_MODERR_START_LIST {
  87. * #define FT_MODERR_END_LIST { 0, 0 } };
  88. *
  89. * const struct
  90. * {
  91. * int mod_err_offset;
  92. * const char* mod_err_msg
  93. * } ft_mod_errors[] =
  94. *
  95. * #include <freetype/ftmoderr.h>
  96. * ```
  97. *
  98. */
  99. #ifndef FTMODERR_H_
  100. #define FTMODERR_H_
  101. /*******************************************************************/
  102. /*******************************************************************/
  103. /***** *****/
  104. /***** SETUP MACROS *****/
  105. /***** *****/
  106. /*******************************************************************/
  107. /*******************************************************************/
  108. #undef FT_NEED_EXTERN_C
  109. #ifndef FT_MODERRDEF
  110. #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
  111. #define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v,
  112. #else
  113. #define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0,
  114. #endif
  115. #define FT_MODERR_START_LIST enum {
  116. #define FT_MODERR_END_LIST FT_Mod_Err_Max };
  117. #ifdef __cplusplus
  118. #define FT_NEED_EXTERN_C
  119. extern "C" {
  120. #endif
  121. #endif /* !FT_MODERRDEF */
  122. /*******************************************************************/
  123. /*******************************************************************/
  124. /***** *****/
  125. /***** LIST MODULE ERROR BASES *****/
  126. /***** *****/
  127. /*******************************************************************/
  128. /*******************************************************************/
  129. #ifdef FT_MODERR_START_LIST
  130. FT_MODERR_START_LIST
  131. #endif
  132. FT_MODERRDEF( Base, 0x000, "base module" )
  133. FT_MODERRDEF( Autofit, 0x100, "autofitter module" )
  134. FT_MODERRDEF( BDF, 0x200, "BDF module" )
  135. FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" )
  136. FT_MODERRDEF( Cache, 0x400, "cache module" )
  137. FT_MODERRDEF( CFF, 0x500, "CFF module" )
  138. FT_MODERRDEF( CID, 0x600, "CID module" )
  139. FT_MODERRDEF( Gzip, 0x700, "Gzip module" )
  140. FT_MODERRDEF( LZW, 0x800, "LZW module" )
  141. FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" )
  142. FT_MODERRDEF( PCF, 0xA00, "PCF module" )
  143. FT_MODERRDEF( PFR, 0xB00, "PFR module" )
  144. FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" )
  145. FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" )
  146. FT_MODERRDEF( PSnames, 0xE00, "PS names module" )
  147. FT_MODERRDEF( Raster, 0xF00, "raster module" )
  148. FT_MODERRDEF( SFNT, 0x1000, "SFNT module" )
  149. FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" )
  150. FT_MODERRDEF( TrueType, 0x1200, "TrueType module" )
  151. FT_MODERRDEF( Type1, 0x1300, "Type 1 module" )
  152. FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
  153. FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
  154. FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
  155. FT_MODERRDEF( Sdf, 0x1700, "Signed distance field raster module" )
  156. #ifdef FT_MODERR_END_LIST
  157. FT_MODERR_END_LIST
  158. #endif
  159. /*******************************************************************/
  160. /*******************************************************************/
  161. /***** *****/
  162. /***** CLEANUP *****/
  163. /***** *****/
  164. /*******************************************************************/
  165. /*******************************************************************/
  166. #ifdef FT_NEED_EXTERN_C
  167. }
  168. #endif
  169. #undef FT_MODERR_START_LIST
  170. #undef FT_MODERR_END_LIST
  171. #undef FT_MODERRDEF
  172. #undef FT_NEED_EXTERN_C
  173. #endif /* FTMODERR_H_ */
  174. /* END */