ftgzip.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /***************************************************************************/
  2. /* */
  3. /* ftgzip.h */
  4. /* */
  5. /* Gzip-compressed stream support. */
  6. /* */
  7. /* Copyright 2002-2004, 2006, 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 __FTGZIP_H__
  18. #define __FTGZIP_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. #ifdef FREETYPE_H
  22. #error "freetype.h of FreeType 1 has been loaded!"
  23. #error "Please fix the directory search order for header files"
  24. #error "so that freetype.h of FreeType 2 is found first."
  25. #endif
  26. FT_BEGIN_HEADER
  27. /*************************************************************************/
  28. /* */
  29. /* <Section> */
  30. /* gzip */
  31. /* */
  32. /* <Title> */
  33. /* GZIP Streams */
  34. /* */
  35. /* <Abstract> */
  36. /* Using gzip-compressed font files. */
  37. /* */
  38. /* <Description> */
  39. /* This section contains the declaration of Gzip-specific functions. */
  40. /* */
  41. /*************************************************************************/
  42. /************************************************************************
  43. *
  44. * @function:
  45. * FT_Stream_OpenGzip
  46. *
  47. * @description:
  48. * Open a new stream to parse gzip-compressed font files. This is
  49. * mainly used to support the compressed `*.pcf.gz' fonts that come
  50. * with XFree86.
  51. *
  52. * @input:
  53. * stream ::
  54. * The target embedding stream.
  55. *
  56. * source ::
  57. * The source stream.
  58. *
  59. * @return:
  60. * FreeType error code. 0~means success.
  61. *
  62. * @note:
  63. * The source stream must be opened _before_ calling this function.
  64. *
  65. * Calling the internal function `FT_Stream_Close' on the new stream will
  66. * *not* call `FT_Stream_Close' on the source stream. None of the stream
  67. * objects will be released to the heap.
  68. *
  69. * The stream implementation is very basic and resets the decompression
  70. * process each time seeking backwards is needed within the stream.
  71. *
  72. * In certain builds of the library, gzip compression recognition is
  73. * automatically handled when calling @FT_New_Face or @FT_Open_Face.
  74. * This means that if no font driver is capable of handling the raw
  75. * compressed file, the library will try to open a gzipped stream from
  76. * it and re-open the face with it.
  77. *
  78. * This function may return `FT_Err_Unimplemented_Feature' if your build
  79. * of FreeType was not compiled with zlib support.
  80. */
  81. FT_EXPORT( FT_Error )
  82. FT_Stream_OpenGzip( FT_Stream stream,
  83. FT_Stream source );
  84. /************************************************************************
  85. *
  86. * @function:
  87. * FT_Gzip_Uncompress
  88. *
  89. * @description:
  90. * Decompress a zipped input buffer into an output buffer. This function
  91. * is modeled after zlib's `uncompress' function.
  92. *
  93. * @input:
  94. * memory ::
  95. * A FreeType memory handle.
  96. *
  97. * input ::
  98. * The input buffer.
  99. *
  100. * input_len ::
  101. * The length of the input buffer.
  102. *
  103. * @output:
  104. * output::
  105. * The output buffer.
  106. *
  107. * @inout:
  108. * output_len ::
  109. * Before calling the function, this is the the total size of the
  110. * output buffer, which must be large enough to hold the entire
  111. * uncompressed data (so the size of the uncompressed data must be
  112. * known in advance). After calling the function, `output_len' is the
  113. * size of the used data in `output'.
  114. *
  115. * @return:
  116. * FreeType error code. 0~means success.
  117. *
  118. * @note:
  119. * This function may return `FT_Err_Unimplemented_Feature' if your build
  120. * of FreeType was not compiled with zlib support.
  121. */
  122. FT_EXPORT( FT_Error )
  123. FT_Gzip_Uncompress( FT_Memory memory,
  124. FT_Byte* output,
  125. FT_ULong* output_len,
  126. const FT_Byte* input,
  127. FT_ULong input_len );
  128. /* */
  129. FT_END_HEADER
  130. #endif /* __FTGZIP_H__ */
  131. /* END */